Specifies a list of one or more comma-separated commands that define the shape, using syntax similar to SVG path commands. Commands include <move-command>
, <line-command>
, <hv-line-command>
, <curve-command>
, <smooth-command>
, <arc-command>
, and close
. Each command's starting point is the previous command's ending point, with the first point of the shape defined by the from <coordinate-pair>
parameter.
The syntax of most shape commands is a keyword providing a directive, such as move
or line
, followed by the by
or to
keyword, and a set of coordinates.
by
: Indicates that the <coordinate-pair>
is relative to the command's starting point (a "relative" value).
to
: Indicates that the <coordinate-pair>
is relative to the top-left corner of the reference box (an "absolute" value).
Note: If a coordinate in a <coordinate-pair>
is specified as a percentage, the value is calculated relative to the respective width or height of the reference box.
The following <shape-command>
s can be specified: <move-command>
, <line-command>
, <hv-line-command>
, <curve-command>
, <smooth-command>
, <arc-command>
, and close
.
<move-command>
: Specified as move [by | to] <coordinate-pair>
. This command adds a MoveTo command to the list of shape commands. It draws nothing. Rather, it specifies the starting position for the next command. The by
or to
keyword specifies whether the <coordinate-pair>
point is relative or absolute, respectively. If the <move-command>
follows the close
command, it identifies the starting point of the next shape or subpath.
<line-command>
: Specified as line [by | to] <coordinate-pair>
. This command adds a LineTo command to the list of shape commands. It draws a straight line from the command's starting point to its ending point. The by
or to
keyword specifies whether the ending point specified by <coordinate-pair>
is relative or absolute, respectively.
<hv-line-command>
: Specified as [hline | vline] [by | to] <length-percentage>
. This command adds a horizontal (hline
) or vertical (vline
) LineTo command to the list of shape commands. With hline
, a horizontal line is drawn from the command's starting point to
or by
the x
position defined by <length-percentage>
. With vline
, a vertical line is drawn from the command's starting point to
or by
the y
position defined by <length-percentage>
. The by
or to
keyword determines the relative or absolute ending point, respectively. This command is equivalent to <line-command>
with one coordinate value set by the single <length-percentage>
and the other coordinate value remaining unchanged from its starting command.
<curve-command>
: Specified as curve [by | to] <coordinate-pair> via <coordinate-pair> [<coordinate-pair>]
. This command adds a Bézier curve command to the list of shape commands. The by
or to
keyword determines whether the ending point of the curve, specified by the first <coordinate-pair>
, is relative or absolute, respectively. The via
keyword specifies the control points of the Bézier curve.
- If only a single
<coordinate-pair>
is provided, the command draws a quadratic Bézier curve, which is defined by three points (the start point, control point, and end point). - If two
<coordinate-pair>
values are provided, the command draws a cubic Bézier curve, which is defined by four points (the start point, two control points, and the end point).
<smooth-command>
: Specified as smooth [by | to] <coordinate-pair> [via <coordinate-pair>]
. This command adds a smooth Bézier curve command to the list of shape commands. The by
or to
keyword determines whether the ending point of the curve, specified by the first <coordinate-pair>
, is relative or absolute, respectively.
- If
via <coordinate-pair>
is omitted, the command draws a smooth quadratic Bézier curve, which uses the previous control point and the current endpoint to define the curve. - If the optional
via
keyword is included, it specifies the control points of the curve through <coordinate-pair>
, drawing a smooth cubic Bézier curve defined by the previous control point, the current control point, and the current endpoint.
Smooth curves ensure a continuous transition from the shape, while quadratic curves do not. Smooth quadratic curves maintain a seamless transition using a single control point, whereas smooth cubic curves provide a more refined transition using two control points.
<arc-command>
: Specified as arc [by | to] <coordinate-pair> of <length-percentage> [<length-percentage>] [<arc-sweep> | <arc-size> | rotate <angle>]
. This command adds an elliptical arc curve command to the list of shape commands. It draws an elliptical arc between a starting point and an ending point. The by
or to
keyword determines whether the ending point of the curve, specified by the first <coordinate-pair>
, is relative or absolute, respectively.
The elliptical arc curve command defines two possible ellipses, which intersect both the starting and ending points, and each can be traced clockwise or counterclockwise, resulting in four possible arcs depending on the arc size, direction, and angle. The of
keyword specifies the size of the ellipse from which the arc is taken: the first <length-percentage>
provides the horizontal radius of the ellipse, and the second <length-percentage>
provides the vertical radius.
Specify the following parameters to choose which of the four arcs to use:
-
<arc-sweep>
: Indicates whether the desired arc is the one traced around the ellipse clockwise (cw
) or counterclockwise (ccw
). If omitted, this defaults to ccw
. -
<arc-size>
: Indicates whether the desired arc is the larger (large
) or smaller (small
) of the two arcs. If omitted, this defaults to small
. -
<angle>
: Specifies the angle, in degrees, by which to rotate the ellipse relative to the x-axis. A positive angle rotates the ellipse clockwise, and a negative angle rotates it counterclockwise. If omitted, this defaults to 0deg
.
Special situations are handled as follows:
- If only one
<length-percentage>
is provided, the same value is used for both the horizontal and vertical radii, effectively creating a circle. In this case, <arc-size>
and <angle>
have no affect. - If either radius is zero, the command is equivalent to a
<line-command>
to the ending point. - If either radius is negative, its absolute value is used instead.
- If the horizontal and vertical radii don't describe an ellipse large enough to intersect both the starting point and ending points (after rotation by the specified
<angle>
), the radii are scaled up uniformly until the ellipse is just large enough to intersect both points. - If the starting and ending points of the arc lie on exactly opposite sides of the ellipse, there is only one possible ellipse and two possible arcs. In this case,
<arc-sweep>
specifies the arc to choose, and <arc-size>
has no effect.
close
: Adds a ClosePath command to the list of shape commands, drawing a straight line from the current position (end of the last command) to the first point in the path defined in the from <coordinate-pair>
parameter. To close the shape without drawing a line, include a <move-command>
with the originating coordinates before the close command. If the close
command is immediately followed by a <move-command>
, it defines the starting point of the next shape or subpath.