rect
A rectangle can be stroked and filled. It can have the following attributes:
Attribute | Description |
---|---|
x
|
The x-axis coordinate of the origin of the rectangle (top-left corner) in the current user coordinate system. If the attribute is not specified, the default is 0. |
y
|
The y-axis coordinate of the origin of the rectangle (top-left corner) in the current user coordinate system. If the attribute is not specified, the default is 0. |
width
|
The width of the rectangle in the current user coordinate system. Must be 0 or greater; if 0, the element will not be rendered. |
height
|
The height of the rectangle in the current user coordinate system. Must be 0 or greater; if 0, the element will not be rendered. |
rx
|
For rounded rectangles, the x-axis radius in the current user coordinate system used to round off the corners of the rectangle. Must be 0 or greater; 0 will produce a square corner. |
ry
|
For rounded rectangles, the y-axis radius in the current user coordinate system used to round off the corners of the rectangle. Must be 0 or greater; 0 will produce a square corner. |
transform
|
See Transformations. This attribute is applied to an element before any other coordinate or length values supplied for that element are processed. |
Note There are additional rules that are implicitly used to specify the value of rx and ry to ensure that rendering is geometrically valid. These rules are (in order of increasing precedence):
-
If neither
rx
norry
are properly specified, then bothrx
andry
are set to 0. -
If a valid value is provided for
rx
but notry
, then setry
torx
. -
If a valid value is provided for
ry
but notrx
, then setrx
tory
. -
If
rx
is greater than half of the width, then setrx
to half of the width. -
If
ry
is greater than half of the height, then setry
to half of the height.
Example:
<rect x="20" y="20" width="60" height="30" style="fill:red;stroke:blue;stroke-width:3" />