Paths define a filled graphic tag that draws a series of
path segments. In vector graphics, a path is a series of points
connected by straight or curved line segments. Together the lines
form an image.
In FXG, you use a <Path> tag to define
a vector shape constructed from a set of line segments. The MXML
graphics equivalent of the FXG <Path> tag
is the Path class.
In MXML, you use the <s:Path> tag.
There are several different types of path segments you can use:
line, cubic bezier, and quadratic bezier. Typically, the first tag
of a path definition moves the pen to the starting position of the
graphic. You then use the segments to draw the lines of the graphic.
To define a series of segments in a path, you use the path’s data property.
You pass this property a series of instructions using shorthand
syntax. Each value is preceded by a letter that acts as a segment
identifier. The segment identifier indicates which type of segment
to draw with the numeric values that follow it.
The following table describes the shorthand syntax used by the
Path tag’s
data property:
Segment Type
|
Segment Identifier
|
Parameters
|
Example
|
Close path
|
Z/z
|
n/a
|
Z
Closes off the
path.
|
Cubic Bezier
|
C/c
|
c1X c1Y c2X c2Y x y
|
C 45 50 20 30 10 20
Curve
to (10, 20), with the first control point at (45, 50) and the second
control point at (20, 30).
|
Cubic Bezier (without control points)
|
S/s
|
c2X c2Y x y
|
S 20 30 10 20
Curve to (10, 20), with
the second control point at (20, 30). The first control point is assumed
to be the reflection of the second control point on the previous
command relative to the current point.
|
Horizontal line
|
H/h
|
x
|
H 100
Horizontal
line to 100.
|
Line
|
L/l
|
x y
|
L 50 30
Line to (50,
30).
|
Move
|
M/m
|
x y
|
M 10 20
Move pen
position to (10, 20).
|
Quadratic Bezier
|
Q/q
|
cX cY x y
|
Q 110 45 90 30
Curve
to (90, 30) with the control point at (110, 45).
|
Quadratic Bezier (without control points)
|
T/t
|
x y
|
T 90 30
Curve to (90, 30). The control
point is the reflection of the control point on the previous command
relative to the current point.
|
Vertical line
|
V/v
|
y
|
V 100
Vertical line
to 100.
|
You can use an uppercase or lowercase letter for the segment
identifiers. If you specify a segment identifier using the uppercase
letter, then the positioning is absolute. If you specify a segment
identifier using the lowercase letter, then the positioning is relative.
When using segments, you do not need to specify the starting
position of the pen; the x and y coordinate of the starting point
is defined by the current pen position.
After drawing a line segment, the current pen position becomes
the x and y coordinates of the end point of the line. You can use
the Move segment type to reposition the pen without drawing a line.
The Path syntax is nearly identical to the SVG path syntax. This
makes it easy to convert SVG paths to FXG or MXML graphics. There
is one exception: FXG and MXML graphics do not support an “A” or
Arc segment. To create an arc (elliptical, parabolic, or otherwise),
use the the cubic Bezier and quadratic Bezier control points to
achieve any sort of arc.
Paths can contain effects such as transforms, filters, blend
modes, and masks.