CGpGraphicsPath.Flattenmethod
Applies a transformation to this path and converts each curve in the path to a sequence of connected lines.
Syntax
FUNCTION Flatten (BYVAL pMatrix AS CGpMatrix PTR = NULL, BYVAL flatness AS SINGLE = FlatnessDefault) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
pMatrix | Optional. Pointer to a Matrix object that specifies the transformation to be applied to the path's data points. The default value is NULL, which specifies that no transformation is to be applied. | |
flatness | Optional. 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, which is a constant defined in Gdiplusenums.bi. |
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
Applies a transformation to this path and converts each curve in the path to a sequence of connected lines.
Example
' ======================================================================================== ' The following example creates a GraphicsPath object and then adds a curve (cardinal spline), ' an ellipse, and a Bézier spline to the path. The code draws the path in blue, flattens ' the path, and then draws the flattened path in green. The call to GraphicsPath.GetPathData ' gets the data points stored by the flattened path. The code draws each of those points by ' filling a small ellipse with red. ' ======================================================================================== SUB Example_Flatten (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi
DIM pts(0 TO 3) AS GpPoint = {(20, 50), (40, 70), (60, 10), (80, 50)} DIM path AS CGpGraphicsPath path.AddCurve(@pts(0), 4) path.AddEllipse(20, 100, 150, 80) path.AddBezier(20, 200, 20, 250, 50, 210, 100, 260)
' // Draw the path before flattening DIM pen AS CGpPen = ARGB_BLUE graphics.DrawPath(@pen, @path)
path.Flatten(NULL, 8.0)
' // Draw the flattened path pen.SetColor(ARGB_LIGHTGREEN) graphics.DrawPath(@pen, @path)
' // Get the path data from the flattened path. DIM pathData AS GDIP_PATHDATA path.GetPathData(@pathData)
' // Draw the data points of the flattened path DIM brush AS CGpSolidBrush = ARGB_RED FOR j AS LONG = 0 TO pathData.Count - 1
graphics.FillEllipse(@brush, pathData.Points[j].x - 3.0, _
pathData.Points[j].y - 3.0, 6.0, 6.0)
NEXT
END SUB ' ========================================================================================
Reference
- Include file
CGpPath.inc - Defined in AfxNova/CGpPath.inc:505
- Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
- Topic: CGpGraphics Class