Help Center

CGpGraphics.DrawBeziersmethod

Draws a sequence of connected Bézier splines.

GraphicsmethodCGpGraphics.incdocumented

Syntax

FUNCTION DrawBeziers (BYVAL pPen AS CGpPen PTR, BYVAL pts AS GpPointF PTR, BYVAL count AS INT_) AS GpStatus

Parameters

NameDescription
pPenPointer to a pen that is used to draw the Bézier spline.
ptsPointer to an array of GpPointF objects that specify the starting, ending, and control points of the Bézier splines.
countInteger that specifies the number of elements in the points array.

Return value

If the function succeeds, it returns StatusOk, which is an element of the GpStatus enumeration.

If the function fails, it returns one of the other elements of the GpStatus enumeration.

Description

Draws a sequence of connected Bézier splines.

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 a Bézier spline bends. Each Bézier spline requires a starting point and an ending point. Each ending point is the starting point for the next Bézier spline.

Example

' ======================================================================================== ' The following example draws a pair of Bézier curves. ' ======================================================================================== SUB Example_DrawBeziers (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Get the DPI scaling ratio DIM rxRatio AS SINGLE = graphics.GetDpiX / 96 DIM ryRatio AS SINGLE = graphics.GetDpiY / 96 ' // Set the scale transform graphics.ScaleTransform(rxRatio, ryRatio)

' // Define a Pen object and an array of PointF objects. DIM greenPen AS CGpPen = ARGB_LIGHTGREEN DIM startPoint AS GpPointF = (100.0, 100.0) DIM ctrlPoint1 AS GpPointF = (200.0, 50.0) DIM ctrlPoint2 AS GpPointF = (400.0, 10.0) DIM endPoint1 AS GpPointF = (500.0, 100.0) DIM ctrlPoint3 AS GpPointF = (600.0, 200.0) DIM ctrlPoint4 AS GpPointF = (700.0, 400.0) DIM endPoint2 AS GpPointF = (500.0, 500.0)

DIM curvePoints(6) AS GpPointF curvePoints(0) = startPoint curvePoints(1) = ctrlPoint1 curvePoints(2) = ctrlPoint2 curvePoints(3) = endPoint1 curvePoints(4) = ctrlPoint3 curvePoints(5) = ctrlPoint4 curvePoints(6) = endPoint2

' // Draw the Bezier curves. graphics.DrawBeziers(@greenPen, @curvePoints(0), 7)

' // Draw the control and end points. DIM redBrush AS CGpSolidBrush = ARGB_RED graphics.FillEllipse(@redBrush, 100 - 5, 100 - 5, 10, 10) graphics.FillEllipse(@redBrush, 500 - 5, 100 - 5, 10, 10) graphics.FillEllipse(@redBrush, 500 - 5, 500 - 5, 10, 10) DIM blueBrush AS CGpSolidBrush = ARGB_BLUE graphics.FillEllipse(@blueBrush, 200 - 5, 50 - 5, 10, 10) graphics.FillEllipse(@blueBrush, 400 - 5, 10 - 5, 10, 10) graphics.FillEllipse(@blueBrush, 600 - 5, 200 - 5, 10, 10) graphics.FillEllipse(@blueBrush, 700 - 5, 400 - 5, 10, 10)

END SUB ' ========================================================================================

Reference

  • Include file CGpGraphics.inc
  • Defined in AfxNova/CGpGraphics.inc:522
  • Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
  • Topic: CGpGraphics Class