Skip to main content

rect

rect() 

Draws a rectangle between two coordinates.

rect((0,0), (1,1))
rect((-.5, -.5), (rel: (2, 2)),
radius: (north-east: (100%, .5),
south-west: (100%, .5), rest: .2),
stroke: red)
rect((-1, -1), (rel: (3, 3)), radius: .5, stroke: blue)

Coordinate of the bottom left corner of the rectangle.

Coordinate of the top right corner of the rectangle. You can draw a rectangle with a specified width and height by using relative coordinates for this parameter (rel: (width, height)).

Styling

Root: rect

radius:

Default: 0

The rectangles corner radius. If set to a single number, that radius is applied to all four corners of the rectangle. If passed a dictionary you can set the radii per corner. The following keys support either a number, ratio or an array of number, ratio for specifying a different x- and y-radius: north, east, south, west, north-west, north-east, south-west and south-east. To set a default value for remaining corners, the rest key can be used.

Ratio values are relative to the rects width/height.

rect((0,0), (rel: (1,1)), radius: 0)
rect((2,0), (rel: (1,1)), radius: 25%)
rect((4,0), (rel: (1,1)), radius: (north: 50%))
rect((6,0), (rel: (1,1)), radius: (north-east: 50%))
rect((8,0), (rel: (1,1)), radius: (south-west: 0, rest: 50%))
rect((10,0), (rel: (1,1)), radius: (rest: (20%, 50%)))

Anchors

Supports border and path anchors.