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
rxnorryare properly specified, then bothrxandryare set to 0. -
If a valid value is provided for
rxbut notry, then setrytorx. -
If a valid value is provided for
rybut notrx, then setrxtory. -
If
rxis greater than half of the width, then setrxto half of the width. -
If
ryis greater than half of the height, then setryto half of the height.
Example:
<rect x="20" y="20" width="60" height="30" style="fill:red;stroke:blue;stroke-width:3" />