Qu

rect

Builtin index · Plotting

rectangle(x0, y0, x1, y1)

Input: x0, y0, x1, y1 · Output: no output

What it is

Draws an axis-aligned rectangle. x0 and y0 (numbers, data units) are one corner; x1 and y1 (numbers, data units) are the corner diagonally opposite it, and which of the two you give first does not matter. rect is a plain alias.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
rectangle(x0, y0, x1, y1)
x0 numberx0 and y0 (numbers, data units) are one corner.
y0 numberx0 and y0 (numbers, data units) are one corner.
x1 numberx1 and y1 (numbers, data units) are the corner diagonally opposite it, and which of the two you give first does not matter.
y1 numberx1 and y1 (numbers, data units) are the corner diagonally opposite it, and which of the two you give first does not matter.
no outputDraws an axis-aligned rectangle. rect is a plain alias.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

# A square canvas, so that equal ranges really are equal scales and the

# circle below comes out round. Without it the figure would render an

# ellipse while the paragraph above it explained how to avoid one.

figure_size(560, 560)
xlim(-2, 2)
ylim(-2, 2)
axis equal
circle(0, 0, 1, color = "royalblue", fill = "royalblue")
ellipse(0, 0, 1.6, 0.7, color = "crimson", rotate = 30)
arc(0, 0, 1.3, 0, 120, color = "seagreen", width = 2)
polygon([0.8, 1.6, 1.2], [-1.6, -1.6, -0.9], color = "purple", fill = "plum")
rectangle(-1.8, -1.8, -1.2, -1.2, color = "orange")
rect(1.0, -1.8, 1.8, -1.2, color = "teal")
point(0, 1.9)
-2.0 -1.5 -1.0 -0.5 0 0.5 1.0 1.5 2.0 -2.0 -1.5 -1.0 -0.5 0 0.5 1.0 1.5 2.0 (0, 1.9)

from plotting

See also

rectangle — documented in the same entry.