public void DrawLine(Pen pen, Point pt1,Point pt2)pen:Pen对象,确定线条颜色、宽度和样式。
Public void DrawLine(Pen pen,int x1,int y1,int x2,int y2)绘制直线的示例代码:
private void button1_Click(object sender, EventArgs e) { Graphics graphics = this.CreateGraphics(); Pen myPen = new Pen(Color.Blue, 2); graphics.DrawLine(myPen, 50, 30, 170, 30); }绘制矩形
public void DrawRectangle(Pen pen,Rectangle rect)pen:Pen对象,确定线条颜色、宽度和样式。
Rectangle rect = new Rectangle(0, 0, 80, 50);(2)绘制由坐标对、宽度和高度指定的矩形。
public void DrawRectangle(Pen pen, int x, int y, int width, int height)pen:Pen对象,确定线条颜色、宽度和样式。
private void button1_Click(object sender, EventArgs e) { Graphics graphics = this.CreateGraphics(); Pen myPen = new Pen(Color.Blue, 2); graphics.DrawRectangle(myPen, 70, 20, 80, 50); }绘制椭圆
public void DrawEllipse(Pen pen, Rectangle rect)(2)绘制一个由边框(该边框由一对坐标、高度和宽度指定)定义的椭圆。
public void DrawEllipse(Pen pen, int x, int y, int width, int height)绘制椭圆的示例代码:
private void button1_Click(object sender, EventArgs e) { Graphics graphics = this.CreateGraphics(); Pen myPen = new Pen(Color.Blue, 3); Rectangle myRectangle = new Rectangle(70, 20, 100, 60); graphics.DrawEllipse(myPen, myRectangle); }绘制圆弧
public void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle)pen:Pen对象,确定线条颜色、宽度和样式。
public void DrawArc(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)绘制圆弧的实例代码:
private void button1_Click(object sender, EventArgs e) { Graphics graphics = this.CreateGraphics(); Pen myPen = new Pen(Color.Blue, 5); Rectangle myRectangle = new Rectangle(70, 20, 100, 60); graphics.DrawArc(myPen, myRectangle,210,120); }绘制多边形
public void DrawPolygon(Pen pen, Point[] pints)
原文地址:http://blog.csdn.net/crazygolf/article/details/39031963