2D coordinates and drawing

Programming guides

2D means two dimensions: width and height, like a drawing on paper. A coordinate tells you a position. In (100, 50), x is 100 steps to the right and y is 50 steps down from the origin, the starting point (0, 0) at the top-left.

Pliro’s drawing area is 640 by 360 logical pixels: the units used by your program. They do not have to match the physical dots of your screen one for one. The host, the app showing the drawing, can make the whole picture larger or smaller. It preserves the aspect ratio, the proportion of width to height, so circles stay round. See pixels and screen sizes.

A circle’s radius is the distance from its center to its edge. Its diameter, all the way across through the center, is twice the radius. A line’s width is its thickness, not its length.

Scene functions are runtime capabilities, not special grammar. The interpreter
emits renderer-independent commands. The IDE, browser, or native host performs
the actual drawing.

# language: en
clearCanvas("#0f172a")

rectangle(80, 90, 480, 180, "#1e293b")
circle(320, 180, 70, "#22d3ee")
drawLine(120, 280, 520, 280, 6, "#facc15")
drawText(320, 28, "PLIRO", 36, "#ffffff", "pixel", "center")
drawText(320, 318, "640 × 360 logical pixels", 18, "#cbd5e1", "sans", "center")

clearCanvas begins a fresh immediate scene frame and discards retained
sprites. A retained image background may remain available separately on hosts
that implement showImage.

Drawing and remembering pictures

A renderer is the part of the host that turns drawing instructions into a visible picture. Immediate drawing adds shapes to the current picture. A retained sprite is a named picture the host remembers so you can change it later. clearCanvas clears the drawn frame and those sprites. An image background is handled separately on hosts that support it; see images and sound.

Syntax and values · Built-ins · Programming guides