This documentation is archived and is not being maintained.

Graphics.DrawClosedCurve Method

Draws a closed cardinal spline defined by an array of Point structures.

Overload List

Draws a closed cardinal spline defined by an array of Point structures.

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

Draws a closed cardinal spline defined by an array of PointF structures.

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

Draws a closed cardinal spline defined by an array of Point structures using a specified tension.

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

Draws a closed cardinal spline defined by an array of PointF structures using a specified tension.

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

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 the curve.
  • Draws seven red straight lines between the seven points to form a polygon.
  • Creates tension and fill mode settings.
  • Draws a green closed curve through the seven points.

[Visual Basic, C#] The method uses the a tension of 1.0 and sets the fill mode to FillMode.Alternate.

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of DrawClosedCurve. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub DrawClosedCurvePointFTension(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 tension and fill mode.
Dim tension As Single = 1F
Dim aFillMode As FillMode = FillMode.Alternate
' Draw closed curve to screen.
e.Graphics.DrawClosedCurve(greenPen, curvePoints, tension, _
aFillMode)
End Sub
        
[C#] 
public void DrawClosedCurvePointFTension(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 tension and fill mode.
float tension = 1.0F;
FillMode aFillMode = FillMode.Alternate;
// Draw closed curve to screen.
e.Graphics.DrawClosedCurve(greenPen, curvePoints, tension, aFillMode);
}
        

[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: