Prism
GuideCookbookExamplesErrorsPlayground

Guide

01Lessons & Slides02Exercises03Scene & State04Objects05Three dimensions06Controls07Timeline08Loops & Logic09Expressions & Math

Guide · 03 of 09

Scene & State

A Prism file is exactly one scene <type> { ... } block. Everything else — space config, state, objects, controls, timeline — lives inside it.

scene#

type is plane (2D cartesian) or numberline (1D axis). For plane, both x: and y: are required. For numberline, only x: is needed. The space config lines can appear anywhere in the block, in any order, alongside state/object/control declarations. By default the x and y domains are stretched independently to fill the box, so a circle only looks round if the domains happen to match the box. Add aspect: equal when shape matters — unit circles, Argand diagrams, geometry, force diagrams — and one shared scale is used for both axes, letterboxed inside the same space.

scene <type> {
  x: [min,max]
  [y: [min,max]]
  [grid]
  [axes]
  [aspect: equal]
  ...
}
proptypedescription
x*[number, number]x-axis domain
y[number, number]y-axis domain (plane only)
gridflagdraw a background grid (plane only)
axesflagdraw axes. they are on by default — write axes: false to hide them
aspectequalone scale for both axes, so circles stay round (plane only)

Example

-2-1.5-1-0.50.511.52-2-112

param#

Declares a numeric state variable. Controls (sliders, steppers) and draggable objects write to it; object expressions read from it. The { ... } block is optional — omit it if there is nothing to configure.

param <name> = <number> { [range: [min,max]], [step: <number>] }
proptypedescription
range[number, number]min/max bounds for controls
stepnumberdiscrete step size

Example

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

bool#

Declares a boolean state variable. Toggles write to it; show: on objects reads from it.

bool <name> = <true|false>

Example

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

choice#

Declares a string-valued state variable restricted to a fixed set of options. A picker control writes to it; object expressions read it and compare with ==.

choice <name> = " { options: ["a", "b", ...] }
proptypedescription
options*string[]the allowed values, required

Example

-6-4-2246-6-4-2246
← PreviousExercisesNext →Objects

On this page

sceneparamboolchoice