首页 > 应用开发 > IT综合 > 浅析C#中图形编程之二(转)
| using System; using System.Windows.Forms; using System.Drawing; using System.Drawing.Drawing2D; public class Drawgra:Form { public Drawgra() { this.Text = "运用画笔示例"; this.Size = new Size(450,400); this.Paint += new PaintEventHandler(Draw_Graphics); } public void Draw_Graphics(object sender,PaintEventArgs e) { Graphics g = e.Graphics; Pen penline = new Pen(Color.Red,5); Pen penellipse = new Pen(Color.Blue,5); Pen penpie = new Pen(Color.Tomato,3); Pen penpolygon = new Pen(Color.Maroon,4); /*DashStyle有Dash、DashDot、DashDotDot、Dot、Solid等风格*/ //以Dash风格画一条直线 penline.DashStyle = DashStyle.Dash; g.DrawLine(penline,50,50,100,200); //以DashDotDot风格画一个椭圆 penellipse.DashStyle = DashStyle.DashDotDot; g.DrawEllipse(penellipse,15,15,50,50); //以Dot风格画一个馅饼图形 penpie.DashStyle = DashStyle.Dot; g.DrawPie(penpie,90,80,140,40,120,100); //以Solid风格画一个多边形 g.DrawPolygon(penpolygon,new Point[]{ new Point(30,140), new Point(270,250), new Point(110,240), new Point(200,170), new Point(70,350), new Point(50,200)}); } public static void Main() { Application.Run(new Drawgra()); } } |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/79548/viewspace-925519/ ,如需转载,请注明出处,否则将追究法律责任。