Prism
GuideCookbookExamplesErrorsPlayground

Guide

01Lessons & Slides02Exercises03Scene & State04Objects05Three dimensions06Controls07Timeline08Loops & Logic09Expressions & Math

Guide · 09 of 09

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

-6-4-2246-6-4-2246

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

Example

-6-4-2246-6-4-2246C(5,2) = 10

constants#

Mathematical constants (uppercase).

PI  E

Example

-6-4-2246-6-4-2246

interpolation#

In label text, ${expr} is evaluated at runtime and shown rounded to 2 decimal places.

"text ${expr} more text"

Example

-6-4-2246-6-4-2246f(1) = 1

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

-6-4-2246-6-4-2246p0p1p2p3p4
← PreviousLoops & Logic

On this page

operatorsmath functionsconstantsinterpolationf-strings