# Path element
.add('path') an SVG path is created. This element represents the outline of a shape. All the
basic shapes can be created with a path element, but it is normally just used for more complex
As in other cases, the method
.fill() sets the interior color,
.stroke() sets its
border color and
.stroke_width() its border width.
The path information is described width
.d and a group of special methods or directly with
.d(path_data). In order to use the latter it's necessary to pass a string with the path
data as a parameter, such as
The easiest way is to use
.d methods like
.d.L() and build the path data step by
step with these helpers. All these methods return
.d and as a result, you can chain calls to
Uppercase letter methods express coordinates in absolute terms, while lowercase methods express them in relative terms from the most recently declared coordinates.
Here is a short list of available methods in
| ||horizontal lineto|
| ||vertical lineto|
| ||smooth curveto|
| ||quadratic Bézier curveto|
| ||smooth quadratic Bézier curveto|
The moveto methods (
.M(x, y) or
.m(x, y)) establish a new point, as if lifting the pen and
starting to draw a new subpath in a new location. The second
x,y pair and subsequent ones are
treated as path points, and a straight line is drawn between these points.
The closepath methods (
.z(), both are identical) end the current subpath and draw a
line from that point to the initial point of this subpath.
The lineto methods (
.v(y)) draw straight lines
from the current point to a new point.
# Curve methods
There are three groups of
.d methods that draw curved paths: Cubic Bézier (
.s()), Quadratic Bézier (
.t()), and Elliptical arc (
# Cubic Bézier
.C(x1, y1, x2, y2, x, y) and
.c(x1, y1, x2, y2, x, y) methods draw a cubic Bézier curve
from the current point to the end point specified by
y. The start control point is specified
y1 and the end control point is specified by
S(x2, y2, x, y) and
s(x2, y2, x, y) methods also draw a Cubic Bézier curve, but in this
case the start control point is a reflection of the previous curve method.
# Quadratic Bézier
Quadratic Bézier curves defined by
Q(x1, y1, x, y),
q(x1, y1, x, y),
methods are similar to Cubic Bézier curves except that they only have one control point.
T(x, y) and
t(x, y) methods also draw a Quadratic Bézier curve, but in this
case the control point is a reflection of the previous curve method.
# Elliptical Arc
An Elliptical Arc methods
A(rx, ry, angle, large-arc-flag, sweep-flag, x, y) and
A(rx, ry, angle, large-arc-flag, sweep-flag, x, y) defines a segment of an ellipse with this
ryare the two radii of the ellipse.
angleis the rotation (in degrees) of the ellipse relative to the x-axis.
large-arc-flagallows to chose one of the large arc (
1) or small arc (
sweep-flagallows to chose one of the clockwise turning arc (
1) or anticlockwise turning arc (
ybecomes the new current point for the next method.