2010 11 30 DrawCurve GDI绘制曲线

vDrawCurve()方法

该法用光滑的曲线把给定的点连接起来,常用形式有

 

public void DrawCurve(Pen pen, Point[] points)

其中,Point结构类型的数组中指明各节点,默认弯曲强度为0.5,注意数组中至少要有4个元素。

 

public void DrawCurve(Pen pen, Point[] points, float tension)

其中tension指定弯曲强度,该值范围为0.0f ~1.0f,超出此范围会产生异常,当弯曲强度为零时,就是直线

 

 

演示:

 

private void Form1_Paint(object sender,

                       System.Windows.Forms.PaintEventArgs e)

{

  Pen redPen   = new Pen(Color.Red, 3);

  Pen greenPen = new Pen(Color.Green, 3);

  Point[] curvePoints =

  {

  new Point( 50,  250),

  new Point(100,  25),

  new Point(200,  250),

  new Point(250,  50),

  new Point(300,  75),

  new Point(350,  200),

  new Point(400,  150)

  };

  e.Graphics.DrawLines(redPen, curvePoints);

  e.Graphics.DrawCurve(greenPen, curvePoints);

}

 

posted @ 2011-11-30 22:14  akak123  阅读(4763)  评论(0编辑  收藏  举报