Parameters and controls

A scene’s named values and the controls that drive them: what each ranges over, which names an expression leaves open, the sweeps a cue control runs, and the state that holds where the reader put things.

@internote/canvas-sdk17 exports
On this page

A parameter is a named value the reader can change, such as the a in y = a x^2. The nodes that declare one are the controls — slider, selector and their cue twins — and each both declares a parameter and offers a way to move it.

Parameters belong to the scene, not to one environment: an a declared in one graph is the same a a second graph beside it reads, and a control may be written in the scene's detail belonging to neither. An environment reaches them through ctx.parameters, a SceneParameterAccess: all is the scene's table of Parameters, numbers() is what an expression may be evaluated against, values() includes the names a selector holds, and set moves one. A surface that draws with them subscribes through useSceneParameters from @internote/canvas-sdk/react.

const { a, b } = ctx.parameters.numbers();
const y = evaluateExpression(curve.js, { a, b, x });
  • isControl tells a control from a mark, so a surface walking its own children can skip the controls written among them.
  • sliceParameterFor finds the parameter a mark's slice: binding is read against, for data with one row per thing per slice.
  • parameterOf and parametersOf read control nodes into parameters, for a seed that runs before anything has mounted.

Positions and values. A parameter's position is always a number — it is what a track and a sweep's arithmetic work in. Its value is what consumers read, and for a selector over a column of names that is a string: such a parameter's position is an index into its names, and valueAtPosition and positionOfValue are where the two meet.

Sweeps. A cue control's at: is an ordinary cue anchor, so it fires when the rest of its step's choreography says it does, and the step's play, pause and replay drive it. The reader's move displaces the sweep rather than stopping it, and the displacement is of the sweep's own elapsed time and never of the scene clock. A ParameterSweep on a parameter says when it starts and how long it runs.

A letter used in an expression but never declared still gets a slider, from −5 to 5. The host cannot tell which names in an expression are free letters, so an environment whose attributes hold expressions says which through its definition's freeParameters. collectFreeParamNames finds them, given a FreeParamScope of the environment's own vocabulary facts.

#Functions

#Constants

#Interfaces

#Types

Last updated