TRSPathData represents a series of connected curves and lines.
Note |
---|
Unlike the Delphi TPathData class, TRSPathData works with both FMX and VCL and may be drawn to either libraries' TCanvas. The TRSPathData class provides much more robust parsing of data strings than TPathData to fulfill the SVG specification for paths. Finally, there are many additional methods in TRSPathData compared to TPathData (for example, AddPolygon). |
Use TRSPathData to build graphic shapes by connecting a series of curves and lines. TRSPathData can be drawn and filled on objects that have a TCanvas as a component. For VCL, call the DrawPath and FillPath methods. The TVclCanvasHelper also implements DrawPath and FillPath methods for VCL TCanvas.
TRSPathData maintains the coordinates of geometric shapes in world coordinate space in an array of FMX.RS.Graphics.TRSPathPoint. Each saved point has a specific type, to identify the primitive shape it is defining. Complex shapes of a TRSPathData are composed of a sequence of primitive shapes like lines and curves. To access the array of TRSPathPoint, use Count and Points.
A TRSPathData can be initialized by setting the Data property, or by adding explicitly each new shape. TRSPathData has defined a way to add shapes explicitly. See the TRSPathData functions.
When a TRSPathData is constructed, each new added shape is appended to the end of the TRSPathData, by default. The start point of the new shape is the end point of the previous shape. To customize the start point of a new element to be added, use the MoveTo or MoveToRel method.
Namespace: FMX.RS.Graphics
TPathData |
Delphi |
type |
|
The path data syntax is a prefix notation (i.e., commands followed by parameters). The only allowable decimal point is a FULL STOP (".") character and no other delimiter characters are allowed. (For example, the following is an invalid numeric value in a path data stream: "13,000.56". Instead, say: "13000.56".) For the relative versions of the commands, all coordinate values are relative to the current point at the start of the command. The following table list the commands. |
|||||||||||||||||||||||||
M (absolute) m (relative) |
Start a new sub-path at the given (x,y) coordinate. M (uppercase) indicates that absolute coordinates will follow; m (lowercase) indicates that relative coordinates will follow. If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit lineto commands. Hence, implicit lineto commands will be relative if the moveto is relative, and absolute if the moveto is absolute. If a relative moveto (m) appears as the first element of the path, then it is treated as a pair of absolute coordinates. In this case, subsequent pairs of coordinates are treated as relative even though the initial moveto is interpreted as an absolute moveto. |
||||||||||||||||||||||||
Z or z |
Close the current subpath by drawing a straight line from the current point to current subpath's initial point. Since the Z and z commands take no parameters, they have an identical effect. |
||||||||||||||||||||||||
L (absolute) l (relative) |
Add a line from the current point to the given (x,y) coordinate which becomes the new current point. L (uppercase) indicates that absolute coordinates will follow; l (lowercase) indicates that relative coordinates will follow. A number of coordinates pairs may be specified to draw a polyline. At the end of the command, the new current point is set to the final set of coordinates provided. |
||||||||||||||||||||||||
H (absolute) h (relative) |
Adds a horizontal line from the current point (cpx, cpy) to (x, cpy). H (uppercase) indicates that absolute coordinates will follow; h (lowercase) indicates that relative coordinates will follow. Multiple x values can be provided (although usually this doesn't make sense). At the end of the command, the new current point becomes (x, cpy) for the final value of x. |
||||||||||||||||||||||||
V (absolute) v (relative) |
Adds a vertical line from the current point (cpx, cpy) to (cpx, y). V (uppercase) indicates that absolute coordinates will follow; v (lowercase) indicates that relative coordinates will follow. Multiple y values can be provided (although usually this doesn't make sense). At the end of the command, the new current point becomes (cpx, y) for the final value of y. |
||||||||||||||||||||||||
C (absolute) c (relative) |
Adds a cubic Bézier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve. C (uppercase) indicates that absolute coordinates will follow; c (lowercase) indicates that relative coordinates will follow. Multiple sets of coordinates may be specified to draw a polybézier. At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybézier. |
||||||||||||||||||||||||
S (absolute) s (relative) |
Adds a cubic Bézier curve from the current point to (x,y). The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not an C, c, S or s, assume the first control point is coincident with the current point.) (x2,y2) is the second control point (i.e., the control point at the end of the curve). S (uppercase) indicates that absolute coordinates will follow; s (lowercase) indicates that relative coordinates will follow. Multiple sets of coordinates may be specified to draw a polybézier. At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybézier. |
||||||||||||||||||||||||
Q (absolute) q (relative) |
Adds a quadratic Bézier curve from the current point to (x,y) using (x1,y1) as the control point. Q (uppercase) indicates that absolute coordinates will follow; q (lowercase) indicates that relative coordinates will follow. Multiple sets of coordinates may be specified to draw a polybézier. At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybézier. |
||||||||||||||||||||||||
T (absolute) t (relative) |
Creates a quadratic Bézier curve from the current point to (x,y). The control point is assumed to be the reflection of the control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not a Q, q, T or t, assume the control point is coincident with the current point.) T (uppercase) indicates that absolute coordinates will follow; t (lowercase) indicates that relative coordinates will follow. At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybézier. |
||||||||||||||||||||||||
A (absolute) a (relative) |
Creates an elliptical arc from the current point to (x, y). The size and orientation of the ellipse are defined by two radii (rx, ry) and an x-axis-rotation, which indicates how the ellipse as a whole is rotated relative to the current coordinate system. The center (cx, cy) of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. large-arc-flag and sweep-flag contribute to the automatic calculations and help determine how the arc is drawn. |
Returns the distance to every point in the path
Note |
---|
It is recommended to Flatten the path before calling this property. |
Specifies how to fill areas that are formed when the path intersects itself.
Note |
---|
This property is ignored in FMX. |
Defines a floating point format string for writing out the path points.
Use the FormatStr property to control the size of the Data string.
Occurs when the path data has changed.
Write an OnChanged event handler to respond to path changes.
Returns the polygons (array of points) that make up the path.
Note |
---|
It is recommended to Flatten the path before calling this property. |
Tracks the number of times BeginUpdate has been called without a corresponding EndUpdate call.
SmoothCurveTo adds the control points and the end point of the curve to the Points array. The added points are of type ppCurveTo. To move the start point of the curve, call the MoveTo or MoveToRel method before calling SmoothCurveTo. To find the end point of the TRSPathData, call the LastPoint method. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Appends a smooth curve to the current TRSPathData. The smooth curve is defined by 4 points that depend on the last point of the current TRSPathData. The start point of the curve is the end point of the TRSPathData. If Points has more than 2 items, the first control point coincides with the start point, otherwise it is equal to the second control point. The ControlPoint2 parameter's coordinates specify the distances to the last point of the current TRSPathData, on each axis, for the second control point of the curve. The EndPoint parameter's coordinates specify the distances to the last point of the current TRSPathData, on each axis, for the end point of the curve. SmoothCurveToRel adds the control points and the end point of the curve to the Points array. The coordinates for each point are equal to the sum between the coordinates of the last point of the current TRSPathData and the coordinates of the corresponding points specified by the parameters. The added points are of type ppCurveTo. To move the start point of the curve, call the MoveTo or MoveToRel method before calling SmoothCurveToRel. To find the end point of the TRSPathData, call the LastPoint method. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Returns the string representation of the path data. The string representation is split every Len characters using the specified delimiter. SplitDataByLength returns a string that can be multiple lines of no more than Len length. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Converts the path data into an array of polygons.
|
Reference•TVclCanvasHelper •FMX.RS.Graphics.TRSPathData.DrawPath(TCanvas,Single) |