Shape
Collection Functions
compose shape1 shape2
Combines two shapes shape1
and shape2
into a single shape. shape2
is always rendered over shape1
.
Equivalent to the (:)
binary operator.
Example:
circle_over_square = compose SQUARE CIRCLE
circle_over_square = (:) SQUARE CIRCLE
circle_over_square = SQUARE : CIRCLE
collect shapes
Combines a list of shapes shapes
into a single shape. Shapes are rendered in order of list.
Example:
circle_over_square = collect [SQUARE, CIRCLE]
Translation Functions
t x y shape
Returns shape
translated by x
and y
on the x and y axes. x
and y
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the translate
function.
Example:
top_right = t 50 50 SQUARE
top_right = translate 50 50 SQUARE
tx x shape
Returns shape
translated by x
on the x axis. x
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the translatex
function.
Example:
right = tx 50 SQUARE
right = translatex 50 SQUARE
ty y shape
Returns shape
translated by y
on the y axis. y
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the translatey
function.
Example:
top = ty 50 SQUARE
top = translatey 50 SQUARE
tt n shape
Returns shape
translated by n
on both the x and y axes. n
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the translateb
function.
Example:
top_right = tt 50 SQUARE
top_right = translateb 50 SQUARE
Rotation Functions
r deg shape
Returns shape
rotated by deg
degrees. deg
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the rotate
function.
Example:
diamond = r 45 SQUARE
diamond = rotate 45 SQUARE
ra deg x y shape
Returns shape
rotated by deg
degrees at position x
and y
. deg
, x
, and y
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the rotate_at
function.
Example:
diamond = ra 45 50 50 SQUARE
diamond = rotate_at 45 50 50 SQUARE
Scale Functions
s x y shape
Returns shape
scaled by x
and y
on the x and y axes. x
and y
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the scale
function.
Example:
rectangle = s 100 50 SQUARE
rectangle = scale 100 50 SQUARE
sx x shape
Returns shape
scaled by x
on the x axis. x
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the scalex
function.
Example:
wide_line = sx 50 SQUARE
wide_line = scalex 50 SQUARE
sy y shape
Returns shape
scaled by y
on the y axis. y
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the scaley
function.
Example:
tall_line = sy 50 SQUARE
tall_line = scaley 50 SQUARE
ss n shape
Returns shape
scaled by n
on both the x and y axes. n
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the scaleb
function.
Example:
big_square = ss 50 SQUARE
big_square = scaleb 50 SQUARE
Skew Functions
k x y shape
Returns shape
skewed by x
and y
on the x and y axes. x
and y
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the skew
function.
Example:
skewed = k 0.5 0.25 SQUARE
skewed = skew 0.5 0.25 SQUARE
kx x shape
Returns shape
skewed by x
on the x axis. x
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the skewx
function.
Example:
skewed = kx 0.5 SQUARE
skewed = skewx 0.5 SQUARE
ky y shape
Returns shape
skewed by y
on the y axis. y
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the skewy
function.
Example:
skewed = ky 0.5 SQUARE
skewed = skewy 0.5 SQUARE
kk n shape
Returns shape
skewed by n
on the x and y axes. n
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the skewb
function.
Example:
skewed = kk 0.5 SQUARE
skewed = skewb 0.5 SQUARE
Flip Functions
f deg shape
Returns shape
flipped along the deg
angle. deg
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the flip
function.
Example:
arrow_left = f 45 TRIANGLE
arrow_left = flip 45 TRIANGLE
fh shape
Returns shape
flipped along the x axis. shape
must be of the shape type.
Shorthand for the fliph
function.
Example:
arrow_down = fh TRIANGLE
arrow_down = fliph TRIANGLE
fv shape
Returns shape
flipped along the y axis. shape
must be of the shape type.
Shorthand for the flipv
function.
Example:
arrow_up = fv TRIANGLE
arrow_up = flipv TRIANGLE
fd shape
Returns shape
flipped along both the x and y axes. shape
must be of the shape type.
Shorthand for the flipd
function.
Example:
arrow_up = fd TRIANGLE
arrow_up = flipd TRIANGLE
Z-Index Functions
z n shape
Returns shape
with its z-index set to z
. Shapes with a higher z-index are rendered on top of shapes with a lower z-index. z
must be of the integer or float types and shape
must be of the shape type.
Shorthand for the zindex
function.
Example:
square_over_circle = z 1 SQUARE : CIRCLE
square_over_circle = zindex 1 SQUARE : CIRCLE
zshift n shape
Returns shape
with its z-index shifted by n
. n
must be of the integer or float types and shape
must be of the shape type.
Example:
square_over_circle = zshift -2 (z 3 SQUARE) : CIRCLE
Rendering Functions
blend bm shape
Returns shape
with its blend mode set to bm
.
Refer to Blend Mode for a full list of possible blend modes.
Example:
transparent_square = blend BLEND_CLEAR SQUARE
anti_alias toggle shape
Returns shape
with anti-aliasing set to toggle
. toggle
must be of the boolean type and shape
must be of the shape type.
Example:
rugged_circle = anti_alias false CIRCLE
fill shape
Returns shape
with its style set to fill.
Example:
filled_square = fill (stroke 0 SQUARE)
winding shape
Returns shape
with its fill rule set to winding.
Specifies that “inside” is computed by a non-zero sum of signed edge crossings.
Example:
winding_square = winding SQUARE
even_odd shape
Returns shape
with its fill rule set to even-odd.
Specifies that “inside” is computed by an odd number of edge crossings.
Example:
even_odd_square = even_odd SQUARE
stroke w shape
Returns shape
with its style set to stroke with a stroke width of w
. w
must be of the integer or float types.
When stroke width is set to 0, a hairline stroking will be used.
Example:
square_outline = stroke 0.1 SQUARE
miter_limit n shape
Returns shape
with its style set to stroke and its miter limit set to n
. n
must be of the integer or float types.
Miter limit is the limit at which a sharp corner is drawn beveled.
Example:
beveled_square = miter_limit 1 (stroke 0.1 SQUARE)
line_cap lc shape
Returns shape
with its style set to stroke and its line cap set to lc
.
Refer to Line Cap for a full list of possible line caps.
Example:
rounded_line = line_cap LINE_CAP_ROUND (stroke 50 (move_to -100 0 : line_to 100 0))
line_join lj shape
Returns shape
with its style set to stroke and its line join set to lj
.
Refer to Line Join for a full list of possible line joins.
Example:
rounded_square = line_join LINE_JOIN_ROUND (stroke 0.1 SQUARE)
dash array offset shape
Returns shape
with its style set to stroke and its dash properties set to array
and offset
. array
must be a list of either integers or floats and offset
must be of the integer or float types.
The array must be of pairs, where the first number indicates an “on” interval and the second one indicates an “off” interval. The offset affects where the dash pattern starts.
Example:
dashed_square = dash [0.2, 0.4] 0 (stroke 0.1 SQUARE)
no_dash shape
Returns shape
with its style set to stroke and its dash removed.
Example:
square_outline = no_dash (dash [0.2, 0.4] 0 (stroke 0.1 SQUARE))
mask mask_shape shape
Returns shape
with its mask set to mask_shape
. During rendering, mask’s black pixels will block rendering and white will allow it. Anything in between is semitransparent.
Example:
semicircle = mask (s 1 0.5 SQUARE) (ty 0.5 CIRCLE)
Path Functions
move_to x y
Returns a new path shape starting at (x
, y
). Accepts integer and float types.
Example:
empty_path = move_to 50 50
line_to x y
Continues an existing path by drawing a line from the last point to (x
, y
). Accepts integer and float types.
Example:
open_triangle = move_to 50 50 : line_to 50 100 : line_to 100 100
quad_to x1 y1 x y
Continues an existing path by drawing a quad curve from the last point to (x
, y
). Accepts integer and float types.
Example:
quad_curve = move_to -100 0 : quad_to 95 120 125 30
cubic_to x1 y1 x2 y2 x y
Continues an existing path by drawing a cubic curve from the last point to (x
, y
). Accepts integer and float types.
Example:
cubic_curve = move_to -100 0 : cubic_to -35 -80 95 20 125 -70
close
Closes an existing path, preventing further modifications.
Example:
closed_triangle = move_to 50 50 : line_to 50 100 : line_to 100 100 : close
voronoi sites boxsize
Returns a list of polygons representing a voronoi diagram, based on sites
and boxsize
. sites
must be a 2D list of integer or float types, with each element the point of a site on the diagram. boxsize
must be of the integer or float types and determines the dimensions of the diagram.
Example:
root = collect colorized
colorized =
for polygon in diagram
hsl (rand * 360) 100% 50% polygon
diagram = voronoi [[80, 80], [160, 240], [240, 160], [320, 320]] 400

Last updated