Mathematically, these shape elements are equivalent to a
‘path’ element that would construct the same shape. The basic
shapes may be stroked, filled and used as clip paths. All of the
properties available for ‘path’ elements also apply to the basic
shapes.

The equivalent path and algorithm to compute the stroke for each shape
are defined in the shape sections below.

10.2. The ‘rect’ element

The ‘rect’ element defines a rectangle which is axis-aligned
with the current local coordinate system. Rounded rectangles can be achieved by setting
non-zero values for the rx and ry geometric properties.

The x and y coordinates refer to the left and top edges of the rectangle,
in the current user coordinate system.

The width and height properties define the overall width and height of the rectangle.
A negative value for either property is illegal and must be ignored as a parsing error.
A computed value of zero for either dimension disables rendering of the element.

For rounded rectangles,
the computed values of the rx and ry properties define
the x- and y-axis radii of elliptical arcs used to round off the corners of the rectangle.
The arc are always symmetrical along both horizontal and vertical axis; to create a rectangle with uneven corner rounding, define the shape explicitly with a ‘path’.
A negative value for either property is illegal and must be ignored as a parsing error.
A computed value of zero for either dimension,
or a computed value of auto for both dimensions,
results in a rectangle without corner rounding.

The used values for the x- and y-axis rounded corner radii
may be determined implicitly from the other dimension (using the auto value),
and are also subject to clamping so that the lengths of
the straight segments of the rectangle are never negative.
The used values for rx and ry are determined
from the computed values by following these steps in order:

If both rx and ry have a computed value of auto
(since auto is the initial value for both properties, this will also occur if neither are specified by the author or if all author-supplied values are invalid),
then the used value of both rx and ry is 0. (This will result in square corners.)

Otherwise, convert specified values to absolute values as follows:

If rx is set to a length value or a percentage,
but ry is auto,
calculate an absolute length equivalent for rx, resolving percentages against the used width of the rectangle;
the absolute value for ry is the same.

If ry is set to a length value or a percentage,
but rx is auto,
calculate the absolute length equivalent for ry, resolving percentages against the used height of the rectangle;
the absolute value for rx is the same.

If both rx and ry were set to lengths or percentages,
absolute values are generated individually,
resolving rx percentages against the used width,
and resolving ry percentages against the used height.

Finally, apply clamping to generate the used values:

If the absolute rx (after the above steps)
is greater than half of the used width,
then the used value of rx is half of the used width.

If the absolute ry (after the above steps)
is greater than half of the used height,
then the used value of ry is half of the used height.

Otherwise, the used values of rx and ry are the absolute values computed previously.

Mathematically, a ‘rect’ element is mapped to an
equivalent ‘path’ element as follows,
after generating absolute used values
x, y, width, height,
rx, and rx
in user units for the local coordinate system,
for each of the equivalent geometric properties
following the rules specified above and in Units:

if both rx and ry are greater than zero,
perform an absolute elliptical arc
operation to coordinate (x+width,y+ry),
where rx and ry are used as the equivalent parameters to
the elliptical arc command,
the x-axis-rotation and large-arc-flag are set to zero,
the sweep-flag is set to one;

Example rect02 shows
two rounded rectangles. The rx specifies how to round the corners of
the rectangles. Note that since no value has been specified for the ry
attribute, the used value will be derived from the rx attribute.

Mathematically, a ‘circle’ element is mapped to an
equivalent ‘path’ element that consists of four
elliptical
arc segments, each covering a quarter of the circle. The path
begins at the "3 o'clock" point on the radius and proceeds in a
clock-wise direction (before any transformations).
The rx and ry parameters to the arc commands
are both equal to the used value of the r property, after conversion to local user units,
while the x-axis-rotation,
the large-arc-flag,
and the sweep-flag are all set to zero.
The coordinates are computed as follows,
where cx, cy, and r are the used values of the equivalent properties, converted to user units:

The rx and ry properties define the x- and y-axis radii of the
ellipse.
A negative value for either property is illegal and must be ignored as a parsing error.
A computed value of zero for either dimension,
or a computed value of auto for both dimensions,
disables rendering of the element.

An auto value for eitherrx or ry
is converted to a used value, following the rules given above for rectangles
(but without any clamping based on width or height).
Effectively, an auto value creates a circular shape
whose radius is defined by a value expressed solely in one dimension;
this allows for creating a circle with a radius defined in terms of one of the following:

a percentage of the coordinate system width; that is, a percentage value for rx and an auto value for ry.

a percentage of the coordinate system height; that is, an auto value for rx and a percentage value for ry.

New in SVG 2.
The auto value for rx and ry was added to allow consistent
parsing of these properties for both ellipses and rectangles.
Previously, if either rx or ry was unspecified,
the ellipse would not render.

Mathematically, an ‘ellipse’ element is mapped to an
equivalent ‘path’ element that consists of four
elliptical
arc segments, each covering a quarter of the ellipse. The path
begins at the "3 o'clock" point on the radius and proceeds in a
clock-wise direction (before any transformation).
The rx and ry parameters to the arc commands
are the used values of the equivalent properties after conversion to local user units,
while the x-axis-rotation,
the large-arc-flag,
and the sweep-flag are all set to zero.
The coordinates are computed as follows,
where cx, cy, rx, and ry
are the used values of the equivalent properties, converted to user units:

Example ellipse01 below specifies
the coordinates of the two ellipses in the user coordinate system
established by the ‘viewBox’ attribute on the ‘svg’
element and the transform property on the ‘g’ and
‘ellipse’ elements. Both ellipses use the default values of
zero for the cx and cy attributes (the center of the
ellipse). The second ellipse is rotated.

A future specification may convert the ‘x1’, ‘y1’, ‘x2’, and ‘y2’ attributes to geometric properties.
Currently, they can only be specified via element attributes, and not CSS.

Mathematically, a ‘line’ element can be mapped to an
equivalent ‘path’ element as follows,
after converting coordinates into local coordinate system user units according
to Units
to generate values x1, y1, x2, and y2:

The points that make up the polyline. All coordinate
values are in the user coordinate system.

If an odd number of coordinates is provided, then the element is in
error, with the same user agent behavior as occurs with an incorrectly
specified ‘path’ element. In such error cases the user agent will drop
the last, odd coordinate and otherwise render the shape.

The initial value, (none), indicates that the polyline element
is valid but does not render.

A future specification may convert the ‘points’ attribute to a geometric property.
Currently, it can only be specified via an element attribute, and not CSS.

Mathematically, a ‘polyline’ element can be mapped to an
equivalent ‘path’ element as follows:

perform an absolute moveto
operation to the first coordinate pair in the list of points

for each subsequent coordinate pair, perform an absolute
lineto operation to that
coordinate pair.

Example polyline01
below specifies a polyline in the user coordinate system established by the
‘viewBox’ attribute on the ‘svg’ element.

If the ‘href’ points to a valid ‘meshgradient’ paint
server, use that to render the ‘mesh’ element; else if the
first ‘meshgradient’ child element is valid use that.
Otherwise, the ‘mesh’ will not render. A non-rendered
‘mesh’ behaves the same as a ‘path’ that has
a d property with value
none. Note: The
fill property is not used to define the paint of a
‘mesh’, however a ‘mesh’ may have a stroke and
markers positioned using the equivalent path.

A 2x2 patch mesh gradient. The equivalent path is shown by the
heavy black path. The path starting point is indicated by the red
circle and the path direction by the arrow.

Meshes can fold over such that there may be painted regions that
are outside the equivalent path. Painting of these regions is
controlled by the overflow property. The initial value
for this property is
visible.

Single patch mesh gradient with different values of the
overflow property. Left: overflow with value
display. Right overflow
with value hidden.

A ‘mesh’ is always painted as if the fill rule
is nonzero regardless of the
value of the fill-rule property.

The points and
animatedPoints IDL
attributes represent the current non-animated value of the reflected attribute.
On getting points or
animatedPoints,
an SVGPointList object is returned that reflects the base
value of the reflected attribute.

This specification imposes additional requirements on the behaviour of DOMPoint
objects beyond those described in the
the Geometry Interfaces
specification, so that they can be used to reflect ‘points’ attributes.

A DOMPoint object can be associated
with a particular element. The associated element is used to
determine which element's content attribute to update if the object reflects
an attribute. Unless otherwise described, a DOMPoint object is not
associated with any element.

A DOMPoint object can be designated as read only,
which means that attempts to modify the object will result in an exception
being thrown. When assigning to a read only DOMPoint's
x,
y,
w or
z
IDL attribute, a NoModificationAllowedError must be
thrown instead of updating the internal coordinate value.

Note that this applies only to the read-write DOMPoint
interface; the DOMPointReadOnly interface, which is not used for reflecting
the ‘points’ attribute, will already throw an exception if
an attempt is made to modify it.

When assigning to a writable DOMPoint's
x,
y,
w or
z
IDL attribute, the following steps are run after updating
the internal coordinate value: