p5loom

Elements

There are 5 element types: circle, rect, line, scatter, random-dots. Each one below has a live example.

circle

A filled or outlined circle. x and y are the centre, r is the radius as a fraction of the smaller canvas side.

FieldMeaning
x, yCentre, normalised 0 to 1.
rRadius, normalised 0 to 1 of the smaller side.
fill, stroke, weightToken names and outline width (0 to 64 px).
circle: one accent circle.

rect

A rectangle from its top-left corner, with size as fractions of the canvas.

FieldMeaning
x, yTop-left corner, normalised.
w, hWidth and height, normalised.
fill, stroke, weightAs for circle.
rect: six bars and a baseline line.

line

A polyline through points. Each point is a pair of normalised coordinates. Lines are always stroked; the colour defaults to fg.

FieldMeaning
points2 or more pairs [x, y].
stroke, weightColour token and width in pixels.
line: three grid lines and one accent series.

scatter

Points drawn as small circles. Use it for data. The radius is in pixels, not a fraction, so dots stay readable on any canvas size.

FieldMeaning
data1 or more pairs [x, y], normalised.
rDot radius in pixels, 0 to 100. Default 3.
fillToken. Default accent.
scatter with a trend line in muted ink.

random-dots

A number of dots placed by the spec's seed. Positions and radii come from the seeded generator, so they are the same every time the seed is the same. Changing the seed moves the dots and nothing else.

FieldMeaning
countInteger 1 to 100,000.
radius[min, max] in pixels, each 0 to 100. Default [1, 3].
fillToken. Default accent.
random-dots: 900 dots from seed 2024.

Drawing order

The background is painted first, then each element in array order. A later element covers an earlier one. There is no z-index: reorder the array instead.