rectangle

Built-ins

Canonical ID: graphics.rectangle. Nederlands: rechthoek.

Draws a filled rectangle with its top-left corner at x,y in the 640 by 360 logical scene. It does not create a retained object that can later be addressed by name. All dimensions must be finite; the runtime currently permits nonpositive width or height, but portable programs should use positive dimensions. Clear and redraw to animate it.

Signature

rectangle(x, y, width, height, color)

Arguments

Parameter Type Requirement
x Number Finite horizontal coordinate in logical pixels.
y Number Finite vertical coordinate in logical pixels.
width Number Finite; use a positive value for portable drawing.
height Number Finite; use a positive value for portable drawing.
color Text Nonempty; use portable English/Dutch names or #RGB/#RRGGBB.

Return value

None.

Example

# language: en
clearCanvas("white")
rectangle(80, 90, 240, 120, "rood")

A red filled rectangle.

Notes and common mistakes

Use the function name for your source language. Its canonical ID is a shared documentation label; you do not type that ID as a call. Giving your own variable or function the same name can hide the built-in. Supply the documented arguments and value types. Pliro reports mismatches when checking can detect them, or when the call runs.

A host is the app or environment running your program. To see a drawing, it needs a renderer, the part that draws on screen. The command-line command pliro run shows text but does not draw these graphics. The host support table explains which effects work in the IDE, browser, native app, and phone preview. A native build reports an unsupported capability instead of leaving it out.

2D uses a 640 × 360 scene with a top-left origin, +X right and +Y down. Both English and Dutch portable color names work in either syntax locale, as do #RGB and #RRGGBB. Other nonempty 2D color text is host-dependent.

clearCanvas · circle · drawLine · drawText · Programming guides · Host support · Calls and arguments