Graphics.DrawBezier Method

Definition

Draws a Bézier spline defined by four Point structures.

Overloads

DrawBezier(Pen, Point, Point, Point, Point)

Draws a Bézier spline defined by four Point structures.

DrawBezier(Pen, PointF, PointF, PointF, PointF)

Draws a Bézier spline defined by four PointF structures.

DrawBezier(Pen, Single, Single, Single, Single, Single, Single, Single, Single)

Draws a Bézier spline defined by four ordered pairs of coordinates that represent points.

DrawBezier(Pen, Point, Point, Point, Point)

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

Draws a Bézier spline defined by four Point structures.

C#
public void DrawBezier(System.Drawing.Pen pen, System.Drawing.Point pt1, System.Drawing.Point pt2, System.Drawing.Point pt3, System.Drawing.Point pt4);

Parameters

pen
Pen

Pen structure that determines the color, width, and style of the curve.

pt1
Point

Point structure that represents the starting point of the curve.

pt2
Point

Point structure that represents the first control point for the curve.

pt3
Point

Point structure that represents the second control point for the curve.

pt4
Point

Point structure that represents the ending point of the curve.

Exceptions

pen 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 a black pen.

  • Creates the start, end, and two control points for the curve.

  • Draws the Bézier curve to the screen.

C#
private void DrawBezierPoint(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create points for curve.
    Point start = new Point(100, 100);
    Point control1 = new Point(200, 10);
    Point control2 = new Point(350, 50);
    Point end = new Point(500, 100);
             
    // Draw arc to screen.
    e.Graphics.DrawBezier(blackPen, start, control1, control2, end);
}

Remarks

The Bézier curve is drawn from the first point to the fourth point. The second and third points are control points that determine the shape of the curve.

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

DrawBezier(Pen, PointF, PointF, PointF, PointF)

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

Draws a Bézier spline defined by four PointF structures.

C#
public void DrawBezier(System.Drawing.Pen pen, System.Drawing.PointF pt1, System.Drawing.PointF pt2, System.Drawing.PointF pt3, System.Drawing.PointF pt4);

Parameters

pen
Pen

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

pt1
PointF

PointF structure that represents the starting point of the curve.

pt2
PointF

PointF structure that represents the first control point for the curve.

pt3
PointF

PointF structure that represents the second control point for the curve.

pt4
PointF

PointF structure that represents the ending point of the curve.

Exceptions

pen 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 a black pen.

  • Creates the start, end, and two control points for the curve.

  • Draws the Bézier curve to the screen.

C#
private void DrawBezierPointF(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create points for curve.
    PointF start = new PointF(100.0F, 100.0F);
    PointF control1 = new PointF(200.0F, 10.0F);
    PointF control2 = new PointF(350.0F, 50.0F);
    PointF end = new PointF(500.0F, 100.0F);
             
    // Draw arc to screen.
    e.Graphics.DrawBezier(blackPen, start, control1, control2, end);
}

Remarks

The Bézier spline is drawn from the first point to the fourth point. The second and third points are control points that determine the shape of the curve.

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

DrawBezier(Pen, Single, Single, Single, Single, Single, Single, Single, Single)

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

Draws a Bézier spline defined by four ordered pairs of coordinates that represent points.

C#
public void DrawBezier(System.Drawing.Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);

Parameters

pen
Pen

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

x1
Single

The x-coordinate of the starting point of the curve.

y1
Single

The y-coordinate of the starting point of the curve.

x2
Single

The x-coordinate of the first control point of the curve.

y2
Single

The y-coordinate of the first control point of the curve.

x3
Single

The x-coordinate of the second control point of the curve.

y3
Single

The y-coordinate of the second control point of the curve.

x4
Single

The x-coordinate of the ending point of the curve.

y4
Single

The y-coordinate of the ending point of the curve.

Exceptions

pen 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 a black pen.

  • Creates the coordinates of the start, end, and two control points for the curve.

  • Draws the Bézier curve to the screen.

C#
private void DrawBezierFloat(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create coordinates of points for curve.
    float startX = 100.0F;
    float startY = 100.0F;
    float controlX1 = 200.0F;
    float controlY1 =  10.0F;
    float controlX2 = 350.0F;
    float controlY2 =  50.0F;
    float endX = 500.0F;
    float endY = 100.0F;
             
    // Draw arc to screen.
    e.Graphics.DrawBezier(blackPen, startX, startY,
        controlX1, controlY1,
        controlX2, controlY2,
        endX, endY);
}

Remarks

The Bézier spline is drawn from the first point to the fourth point. The second and third points are control points that determine the shape of the curve.

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