Export (0) Print
Expand All

Graphics.DrawCurve Method

Draws a cardinal spline through a specified array of Point structures.

Overload List

Draws a cardinal spline through a specified array of Point structures.

[Visual Basic] Overloads Public Sub DrawCurve(Pen, Point())
[C#] public void DrawCurve(Pen, Point[]);
[C++] public: void DrawCurve(Pen*, Point[]);
[JScript] public function DrawCurve(Pen, Point[]);

Draws a cardinal spline through a specified array of PointF structures.

[Visual Basic] Overloads Public Sub DrawCurve(Pen, PointF())
[C#] public void DrawCurve(Pen, PointF[]);
[C++] public: void DrawCurve(Pen*, PointF[]);
[JScript] public function DrawCurve(Pen, PointF[]);

Draws a cardinal spline through a specified array of Point structures using a specified tension.

[Visual Basic] Overloads Public Sub DrawCurve(Pen, Point(), Single)
[C#] public void DrawCurve(Pen, Point[], float);
[C++] public: void DrawCurve(Pen*, Point[], float);
[JScript] public function DrawCurve(Pen, Point[], float);

Draws a cardinal spline through a specified array of PointF structures using a specified tension.

[Visual Basic] Overloads Public Sub DrawCurve(Pen, PointF(), Single)
[C#] public void DrawCurve(Pen, PointF[], float);
[C++] public: void DrawCurve(Pen*, PointF[], float);
[JScript] public function DrawCurve(Pen, PointF[], float);

Draws a cardinal spline through a specified array of PointF structures. The drawing begins offset from the beginning of the array.

[Visual Basic] Overloads Public Sub DrawCurve(Pen, PointF(), Integer, Integer)
[C#] public void DrawCurve(Pen, PointF[], int, int);
[C++] public: void DrawCurve(Pen*, PointF[], int, int);
[JScript] public function DrawCurve(Pen, PointF[], int, int);

Draws a cardinal spline through a specified array of Point structures using a specified tension.

[Visual Basic] Overloads Public Sub DrawCurve(Pen, Point(), Integer, Integer, Single)
[C#] public void DrawCurve(Pen, Point[], int, int, float);
[C++] public: void DrawCurve(Pen*, Point[], int, int, float);
[JScript] public function DrawCurve(Pen, Point[], int, int, float);

Draws a cardinal spline through a specified array of PointF structures using a specified tension. The drawing begins offset from the beginning of the array.

[Visual Basic] Overloads Public Sub DrawCurve(Pen, PointF(), Integer, Integer, Single)
[C#] public void DrawCurve(Pen, PointF[], int, int, float);
[C++] public: void DrawCurve(Pen*, PointF[], int, int, float);
[JScript] public function DrawCurve(Pen, PointF[], int, int, float);

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates red and green pens.
  • Creates seven points to define a curve.
  • Draws six red straight lines between the seven points to form an incomplete polygon.
  • Defines the starting point offset and number of segments.
  • Defines the tension.
  • Draws an open green curve (starting at the third point) through the last five points.

[Visual Basic, C#] The method sets the tension to 1.0.

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of DrawCurve. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub DrawCurvePointFSegmentTension(e As PaintEventArgs)
' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)
' Create points that define curve.
Dim point1 As New PointF(50F, 50F)
Dim point2 As New PointF(100F, 25F)
Dim point3 As New PointF(200F, 5F)
Dim point4 As New PointF(250F, 50F)
Dim point5 As New PointF(300F, 100F)
Dim point6 As New PointF(350F, 200F)
Dim point7 As New PointF(250F, 250F)
Dim curvePoints As PointF() =  {point1, point2, point3, point4, _
point5, point6, point7}
' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)
' Create offset, number of segments, and tension.
Dim offset As Integer = 2
Dim numSegments As Integer = 4
Dim tension As Single = 1F
' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments, _
tension)
End Sub
        
[C#] 
public void DrawCurvePointFSegmentTension(PaintEventArgs e)
{
// Create pens.
Pen redPen   = new Pen(Color.Red, 3);
Pen greenPen = new Pen(Color.Green, 3);
// Create points that define curve.
PointF point1 = new PointF( 50.0F,  50.0F);
PointF point2 = new PointF(100.0F,  25.0F);
PointF point3 = new PointF(200.0F,   5.0F);
PointF point4 = new PointF(250.0F,  50.0F);
PointF point5 = new PointF(300.0F, 100.0F);
PointF point6 = new PointF(350.0F, 200.0F);
PointF point7 = new PointF(250.0F, 250.0F);
PointF[] curvePoints =
{
point1,
point2,
point3,
point4,
point5,
point6,
point7
};
// Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints);
// Create offset, number of segments, and tension.
int offset = 2;
int numSegments = 4;
float tension = 1.0F;
// Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments, tension);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

Show:
© 2014 Microsoft