Graphics::DrawBezier(constPen*,REAL,REAL,REAL,REAL,REAL,REAL,REAL,REAL) method (gdiplusgraphics.h)

The Graphics::DrawBezier method draws a Bézier spline.

Syntax

Status DrawBezier(
  const Pen *pen,
  REAL      x1,
  REAL      y1,
  REAL      x2,
  REAL      y2,
  REAL      x3,
  REAL      y3,
  REAL      x4,
  REAL      y4
);

Parameters

pen

Pointer to a pen that is used to draw the Bézier spline.

x1

Real number that specifies the x-coordinate of the starting point of the Bézier spline.

y1

Real number that specifies the y-coordinate of the starting point of the Bézier spline.

x2

Real number that specifies the x-coordinate of the first control point of the Bézier spline.

y2

Real number that specifies the y-coordinate of the first control point of the Bézier spline.

x3

Real number that specifies the x-coordinate of the second control point of the Bézier spline.

y3

Real number that specifies the y-coordinate of the second control point of the Bézier spline.

x4

Real number that specifies the x-coordinate of the ending point of the Bézier spline.

y4

Real number that specifies the y-coordinate of the ending point of the Bézier spline.

Return value

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

A Bézier spline does not pass through its control points. The control points act as magnets, pulling the curve in certain directions to influence the way the Bézier spline bends.

Examples

The following example draws a Bézier curve.

VOID Example_DrawBezier4(HDC hdc)
{
   Graphics graphics(hdc);

   // Set up the pen and curve points.
   Pen greenPen(Color(255, 0, 255, 0));
   REAL startPointx = 100.0f;
   REAL startPointy = 100.0f;
   REAL ctrlPoint1x = 200.0f;
   REAL ctrlPoint1y = 10.0f;
   REAL ctrlPoint2x = 350.0f;
   REAL ctrlPoint2y = 50.0f;
   REAL endPointx = 500.0f;
   REAL endPointy = 100.0f;

   //Draw the curve.
   graphics.DrawBezier(
   &greenPen,
   startPointx,
   startPointy,
   ctrlPoint1x,
   ctrlPoint1y,
   ctrlPoint2x,
   ctrlPoint2y,
   endPointx,
   endPointy);

   //Draw the end points and control points.
   SolidBrush redBrush(Color(255, 255, 0, 0));
   SolidBrush blueBrush(Color(255, 0, 0, 255));
   graphics.FillEllipse(&redBrush, 100 - 5, 100 - 5, 10, 10);
   graphics.FillEllipse(&redBrush, 500 - 5, 100 - 5, 10, 10);
   graphics.FillEllipse(&blueBrush, 200 - 5, 10 - 5, 10, 10);
   graphics.FillEllipse(&blueBrush, 350 - 5, 50 - 5, 10, 10);
}

Requirements

Requirement Value
Header gdiplusgraphics.h

See also

Graphics

DrawBezier

DrawBeziers Methods

Pen

Drawing Bézier Splines

Bézier Splines