Guide · 04 of 09
Objects
Objects are the visual elements of a scene. Properties go in a trailing { key: value } block — omit it entirely if the object needs no configuration. All objects accept: color, style (solid/dashed/dotted), show:<expr>, width:<number>. Note: curve, line, rect, circle, polygon, vector, arc, image require plane scenes; only point and label work on numberline scenes.
curve#
Plots f(x) across the domain. Give it a (x, y) pair instead to trace a parametric curve over the parameter t — supply t: [start, end]. State variables can appear in either form. A vertical asymptote (tan(x), 1/x, ...) breaks the stroke automatically — no special syntax needed, just let the domain span the pole.
curve <id> = <expr> { [props] } OR curve <id> = (x(t), y(t)) { t: [start, end], [steps: <n>] }
| prop | type | description |
|---|---|---|
| t | [start, end] | parameter range (parametric form only) |
| steps | number | sample count for parametric curves |
| where | expr | boolean in x — draw the curve only where it holds (piecewise) |
Example
area#
Shades the region under a curve. Fills between y = <upper expr> and y = 0 (or lower: for a second curve), clipped to x in [from, to] (defaults to the scene domain). from/to can bind to state, so a slider can sweep the shaded width.
area <id> = <upper expr> { [from: <n>], [to: <n>], [lower: <expr>], [opacity: <n>] }
| prop | type | description |
|---|---|---|
| from | expr | left x bound (default xMin) |
| to | expr | right x bound (default xMax) |
| lower | expr | lower boundary curve (default y = 0) |
| opacity | number | fill opacity (default 0.15) |
Example
point#
A point at scene coordinates (x, y). Both coords can be expressions. drag makes it draggable — axis is x, y, or xy; bind is the state key updated by the drag. snap rounds the dragged value to the nearest step (grid = nearest 1). drag: along(<objId>) -> <bind> constrains the drag to a circle or two-point line object — bind receives an angle (radians) for a circle, or 0..1 for a line segment; the point's own position should already be an expression of that param. The bare open flag draws a hollow (unfilled) marker instead of a solid disc — the standard way to mark a removable discontinuity or an excluded one-sided limit endpoint.
point <id> = (x, y) { [drag: <axis> -> <bind>], [snap: <n>|(nx,ny)|grid], [r: <number>], [label: "text"], [open], [props] }
| prop | type | description |
|---|---|---|
| drag | axis -> bind | make it draggable, writes state |
| snap | number | (number, number) | grid | round the dragged value(s) to a step |
| r | number | radius in pixels (default 6) |
| label | string | text label next to the point |
| open | flag | draw a hollow marker instead of a filled disc |
Example
line#
A line segment uses -> arrow syntax. For an infinite line through a point, omit = and put through: and slope: in the props block instead.
line <id> = (x1,y1) -> (x2,y2) { [props] } OR line <id> { through: <obj_id>, slope: <expr>, [props] }
Example
label#
Text positioned in scene coordinates. Use ${expr} in the text for live-updating values (rounded to 2 dp). Add tex flag to render as LaTeX via KaTeX. anchor: says which end of the text sits on (x, y) — the default start runs the text rightwards, middle centres it, which is what you want for a column of numbers of different widths.
label [id] at (x, y) = <text> { [size: <number>], [anchor: start|middle|end], [tex], [props] }
Example
rect#
(x, y) is the bottom-left corner in scene coords. Width and height are expressions. rotate: tilts the rectangle counter-clockwise by that many degrees about (x, y), so the anchor stays put and the body swings around it — that is what puts a block on a ramp. The angle can be live state, and the rotation happens in scene coords, so it stays correct with or without aspect: equal.
rect <id> = (x, y) { w: <expr>, h: <expr>, [rotate: <expr>], [opacity: <number>], [props] }
Example
circle#
Circle centered at (x, y) with radius r in scene units.
circle <id> = (x, y) { r: <expr>, [opacity: <number>], [props] }
Example
polygon#
Closed polygon. Vertices are a list [...] of (x, y) tuples. rotate: turns the whole shape counter-clockwise by that many degrees about the first vertex.
polygon <id> = [(x1,y1), (x2,y2), ...] { [rotate: <expr>], [props] }
Example
vector#
An arrow from (x1,y1) to (x2,y2). All coords can be expressions.
vector <id> = (x1,y1) -> (x2,y2) { [props] }
Example
arc#
An arc centered at (x, y), from from degrees to to degrees (counter-clockwise). Useful for angle markers.
arc <id> = (x, y) { r: <expr>, from: <degrees>, to: <degrees>, [props] }
Example
image#
(x, y) is the bottom-left corner in scene coords; width/height are expressions. src must be an http(s) URL, a data:image/ URI, or a root-relative path — nothing else compiles. alt is required: it becomes the image's accessible description, so write what it shows, not just its filename.
image <id> = (x, y) { w: <expr>, h: <expr>, src: "" , alt: "" , [opacity: <number>] }
| prop | type | description |
|---|---|---|
| src | string | http(s) URL, data:image/ URI, or /path |
| alt | string | required accessible description |
| opacity | number | fill opacity (default 1) |
Example