Constants
pi circle const. π (~3.14)
tau circle const. τ (2π) (~6.28)
phi golden ratio φ (~1.61803)
e Euler's number e (~2.71828)
deg degrees
Numbers
-m
- negation
+m
- identity
m + n
- addition
m - m
- subtraction
m * n
- multiplication
m / n
- division
m ^ n
- exponentiation
abs n
- absolute value of n
sign n
- sign of n
floor n
-
ceil n
-
trunc n
-
round n
-
frac n
-
max [list]
-
min [list]
-
sum [list]
-
product [list]
-
sort [list]
-
mod [a,m]
-
rem [a,m]
-
sqrt n
-
log n
-
clamp [n,lo,hi]
-
lerp [lo,hi,t]
- :
linear interpolation
smoothstep [lo,hi,x]
- :
smoothstep interpolation
Trigonometry
sin a
cos a
tan a
cis a
asin a
acos a
atan a
atan2 [y,x]
phase [x,y]
sec a
csc a
cot a
sinh a
cosh a
tanh a
asinh a
acosh a
atanh a
Complex Numbers
[re, im]
z.[RE], z.[IM]
mag z
phase z
r * cis theta
cmul[z, w]
csqr z
Vectors & Matrices
mag [v]
normalize [v]
dot [v1,v2]
phase [x,y]
cis theta
perp [x,y]
cross [v1,v2]
idmatrix n
transpose [a]
2D Shapes
circle d
ellipse [dx,dy]
triangle d
triangle [dx,dy]
triangle [p1,p2,p3]
square d
rect [dx,dy]
rect [[xmin,ymin],[xmax,ymax]]
rect {xmin,ymin,xmax,ymax}
pentagon d
hexagon d
octagon d
regular_polygon n d
polygon [vertices]
stroke {d:diameter, from:p1, to:p2}
polyline {d:diameter, v:vertices}
half_plane {d, normal:n}
half_plane {at:p, normal:n}
half_plane [p1,p2]
nothing
everything
make_shape {dist,colour,bbox,is_2d}
3D Shapes
sphere d
spheroid [dxy,dz]
ellipsoid [dx,dy,dz]
cylinder {d,h}
cone {d,h}
capped_cone {h,top,bottom}
torus {major:d1, minor:d2}
box [dx,dy,dz]
box [[xmin,ymin,zmin],[xmax,ymax,zmax]]
box {xmin,ymin,zmin,xmax,ymax,zmax}
prism n {d,h}
S d Platonic solid S can be
tetrahedron, cube, octahedron,
dodecahedron, or icosahedron
capsule {d:diameter, from:p1, to:p2}
half_space {d, normal:n}
half_space {at:p, normal:n}
half_space [p1,p2,p3]
gyroid
nothing
everything
make_shape {dist,colour,bbox,is_3d}
Lists
[1,2,3] list of 3 numbers
"abc" list of 3 characters
i .. j
i .. j by k
i ..< j
i ..< j by k
a.[i]
a.[indices]
count [a]
[a] ++ [b]
concat [aa]
reverse [a]
map f [a]
filter p [a]
reduce [zero, f] [a]
contains [list, x]
Records
{a:1,b:2} dynamic record
{a=1, b=2} scoped record
...r spread operator
record .identifier
record .[ symbolExpr ]
recordVariable .identifier := newVal
recordVariable .[symbolExpr] := newVal
defined(record .identifier)
defined(record .[symbolExpr])
fields record
merge [listOfRecords]
move [dx,dy] shape
rotate angle shape
reflect [vnx,vny] shape
scale k shape
at p (t) shape
about [vx,vy] (t) shape
about angle (t) shape
align.min [dx,dy] shape
align.max [dx,dy] shape
align.centre [dx,dy] shape
stretch [kx,ky] shape
stretch k shape
shear kx shape
local_taper {scale:[kx0,kx1],
range:[y0,y1],} shape
bend {d, angle} shape
swirl {d, strength} shape
2D Repetition
repeat [dx,dy] shape
repeat {d:[dx,dy], reps:[nx,ny]} shape
mirror [vnx,vny] shape
repeat_radial n shape
2D -> 3D
extrude d shape
revolve shape
perimeter_extrude perimeter cross_section
move [dx,dy,dz] shape
rotate {angle, axis} shape
reflect [vnx,vny,vnx] shape
scale k shape
at p (t) shape
about [vx,vy,vz] (t) shape
align.min [dx,dy,dz] shape
align.max [dx,dy,dz] shape
align.centre [dx,dy,dz] shape
stretch [kx,ky,kz] shape
stretch k shape
shear [kx,ky] shape
local_taper {scale:[[kx0,ky0],
[kx1,ky1]], range:[z0,z1] shape
twist tr shape
bend {d, angle} shape
3D Repetition
repeat [dx,dy,dz] shape
repeat {d:[dx,dy,dz],
reps:[nx,ny,nz]} shape
mirror [vnx,vny,vnz] shape
repeat_radial n shape
3D -> 2D
slice [vnx,vny,vnz] shape
Distance Field Operations
offset d shape
shell d shape
pancake d shape
morph k [shape1, shape2]
loft d [shape1, shape2]
Boolean Operations
complement shape
union [shape1, shape2, ...]
intersection [shape1, shape2, ...]
difference [shape1, shape2]
symmetric_difference [shape1, shape2, ...]
row shapes
row d shapes
smooth r .union [shape1, shape2]
smooth r .intersection [shape1, shape2]
smooth r .difference [shape1, shape2]
chamfer r .union [shape1, shape2]
chamfer r .intersection [shape1, shape2]
chamfer r .difference [shape1, shape2]
Intensity Fields
show_ifield ifield
i_linear d
i_radial n
i_concentric d
i_gyroid
i_animate t ifield
Textures
make_texture colour
make_texture cfield
texture [ifield, cmap]
texture cfield shape
texture [ifield, cmap] shape
Colour
sRGB [r,g,b]
sRGB.HSV [h,s,v]
sRGB.hue h
sRGB.grey i
webRGB [r,g,b]
OKLab [L,a,b]
OKLCH [L,C,H]
show_colour c
colour c shape
sRGB.hue a "rainbow" colour map
sRGB.grey a greyscale colour map
gradient_cmap [col1, col2, i]
show_cmap f
Debug
show_axes shape
show_bbox shape
set_bbox bbox shape
show_dist shape
show_gradient [j,k] shape
lipschitz k shape
Other
include record
file "filename"
Parametric Shapes
parametric <par1>; <par2>; … in <shape>
<identifier> :: <picker> = <initial-val>;
Pickers:
checkbox
colour_picker
slider[low,high]
int_slider[low,high]
scale_picker
Patterns
pattern :: predicate
[pattern1 , …] list pattern
{field_pattern1 , …} record pattern
Symbols & Strings
#'symbol name!'
#true
#false
#null
symbol str
#"x" character literal
char c
ucode c
repr x
string x
_ char escape suffix
$name variable substitution
nl newline
tab
quot double quote
dol dollar sign