在网上看到一段代码,觉得有意思,就修改了下共享CSDN读友。
程序运行界面:
在看代码:
private void printDramC(Graphics g) { const int MID = 150; const int Top = 50; this.Text = "simple graphics snowman"; Font font = new Font("隶书",17); Pen blue = new Pen(Color.Blue); Pen yellow = new Pen(Color.Yellow); Pen white = new Pen(Color.White); Pen red = new Pen(Color.Red); Pen black = new Pen(Color.Black); Brush brWhite = white.Brush; Brush brBlack = black.Brush; Brush brRed = red.Brush; g.FillRectangle(brRed, 20, 30, 30, 120); g.FillRectangle(brRed, 250, 30, 30, 120); g.FillRectangle(brRed, 100, 0, 100, 25); StringFormat format = new StringFormat(); format.FormatFlags = StringFormatFlags.DirectionVertical; g.DrawString("三杯祝福歌", font, brBlack, 250, 30, format); g.DrawString("一曲迎春调", font, brBlack, 20, 30, format); g.DrawString("迎春祝福", font, brBlack, 100, 0); g.DrawRectangle(blue, 0, 175, 300, 50); //sky g.DrawEllipse(yellow, -40, -40, 80, 80); //sun g.FillEllipse(brWhite, MID - 20, Top, 40, 40); //head g.FillEllipse(brWhite, MID - 35, Top + 35, 70, 50); //top g.FillEllipse(brWhite, MID - 50, Top + 80, 100, 60); //bot g.FillEllipse(brBlack, MID - 10, Top + 10, 5, 5); //l.eye g.FillEllipse(brBlack, MID + 5, Top + 10, 5, 5);//r.eye g.DrawArc(black, MID - 10, Top + 20, 20, 10, -190, -160);//(: //arms g.DrawLine(black, MID - 25, Top + 60, Top - 50, MID + 40); g.DrawLine(black, MID + 25, Top + 60, MID + 55, Top + 60); g.DrawLine(black, MID - 20, Top + 5, MID + 20, Top + 5);//hat,brim,top g.FillRectangle(brBlack, MID - 15, Top - 20, 30, 25); }