Guide · 14 of 15
Expressions & Math
Expressions appear in object properties (like the expr in curve f = <expr>), control bounds, and ${...} label interpolations. They're evaluated at runtime against the current state.
operators#
^ is exponentiation (e.g. x^2). All standard arithmetic. Standard precedence.
+ - * / ^ %
Example
math functions#
All standard math functions, called without a namespace prefix. Trig works in radians — deg/rad convert. mod is a true modulo (unlike the % operator, mod(-1, 3) is 2). fact, nCr and nPr are the counting functions; they return nothing usable for negative, non-integer, or out-of-range input.
sin cos tan asin acos atan atan2 sinh cosh tanh sec csc cot sqrt cbrt abs log log2 log10 exp pow hypot floor ceil round sign min max clamp lerp mod deg rad fact nCr nPr fixed sig sci
Example
interpolation#
In label text, ${expr} is evaluated at runtime and shown rounded to 2 decimal places (small numbers keep two significant figures, so a gap of 0.001 still reads 0.001). Wrap it in fixed(expr, digits) to show an exact number of decimals, which is what a readout that should visibly settle wants: 3.000, 2.100, 2.010, 2.001. For very large or very small values use sci(expr, digits), which writes scientific notation with that many significant figures (2.5 × 10²⁰, 1.6 × 10⁻¹⁹), or sig(expr, digits), which keeps a plain number while it is readable and switches to that form when it is not. Both also work inside $...$.
"text ${expr} more text"Example
f-strings#
Compile-time string interpolation. Used to generate unique object IDs and string values inside for loops. Uses {expr}, not ${expr}.
f"text {expr}"
Example