Help Center

GdipAddPathCurve3function

Adds a cardinal spline to the current figure of this path.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipAddPathCurve3 (BYVAL path AS GpPath PTR, BYVAL points AS CONST GpPointF PTR, BYVAL count AS INT_, BYVAL offset AS INT_, BYVAL numberOfSegments AS INT_, BYVAL tension AS REAL) AS GpStatus
Also documented as GdipAddPathCurve3I — one description covers them all.

Parameters

NameDescription
path[in] Pointer to the GraphicsPath object.
points[in] Pointer to an array of points that define the cardinal spline. The cardinal spline is a curve that passes through each point in the array.
count[in] Long integer value that specifies the number of elements in the points array.
offset[in] Long integer value that specifies the index of the array element that is used as the first point of the cardinal spline.
numberOfSegments[in] Long integer value that specifies the number of segments in the cardinal spline. Segments are the curves that connect consecutive points in the array.
tension[in] Nonnegative simple precision value that controls the length of the curve and how the curve bends. A value of 0 specifies that the spline is a sequence of straight line segments. As the value increases, the curve becomes fuller.

Description

Adds a cardinal spline to the current figure of this path.

Remarks

You should keep a copy of the points array if those points will be needed later. The GraphicsPath object does not store the points passed to the GdipAddPathCurve function; instead, it converts the cardinal spline to a sequence of Bézier splines and stores the points that define those Bézier splines. You cannot retrieve the original array of points from the GraphicsPath object.

Example

' ======================================================================================== ' This example draws a cardinal spline using GdipAddPathCurve3 with per-point tension. ' ======================================================================================== SUB Example_DrawCurve3 (BYVAL hdc AS HDC)

DIM hStatus AS LONG

' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)

' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)

' // Create a GraphicsPath object and initializes the fill mode. DIM path AS GpPath PTR hStatus = GdipCreatePath(FillModeAlternate, @path)

' // Define points for the curve ' // Define a larger array of points DIM pts(0 TO 6) AS GpPointF pts(0).x = 40 : pts(0).y = 120 pts(1).x = 80 : pts(1).y = 60 pts(2).x = 120 : pts(2).y = 140 pts(3).x = 160 : pts(3).y = 80 pts(4).x = 200 : pts(4).y = 160 pts(5).x = 240 : pts(5).y = 100 pts(6).x = 280 : pts(6).y = 180

' // Add curve starting at offset 2, using 5 points, with tension 0.6 DIM offset AS LONG = 2 DIM segmentCount AS LONG = 4 DIM tension AS SINGLE = 0.6 hStatus = GdipAddPathCurve3(path, @pts(0), 7, offset, segmentCount, tension)

' // Create pen DIM pen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_OLIVE, 2, UnitWorld, @pen)

' // Draw path hStatus = GdipDrawPath(graphics, pen, path)

' // Cleanup IF pen THEN GdipDeleteBrush(pen) IF path THEN GdipDeletePath(path) IF graphics THEN GdipDeleteGraphics(graphics)

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

Reference

  • Defined in AfxNova/AfxGdiPlus.bi:2013
  • Documented in Graphics/GdiPlus Flat Api/GdiPlusGraphicsPath.md
  • Topic: GraphicsPath Functions