⚠ Early release: v0.3.2.sophistry is not ready for production use. Until 1.0, any minor release may break the API; expect missing features and bugs too.Stability and versioning
Core concepts
A handful of ideas explain most of sophistry. Read this page once and the rest of the guides will feel predictable. Each section is short; Architecture has the depth.
The core, @sophistry/core, is plain TypeScript. The Solid and React bindings are a thin, generated layer over it, so everything on this page holds whichever way you write scenes. Samples show the core API, with the JSX equivalent where it helps.
The stage
Section titled “The stage”A scene is a canvas plus the tree of nodes painted into it. createScene makes one in a host element; <Stage> does the same from JSX. The scene owns the canvas, the renderer, the pointer driver and the accessibility mirror.
import { circle, createScene, text } from "@sophistry/core";
const scene = createScene({ host: document.querySelector<HTMLElement>("#figure")!, units: 10 });scene.add(circle.create({ radius: 1.5 }));scene.add(text.create({ text: "hello", y: -2.2 }));import { Circle, Text, Stage } from "@sophistry/solidjs";
export function Hello() { return ( <Stage units={10}> <Circle radius={1.5} /> <Text text="hello" y={-2.2} /> </Stage> );}The options you reach for most (the same names on createScene and as <Stage> props):
| option | meaning |
|---|---|
units |
scene units across the full width (default 16); larger zooms out |
center |
the scene point shown in the middle (default the origin) |
aspect |
width divided by height (default 16/9); the stage fills its container’s width |
palette, mode, theme |
colours; see Context: theme and clock |
background |
"theme", "transparent" or a colour |
clock |
the clock the scene’s animations run on |
pauseWhenHidden |
skip painting and pause the scene’s own clock while scrolled out of view (default true) |
units and center take a track, so a view can zoom and pan (scene.setView(...) does it imperatively). For several views of one scene (split screen, picture-in-picture) see Cameras.
Scene units, y-up and the frame
Section titled “Scene units, y-up and the frame”Scene code works in units, never pixels. units: 8 means eight units span the canvas’s width. Height follows the aspect ratio, so at 16:9 the visible area is 8 by 4.5 units. y points up, and the origin sits at center.
Strokes, font sizes and dash patterns are in units too, so a scene is identical at any canvas size and device pixel ratio.
Scene units and the frame
A unit grid with y pointing up, the origin at the center, and the visible frame read back from useScene().frame: units={8} at 16:9 spans x from -4 to 4 and y from -2.25 to 2.25.
4 collapsed lines
import type { ColorInput, ThemePalette } from "@sophistry/core";import { derive } from "@sophistry/core";import { Dot, Line, Stage, Text, useScene } from "@sophistry/solidjs";import { For } from "solid-js";
const XS = [-4, -3, -2, -1, 0, 1, 2, 3, 4];const YS = [-2, -1, 0, 1, 2];
function Grid() { const scene = useScene(); // A colour that follows the theme (and the site's light and dark mode). const palette = (pick: (palette: ThemePalette) => ColorInput) => derive(scene.theme, (theme) => pick(theme.palette)); const frame = scene.frame;
return ( <> <For each={XS}> {(x) => ( <Line from={derive(frame, (f) => ({ x, y: f.minY }))} to={derive(frame, (f) => ({ x, y: f.maxY }))} stroke={palette((p) => (x === 0 ? p.muted : p.grid))} strokeWidth={x === 0 ? 0.03 : 0.015} /> )} </For> <For each={YS}> {(y) => ( <Line from={derive(frame, (f) => ({ x: f.minX, y }))} to={derive(frame, (f) => ({ x: f.maxX, y }))} stroke={palette((p) => (y === 0 ? p.muted : p.grid))} strokeWidth={y === 0 ? 0.03 : 0.015} /> )} </For> <Dot center={{ x: 1, y: 1.5 }} color={palette((p) => p.series[0])} radius={0.08} /> <Text text="(1, 1.5)" x={1.15} y={1.5} align="left" fontSize={0.2} color={palette((p) => p.series[0])} /> <Text text="origin" x={0.12} y={-0.15} align="left" fontSize={0.2} color={palette((p) => p.muted)} /> <Text text={derive( frame, (f) => `frame: x ${f.minX} to ${f.maxX}, y ${f.minY} to ${f.maxY}`, )} y={derive(frame, (f) => f.minY + 0.3)} fontSize={0.2} color={palette((p) => p.muted)} // Lifted off the grid and axis lines that run under it. halo /> </> );}
export default function SceneUnitsFrame() { return ( <Stage units={8}> <Grid /> </Stage> );}scene.frame is the visible box in scene units ({ minX, minY, maxX, maxY }) as a track-like value, so you can pin things to edges and corners and follow resizes; in a component, read it through useScene().frame. Pass yUp: false if you prefer the canvas convention, where y grows downward.
The scene graph
Section titled “The scene graph”The scene is a retained tree of nodes. A node is created once and lives until it is disposed; changing it is a write to one of its props, never a re-render.
import { circle, createScene, group, track } from "@sophistry/core";
const scene = createScene({ host: document.body, units: 8 });const ring = scene.add(circle.create({ radius: 1, stroke: "#89b4fa" }));
ring.set("radius", 2); // write one propring.update({ fill: "#89b4fa", fillOpacity: 0.2 }); // write severalring.get("radius"); // 2
const radius = track(2);ring.set("radius", radius); // a Readable binds: the node follows itradius.set(3); // ...and recomputes in the next frame
const arm = scene.add(group.create({ rotation: 0.3 })); // a containerarm.add(circle.create({ center: { x: 2, y: 0 }, radius: 0.3 }));
ring.on("tap", () => ring.set("fill", "tomato")); // events; returns its unsubscribering.bounds(); // its box in scene units, measured lazilyring.dispose(); // removes it and drops its bindingsset(key, value)stores a value, or binds when the value is aReadable(a track or aderive). There is no other kind of reactivity: a node never reads anything it was not given.- Containers (the root,
group, composites) havechildren,add,removeandsetChildren, which reconciles by identity and disposes what it drops. - The node is the handle.
bounds(),localBounds(),center(),pointAt(direction),width()andheight()measure it; layout helpers take those boxes. See Layout. - Order is tree order plus
zIndex; see Paint order.
Definitions and descriptors
Section titled “Definitions and descriptors”Every node kind is a definition: a lowercase value such as circle, label or axes, with create(props) and a descriptor that says, for each prop:
- its default;
- which stage bits a write invalidates (below);
- whether it is
instanceable, so instancing may drive it per item; - its kind: a
value, aneventhandler (onTap, …), orchildren.
import { circle } from "@sophistry/core";
circle.name; // "Circle"circle.descriptor.radius; // { invalidates: Invalidate.GEOMETRY, instanceable: true }circle.descriptor.center; // { invalidates: Invalidate.TRANSFORM, instanceable: true }The descriptor is the single source for updates, instancing, types, the API docs and the bindings: codegen reads it to write <Circle>. Your own definitions work the same way. defineShape takes a descriptor and a geometry function, and the result is as first-class as circle:
A custom shape with defineShape
defineShape turns a props descriptor and a geometry function into a definition like circle; the new rose shape is created, drawn and animated.
12 collapsed lines
import type { Clock, Point, ShapeProps } from "@sophistry/core";import { createScene, defineShape, draw, Invalidate, parallel, sequence, shapeProps, track, valueTo,} from "@sophistry/core";
interface RoseProps extends ShapeProps { center?: Point; /** Number of petals (an odd count draws as many, an even one twice as many). */ petals: number; size: number;}
// Each prop names the cheapest stage it invalidates: a move is a new matrix, never a new outline.const rose = defineShape<RoseProps>({ name: "Rose", props: { ...shapeProps, center: { invalidates: Invalidate.TRANSFORM, instanceable: true }, petals: { invalidates: Invalidate.GEOMETRY }, size: { invalidates: Invalidate.GEOMETRY, instanceable: true }, }, geometry: ({ petals, size }) => ({ closed: true, polylines: [ Array.from({ length: 360 }, (_, i) => { const t = (i / 360) * 2 * Math.PI; const radius = size * Math.cos(petals * t); return { x: radius * Math.cos(t), y: radius * Math.sin(t) }; }), ], }), offset: (props) => props.center,});
export default function mount(host: HTMLElement, clock?: Clock): () => void { const scene = createScene({ host, clock, units: 10 }); const drawn = track(0); const size = track(1.5); const rotation = track(0); scene.add( rose.create({ petals: 5, size, progress: drawn, rotation, stroke: "#cba6f7", fill: "#cba6f7", fillOpacity: 0.2, }), ); void scene.play( sequence( draw(drawn, { duration: 2 }), parallel( valueTo(size, 2.6, { duration: 1.2 }), valueTo(rotation, Math.PI / 5, { duration: 1.2 }), ), ), ); return () => scene.dispose();}defineComposite builds a node from other nodes (a chart, a coordinate system); Extending covers both.
Dirty stages
Section titled “Dirty stages”A shape caches a short pipeline: geometry (its outline) → transform (where it sits) → style (paints, widths, dashes) → spec (the draw record the renderer paints). A prop write ORs its stage bits into the node’s dirty mask, and the next commit reruns only those stages. That is why descriptors matter:
| a write to… | invalidates | reruns |
|---|---|---|
radius, points, text |
Invalidate.GEOMETRY |
the outline, then the spec |
center, x, rotation, place |
Invalidate.TRANSFORM |
a matrix; the outline keeps its identity |
stroke, fill, opacity |
Invalidate.STYLE |
the style, then the spec |
progress, zIndex, visible |
Invalidate.SPEC |
only the spec assembly |
Results keep their identity when their inputs did not change, and the renderer’s caches key on identity, so moving a shape a thousand times never rebuilds its path. Containers add Invalidate.SPACE (the coordinate space handed to children) and composites Invalidate.UPDATE. See Stages and dirty bits.
Tracks: signals are the single source of truth
Section titled “Tracks: signals are the single source of truth”A track is a small observable value: peek() reads it, set(value) writes it, subscribe(onStale) listens. derive computes from one or more readables, and watch runs a side effect when one changes.
import { derive, track, trackPoint, watch } from "@sophistry/core";
const radius = track(1);const position = trackPoint(2, 0); // a track of { x, y }const area = derive(radius, (r) => Math.PI * r * r);const label = derive([radius, position], (r, p) => `r = ${r} at ${p.x}, ${p.y}`);
radius.set(2);area.peek(); // 12.57: computed now, on demandconst stop = watch(area, (value) => console.log(value)); // runs in the frame's commitstop();The model is push-stale, pull-value:
setonly tells subscribers “this may have changed”; nothing is computed then.- A value is computed when it is read with
peek(), at most once per change. So a diamond (two derives of one track feeding a third) never sees a half-updated state, and three writes in one frame cost one recompute. derivesubscribes to its sources only while something subscribes to it, so a derived value nobody reads costs nothing and leaks nothing. There is no global graph, no owner and noflush.
Tracks, derive and watch
One track drives a dot, a radius, an arc and a caption through derive; watch mirrors it into the page once per frame.
14 collapsed lines
import type { Clock } from "@sophistry/core";import { arc, circle, createScene, derive, dot, forever, line, text, track, valueTo, watch,} from "@sophistry/core";
const RADIUS = 2.4;
export default function mount(host: HTMLElement, clock?: Clock): () => void { const scene = createScene({ host, clock, units: 10 }); const turns = track(0); // Derived values recompute lazily, at most once per change, when read. const angle = derive(turns, (t) => (t % 1) * 2 * Math.PI); const tip = derive(angle, (a) => ({ x: RADIUS * Math.cos(a), y: RADIUS * Math.sin(a), })); const degrees = derive(angle, (a) => Math.round((a * 180) / Math.PI));
scene.add(circle.create({ radius: RADIUS, stroke: "#6c7086" })); scene.add(line.create({ from: { x: 0, y: 0 }, to: tip, stroke: "#89b4fa" })); scene.add(arc.create({ radius: 0.8, angle, stroke: "#f9e2af" })); scene.add(dot.create({ center: tip, color: "#f38ba8" })); scene.add( text.create({ text: derive(degrees, (d) => `θ = ${d}°`), x: 4, y: -2.2 }), );
// A side effect outside the scene: runs in the commit phase, coalesced. const readout = host.appendChild(document.createElement("output")); const stop = watch(degrees, (d) => { readout.textContent = `angle: ${d}°`; });
void scene.play( forever(valueTo(turns, (from) => from + 0.25, { duration: 1.2 })), ); return () => { stop(); readout.remove(); scene.dispose(); };}Because a node binds to whatever readable it is given, the thing that writes a track does not matter. Dragging, a tween, a slider, a scroll listener and your own store can all write the same track; the shape does not know or care which one did:
One track, many drivers
The same x track is written by dragging the knob, by a tween from the button, and by a slider. Nothing is wired together: they all just write the track.
17 collapsed lines
import { derive, draggable, scalarParam, type Track, track, valueTo,} from "@sophistry/core";import { Dot, Line, Stage, Text, usePlayer, useScene, useTrackValue,} from "@sophistry/solidjs";
const FROM = { x: -3, y: 0 };const TO = { x: 3, y: 0 };
function Knob(props: { x: Track<number> }) { const palette = derive(useScene().theme, (t) => t.palette); const param = scalarParam(FROM, TO, { range: [-3, 3] }); return ( <> <Line from={FROM} to={TO} stroke={derive(palette, (p) => p.grid)} /> <Dot center={derive(props.x, (x) => ({ x, y: 0 }))} radius={0.22} label="value" {...draggable(props.x, { param })} /> <Text text={derive(props.x, (x) => `x = ${x.toFixed(2)}`)} y={1.2} /> <Text text="drag it, tween it, or slide it" y={-1.2} fontSize={0.28} color={derive(palette, (p) => p.muted)} /> </> );}
export default function OneTrackManyDrivers() { const { play } = usePlayer(); const x = track(0); const value = useTrackValue(x);
return ( <> <Stage units={10}> <Knob x={x} /> </Stage> <div style={{ display: "flex", gap: "0.75rem", "align-items": "center", "margin-top": "0.5rem", }} > <button type="button" onClick={() => void play(valueTo(x, x.peek() > 0 ? -3 : 3))} > Tween to the other end </button> <input type="range" aria-label="x" style={{ flex: "1" }} min={-3} max={3} step="any" value={value()} onInput={(e) => x.set(Number(e.currentTarget.value))} /> </div> </> );}Animations are not tied to track itself. They drive any animatable (an object with peek() and set()), so a property of a plain object works too; see Animating signals and stores.
Animations are seekable descriptions
Section titled “Animations are seekable descriptions”draw, fadeIn, moveTo, valueTo and friends build animations that walk tracks from A to B over time. They know nothing about canvases or nodes. An animation is a lazy value with a known duration and a seek(t) method; nothing runs until a runner samples it against a clock. That is why the same value can be played, paused or scrubbed:
import { createScene, draw, fadeOut, sequence, track } from "@sophistry/core";
const scene = createScene({ host: document.body, units: 8 });const drawn = track(0);const opacity = track(1);
await scene.play(draw(drawn, { duration: 1.5 })); // resolves "done" or "aborted"; never rejectsconst tl = scene.timeline(sequence(draw(drawn), fadeOut(opacity)));tl.seek(0.5); // jump half a second in; every track takes its value for that momenttl.seek(0); // and back, restoring start valuesvoid tl.play();scene.play and scene.timeline run on the scene’s clock; in a component, usePlayer() returns the same pair bound to the enclosing stage and aborts its runs when the component goes away. Composites (sequence, parallel, lagged, repeat, forever) sample at absolute time, so they are frame-exact. See Animation and Timelines.
Springs come in two forms. springTo(target, to, spring) is a seekable animation like any other (its duration is the settle time). follow(target, source, spring) is live: the target chases a moving source on the clock and keeps its velocity when the source changes.
Springs: springTo and follow
springTo is a seekable spring animation with an overshoot; follow keeps a second point chasing the first, live, preserving its velocity.
11 collapsed lines
import type { Clock } from "@sophistry/core";import { circle, createScene, follow, sequence, springTo, text, track, trackPoint,} from "@sophistry/core";
export default function mount(host: HTMLElement, clock?: Clock): () => void { const scene = createScene({ host, clock, units: 10 }); const leader = trackPoint(-3, 0); const follower = trackPoint(-3, 0); const size = track(0.2);
scene.add( circle.create({ center: follower, radius: 0.35, stroke: "#a6e3a1", strokeWidth: 0.06, }), ); scene.add( circle.create({ center: leader, radius: size, fill: "#f38ba8", stroke: "none", }), ); scene.add(text.create({ text: "springTo (pink) · follow (green)", y: -3.2 }));
// A live follower on the scene's clock: retargets keep the velocity. const stop = follow( follower, leader, { stiffness: 60, damping: 8 }, { clock: scene.clock }, );
const bouncy = { stiffness: 180, damping: 9 }; void scene.play( springTo(size, 0.4, bouncy), sequence( springTo(leader, { x: 3, y: 1.5 }, bouncy), springTo(leader, { x: 0, y: -1.5 }, bouncy), springTo(leader, { x: -3, y: 0 }, { stiffness: 120, damping: 20 }), ), ); return () => { stop(); scene.dispose(); };}The frame loop
Section titled “The frame loop”One shared requestAnimationFrame loop drives every clock, scene and renderer on the page, and sleeps when nothing needs a frame. Each frame runs three phases in order:
- tick: clocks advance; animations sampled on them write tracks (which only mark their subscribers stale);
- commit: each scene pulls its stale bindings and reruns its dirty nodes’ stages;
watchcallbacks run here; - paint: renderers draw what the commit produced.
So a write and the paint it causes land in the same frame, and work is proportional to what changed: a still scene costs nothing per frame. The same holds for writes from outside the loop (a pointer event, a fetch): they mark, and the next frame pulls. See The frame loop and the renderer.
Clocks
Section titled “Clocks”Time comes from a clock. By default every scene shares defaultClock. A clock can be paused and has a speed; its time, paused and speed are readables:
import { circle, createClock, createScene } from "@sophistry/core";
const clock = createClock();const scene = createScene({ host: document.body, units: 8, clock });scene.add(circle.create({ radius: 1 }));
clock.pause();clock.setSpeed(0.25); // slow motionclock.advance(2); // step by hand, even while pausedA clock also carries the reduced-motion setting: by default it follows the user’s prefers-reduced-motion, and under it play jumps to the end state instead of animating (see Reduced motion). Give a scene its own clock when scenes need independent pause and speed, or when you want to control playback from outside the stage (as in the tutorial’s timeline step). Inside a stage, useClock() reads the enclosing clock.
Instancing and path batches
Section titled “Instancing and path batches”A node per item is the right default, and cheap enough for thousands. For many items of one kind that need no individuality (scatter points, particles, grid cells), instances(definition, { data, key, channels, shared, transition }) draws all of them with one node: per-item values live in typed arrays, only instanceable props may vary per item, and a data change is reconciled by key with tweened or sprung transitions. Click the stage to re-lay 4,000 dots:
Instancing: thousands of dots, one node
instances() draws 4,000 circles as one node with per-item channels; changing its data tweens every dot to a new layout with a stagger.
2 collapsed lines
import type { Clock } from "@sophistry/core";import { circle, createScene, instances, text } from "@sophistry/core";
interface Item { id: number; x: number; y: number;}
const COUNT = 4000;const COLORS = ["#89b4fa", "#a6e3a1", "#f9e2af", "#f38ba8"];
/** A spiral (sunflower) layout, or a grid. */function layout(spiral: boolean): Item[] { return Array.from({ length: COUNT }, (_, id) => { if (!spiral) return { id, x: ((id % 80) - 39.5) * 0.18, y: (Math.floor(id / 80) - 24.5) * 0.18, }; const radius = 0.07 * Math.sqrt(id); const angle = id * 2.39996; return { id, x: radius * Math.cos(angle), y: radius * Math.sin(angle) }; });}
export default function mount(host: HTMLElement, clock?: Clock): () => void { const scene = createScene({ host, clock, units: 16 }); const dots = instances(circle, { data: layout(true), key: (item) => item.id, channels: { center: (item) => item, fill: (item) => COLORS[item.id % 4] }, shared: { radius: 0.06, stroke: "none" }, transition: { duration: 1.2, stagger: 0.0002, enter: { from: { opacity: 0 } }, }, }); scene.add(dots); scene.add( text.create({ text: "4,000 dots, one node: click to re-lay them", y: -4.1, }), ); let spiral = true; const toggle = () => { spiral = !spiral; dots.set("data", layout(spiral)); }; host.addEventListener("click", toggle); return () => { host.removeEventListener("click", toggle); scene.dispose(); };}When the items are distinct outlines (wedges, ribbons, areas, arrows of a field), a path batch (pathBatch.create({ items })) draws them all from one node. Charts are built on both, so they batch by default.
PathBatch: many outlines, one node
A field of 600 arrowheads, each its own outline and colour, drawn by one pathBatch node whose items derive from a single phase track.
10 collapsed lines
import type { Clock, PathBatchItem } from "@sophistry/core";import { createScene, derive, forever, pathBatch, text, track, valueTo,} from "@sophistry/core";
/** An arrowhead at `(x, y)` pointing along `angle`. */function arrow( x: number, y: number, angle: number, length: number,): PathBatchItem { const at = (along: number, across: number) => ({ x: x + along * Math.cos(angle) - across * Math.sin(angle), y: y + along * Math.sin(angle) + across * Math.cos(angle), }); const hue = Math.round(((angle / Math.PI) * 180 + 360) % 360); return { closed: true, polylines: [ [ at(length, 0), at(-length / 2, length / 2), at(-length / 4, 0), at(-length / 2, -length / 2), ], ], fill: `hsl(${hue} 70% 70%)`, };}
export default function mount(host: HTMLElement, clock?: Clock): () => void { const scene = createScene({ host, clock, units: 16 }); const phase = track(0); // One node, 600 distinct outlines, rebuilt from the phase each frame it moves. const items = derive(phase, (p) => Array.from({ length: 600 }, (_, i) => { const x = (i % 30) * 0.5 - 7.25; const y = Math.floor(i / 30) * 0.4 - 3.8; const angle = Math.sin(x * 0.6 + p) + Math.cos(y * 0.8 - p); return arrow(x, y, angle * 1.5, 0.12 + 0.06 * Math.abs(Math.sin(angle))); }), ); scene.add(pathBatch.create({ items, stroke: "none" })); scene.add(text.create({ text: "600 outlines, one PathBatch node", y: -4.3 })); void scene.play( forever( valueTo(phase, (from) => from + 2 * Math.PI, { duration: 6, easing: "linear", }), ), ); return () => scene.dispose();}Context: theme and clock
Section titled “Context: theme and clock”Some values flow down the tree: containers provide them and descendants read the nearest one (node.context(key)). The root provides the theme, the clock, the reduced-motion flag and the frame; a chart provides its scales to the marks inside it. You can make your own keys with createContextKey.
The theme is a palette plus sizing defaults, each with a light and a dark variant. A scene follows <html data-mode="light|dark"> on its own and picks Catppuccin by default. Any explicit prop (stroke, color, …) overrides its theme default; for a colour that should follow the theme, bind a derive of scene.theme:
import { circle, createScene, derive } from "@sophistry/core";
const scene = createScene({ host: document.body, units: 8, palette: "catppuccin" });const accent = derive(scene.theme, (theme) => theme.palette.series[0]);scene.add(circle.create({ radius: 2, stroke: accent })); // repaints when the mode flipsIn components, useScene().theme is the same readable, and useTheme() returns its value for Solid or React logic. Define your own palette with definePalette and pass it as palette. See Theming and colour.
How the bindings map onto this
Section titled “How the bindings map onto this”Each binding is a thin layer over the API above. Every component is generated from a definition (export const Circle = wrap(circle)), so the two always agree on names and props.
| in JSX (Solid or React) | in the core |
|---|---|
<Stage units={10}> |
createScene({ host, units: 10 }) |
<Circle radius={2} /> |
scene.add(circle.create({ radius: 2 })), once |
a changed prop (radius={size()} in Solid, a re-render in React) |
node.set("radius", value) for that key only |
a track as a prop (radius={radius}) |
node.set("radius", radius): a binding; no framework work per frame |
| children | container.setChildren([...]), reconciled by identity |
ref={(node) => ...} |
the node itself |
onTap={...} |
an event prop, the same as node.on("tap", ...) |
usePlayer() |
scene.play / scene.timeline, aborted on unmount |
useScene(), useClock(), useTheme() |
scene, scene.clock, scene.theme |
useTrackValue(track) |
track.subscribe + peek, for DOM text and framework logic |
In Solid a component body runs once and makes its node; in React each element is one host fiber over one node, and a re-render only sets the props that changed. Either way, the rule is the same: pass the track itself for anything that animates, and keep framework state for things the user changes. Bindings has the details.
Naming conventions
Section titled “Naming conventions”Props follow a few rules, so a name you guess is usually right.
- Names are spelled out:
center,radius,cornerRadius,function. Single letters are coordinates only (x,y,z,t). - Definitions are lowercase values, components PascalCase:
circle.create(...)in the core,<Circle>in a binding. - Colour: geometry takes
strokeandfill; text and single-hue marks takecolor; a cycled categorical list iscolors; a continuous colour map isramp. See Theming and colour. - A part toggles by its bare name:
grid,legend,tip,labels,ticks,numbers. Each takestrue/falseor an options object.visible={false}hides the whole component. labelis the text;labelsdraws them. Part settings are prefixed by the part:numberFontSize,labelGap,tipLength.- Spacing:
gapbetween separate things,paddinginside a surround,marginfrom a frame edge,spacingcentre-to-centre pitch,lineHeighta multiple of the font size. tipis always an arrowhead; the hover box istooltip.orientationis"vertical"or"horizontal"; vertical marks grow along y.- Paint order is
zIndex;zis only ever a coordinate. - Functions:
createXmakes a stateful object (createScene,createClock,createSlots),defineXmakes a definition,useXis a binding hook, a bare noun (track,linearGradient) is a plain value. - Time is in seconds everywhere:
duration,delay,lag.
Next steps
Section titled “Next steps”- Your first scene: put these ideas to work
- Shapes and styling
- Animation and Timelines
- Interaction
- Architecture: the same model, in depth