Graphics.DrawClosedCurve Method

Definition

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

Overloads

DrawClosedCurve(Pen, ReadOnlySpan<Point>, Single, FillMode)

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

DrawClosedCurve(Pen, PointF[], Single, FillMode)

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

DrawClosedCurve(Pen, Point[], Single, FillMode)

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

DrawClosedCurve(Pen, ReadOnlySpan<PointF>, Single, FillMode)

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

DrawClosedCurve(Pen, ReadOnlySpan<Point>)

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

DrawClosedCurve(Pen, Point[])

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

DrawClosedCurve(Pen, ReadOnlySpan<PointF>)

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

DrawClosedCurve(Pen, PointF[])

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

DrawClosedCurve(Pen, ReadOnlySpan<Point>, Single, FillMode)

Source:
Graphics.cs
Source:
Graphics.cs

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

public void DrawClosedCurve (System.Drawing.Pen pen, ReadOnlySpan<System.Drawing.Point> points, float tension, System.Drawing.Drawing2D.FillMode fillmode);

Parameters

pen
Pen

Pen that determines the color, width, and height of the curve.

points
ReadOnlySpan<Point>

Array of PointF structures that define the spline.

tension
Single

Value greater than or equal to 0.0F that specifies the tension of the curve.

fillmode
FillMode

Member of the FillMode enumeration that determines how the curve is filled. This parameter is required but is ignored.

Applies to

.NET 9 (package-provided) and Windows Desktop 9
Product Versions
.NET 9 (package-provided)
Windows Desktop 9

DrawClosedCurve(Pen, PointF[], Single, FillMode)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

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

public void DrawClosedCurve (System.Drawing.Pen pen, System.Drawing.PointF[] points, float tension, System.Drawing.Drawing2D.FillMode fillmode);

Parameters

pen
Pen

Pen that determines the color, width, and height of the curve.

points
PointF[]

Array of PointF structures that define the spline.

tension
Single

Value greater than or equal to 0.0F that specifies the tension of the curve.

fillmode
FillMode

Member of the FillMode enumeration that determines how the curve is filled. This parameter is required but is ignored.

Exceptions

pen is null.

-or-

points is null.

Examples

The following code 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.

The method uses a tension of 1.0 and sets the fill mode to FillMode.Alternate.

private 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);
}

Remarks

This method draws a closed cardinal spline that passes through each point in the array. If the last point does not match the first point, an additional curve segment is added from the last point to the first point to close it.

The array of points must contain at least four PointF structures.

The tension parameter determines the shape of the spline. If the value of the tension parameter is 0.0F, this method draws straight line segments to connect the points. Usually, the tension parameter is less than or equal to 1.0F. Values over 1.0F produce unusual results.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawClosedCurve(Pen, Point[], Single, FillMode)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

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

public void DrawClosedCurve (System.Drawing.Pen pen, System.Drawing.Point[] points, float tension, System.Drawing.Drawing2D.FillMode fillmode);

Parameters

pen
Pen

Pen that determines the color, width, and height of the curve.

points
Point[]

Array of Point structures that define the spline.

tension
Single

Value greater than or equal to 0.0F that specifies the tension of the curve.

fillmode
FillMode

Member of the FillMode enumeration that determines how the curve is filled. This parameter is required but ignored.

Exceptions

pen is null.

-or-

points is null.

Examples

The following code 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.

The method uses a tension of 1.0 and sets the fill mode to FillMode.Alternate.

private void DrawClosedCurvePointTension(PaintEventArgs e)
{

    // Create pens.
    Pen redPen = new Pen(Color.Red, 3);
    Pen greenPen = new Pen(Color.Green, 3);

    // Create points that define curve.
    Point point1 = new Point(50, 50);
    Point point2 = new Point(100, 25);
    Point point3 = new Point(200, 5);
    Point point4 = new Point(250, 50);
    Point point5 = new Point(300, 100);
    Point point6 = new Point(350, 200);
    Point point7 = new Point(250, 250);
    Point[] 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);
}

Remarks

This method draws a closed cardinal spline that passes through each point in the array. If the last point does not match the first point, an additional curve segment is added from the last point to the first point to close it.

The array of points must contain at least four Point structures.

The tension parameter determines the shape of the spline. If the value of the tension parameter is 0.0F, this method draws straight line segments to connect the points. Usually, the tension parameter is less than or equal to 1.0F. Values over 1.0F produce unusual results.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawClosedCurve(Pen, ReadOnlySpan<PointF>, Single, FillMode)

Source:
Graphics.cs
Source:
Graphics.cs

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

public void DrawClosedCurve (System.Drawing.Pen pen, ReadOnlySpan<System.Drawing.PointF> points, float tension, System.Drawing.Drawing2D.FillMode fillmode);

Parameters

pen
Pen

Pen that determines the color, width, and height of the curve.

points
ReadOnlySpan<PointF>

Array of PointF structures that define the spline.

tension
Single

Value greater than or equal to 0.0F that specifies the tension of the curve.

fillmode
FillMode

Member of the FillMode enumeration that determines how the curve is filled. This parameter is required but is ignored.

Applies to

.NET 9 (package-provided) and Windows Desktop 9
Product Versions
.NET 9 (package-provided)
Windows Desktop 9

DrawClosedCurve(Pen, ReadOnlySpan<Point>)

Source:
Graphics.cs
Source:
Graphics.cs

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

public void DrawClosedCurve (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.Point> points);

Parameters

pen
Pen

Pen that determines the color, width, and height of the curve.

points
ReadOnlySpan<Point>

Array of PointF structures that define the spline.

Applies to

.NET 9 (package-provided) and Windows Desktop 9
Product Versions
.NET 9 (package-provided)
Windows Desktop 9

DrawClosedCurve(Pen, Point[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

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

public void DrawClosedCurve (System.Drawing.Pen pen, params System.Drawing.Point[] points);
public void DrawClosedCurve (System.Drawing.Pen pen, System.Drawing.Point[] points);

Parameters

pen
Pen

Pen that determines the color, width, and height of the curve.

points
Point[]

Array of Point structures that define the spline.

Exceptions

pen is null.

-or-

points is null.

Examples

The following code 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 seven red straight lines between the seven points to form a closed polygon.

  • Draws a green closed curve through the seven points.

The method uses a default tension of 0.5.

private void DrawClosedCurvePoint(PaintEventArgs e)
{
    // Create pens.
    Pen redPen   = new Pen(Color.Red, 3);
    Pen greenPen = new Pen(Color.Green, 3);
             
    // Create points that define curve.
    Point point1 = new Point(50,  50);
    Point point2 = new Point(100,  25);
    Point point3 = new Point(200,   5);
    Point point4 = new Point(250,  50);
    Point point5 = new Point(300, 100);
    Point point6 = new Point(350, 200);
    Point point7 = new Point(250, 250);
    Point[] curvePoints =
             {
                 point1,
                 point2,
                 point3,
                 point4,
                 point5,
                 point6,
                 point7
             };
             
    // Draw lines between original points to screen.
    e.Graphics.DrawLines(redPen, curvePoints);
             
    // Draw closed curve to screen.
    e.Graphics.DrawClosedCurve(greenPen, curvePoints);
}

Remarks

This method draws a closed cardinal spline that passes through each point in the array. If the last point does not match the first point, an additional curve segment is added from the last point to the first point to close the figure.

The array of points must contain at least four Point structures.

This method uses a default tension of 0.5.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawClosedCurve(Pen, ReadOnlySpan<PointF>)

Source:
Graphics.cs
Source:
Graphics.cs

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

public void DrawClosedCurve (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.PointF> points);

Parameters

pen
Pen

Pen that determines the color, width, and height of the curve.

points
ReadOnlySpan<PointF>

Array of PointF structures that define the spline.

Applies to

.NET 9 (package-provided) and Windows Desktop 9
Product Versions
.NET 9 (package-provided)
Windows Desktop 9

DrawClosedCurve(Pen, PointF[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

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

public void DrawClosedCurve (System.Drawing.Pen pen, params System.Drawing.PointF[] points);
public void DrawClosedCurve (System.Drawing.Pen pen, System.Drawing.PointF[] points);

Parameters

pen
Pen

Pen that determines the color, width, and height of the curve.

points
PointF[]

Array of PointF structures that define the spline.

Exceptions

pen is null.

-or-

points is null.

Examples

The following code 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 seven red straight lines between the seven points to form a closed polygon.

  • Draws a green closed curve through the seven points.

The method uses a default tension of 0.5.

private void DrawClosedCurvePointF(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);

    // Draw closed curve to screen.
    e.Graphics.DrawClosedCurve(greenPen, curvePoints);
}

Remarks

This method draws a closed cardinal spline that passes through each point in the array. If the last point does not match the first point, an additional curve segment is added from the last point to the first point to close it.

The array of points must contain at least four PointF structures.

This method uses a default tension of 0.5.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9