Help Center

GdipWidenPathfunction

Replaces this path with curves that enclose the area that is filled when this path is drawn by a specified pen. This function also flattens the path.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipWidenPath (BYVAL path AS GpPath PTR, BYVAL pen AS GpPen PTR, BYVAL matrix AS GpMatrix PTR, BYVAL flatness AS REAL) AS GpStatus

Parameters

NameDescription
path[in] Pointer to the GraphicsPath object.
pen[in] Pointer to a Pen object. The path is made as wide as it would be when drawn by this pen.
matrix[in] Pointer to a Matrix object that specifies a transformation to be applied along with the widening. If this parameter is NULL, no transformation is applied. The default value is NULL.
flatness[in] Simple precision value that specifies the maximum error between the path and its flattened approximation. Reducing the flatness increases the number of line segments in the approximation. The default value is FlatnessDefault.

Description

Replaces this path with curves that enclose the area that is filled when this path is drawn by a specified pen. The Widen method also flattens the path.

Example

' ======================================================================================== ' The following example creates a GraphicsPath object and adds a closed curve to the path. ' The code creates a green pen that has a width of 10, changes its style to DashStyleDash, ' and passes the address of that pen to the GdipWidenPath function. Then the code draws the ' path with a blue pen of width 1. ' ======================================================================================== SUB Example_WidenPath (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 path DIM path AS GpPath PTR hStatus = GdipCreatePath(FillModeAlternate, @path)

' // Create the pens. DIM bluePen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_RED, 1, UnitWorld, @bluePen) DIM greenPen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_LIGHTGREEN, 10, UnitWorld, @greenPen)

' // Add a closed curve. DIM pts(3) AS GpPointF pts(0).x = 20 : pts(0).y = 20 pts(1).x = 160 : pts(1).y = 100 pts(2).x = 140 : pts(2).y = 60 pts(3).x = 60 : pts(3).y = 100 hStatus = GdipAddPathClosedCurve(path, @pts(0), 4)

' // The GdipWidenPath function respects the dash style of the specified pen ' // (the green pen in this case). The following instruction changes it. hStatus = GdipSetPenDashStyle(greenPen, DashStyleDash)

' // Widen the path. hStatus = GdipWidenPath(path, greenPen, NULL, FlatnessDefault)

' // Draw the path. hStatus = GdipDrawPath(graphics, bluePen, path)

' // Cleanup IF bluePen THEN GdipDeletePen(bluePen) IF greenPen THEN GdipDeletePen(greenPen) IF path THEN GdipDeletePath(path) IF graphics THEN GdipDeleteGraphics(graphics)

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

Reference

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