Parameters

Free parameters and the sweeps over them: which names an expression leaves open, the axis a sweep walks, and the session that holds the current value.

@internote/canvas-sdk14 exports

#Functions

collectFreeParamNames
packages/canvas-sdk/src/parameters/index.ts:468
Free identifiers anywhere in an environment's attribute values — the letters it may offer the reader as parameters.
(
    children: CompiledNode[],
    categorical?: Partial<Record<string, boolean>>,
    scope?: FreeParamScope,
): string[]

Walks the body flattened, so a letter written inside a cue is found; the caller decides whether a control for it should be SHOWN yet, which is what visibleNodes is for.

environmentParameters
packages/canvas-sdk/src/parameters/index.ts:518
The parameters an environment offers: the ones its author declared, with the range, step, starting value, format and name they gave them, plus any free letter left in an expression — which still gets a slider, just without anyone having said what it means.
(
    children: CompiledNode[],
    free: string[],
    datasets?: Record<string, ChalkDataset>,
): ParameterAxis[]

hidden: parameters are left out: a letter the author put behind an expression still holds a value the marks read, and still has no business being a knob. That is why this is not the same walk a surface makes — the surface wants every letter, the footer wants the operable ones.

looseParameter
packages/canvas-sdk/src/parameters/index.ts:223
Makes a ParameterAxis for a letter used in an expression but never declared as a parameter: a slider from −5 to 5 in steps of 0.1, starting at 1.
(variable: string): ParameterAxis
parameterAxesOf
packages/canvas-sdk/src/parameters/index.ts:240
Every parameter the environment declares, in source order.
(
    nodes: CompiledNode[],
    datasets: Record<string, ChalkDataset> | undefined,
): ParameterAxis[]
parameterAxisOf
packages/canvas-sdk/src/parameters/index.ts:113
Reads one parameter node into a ParameterAxis: its letter, range, step, starting value and format, taking them from a bound data column where it has one.
(
    node: CompiledNode,
    datasets: Record<string, ChalkDataset> | undefined,
): ParameterAxis | null
parameterValues
packages/canvas-sdk/src/parameters/index.ts:386
The value each of an environment's letters holds: the sweep where the scene drives one, the author's starting point otherwise, and over both of those whatever the reader has done to it.
(
    axes: ParameterAxis[],
    steps: StepController,
    params: Record<string, number> | undefined,
    sweeps?: Record<string, number>,
): Record<string, number>

The reader's two inputs are held apart because they MEAN different things. A plain parameter takes a value — it sits where they put it, and nothing else was ever going to move it. A swept one takes a displacement, which is a claim about the sweep rather than about the number: the letter keeps running, it just runs from where they let go. That is why sweeps alone is handed back on a step change; nobody was driving params, so there is nothing there to hand back.

periodAxisFor
packages/canvas-sdk/src/parameters/index.ts:269
The parameter a mark's period: slices against.
(axes: ParameterAxis[], periodBinding: unknown): ParameterAxis | null

A mark names the COLUMN, never the parameter: an environment with two parameters over the same years is not a thing anyone has wanted, and making every mark name the same node would be noise. So the match is by column where one can be made, and by there being a single bound parameter where the mark's column and the parameter's are written differently — #pop.year for the marks and #calendar.year for the scrubber is one axis spelled twice, not two axes.

setParameter
packages/canvas-sdk/src/parameters/index.ts:422
Returns the session updated with a new value for one parameter, as when the reader drags its slider.
<S extends ParameterSession>(
    session: S,
    axis: ParameterAxis,
    steps: StepController,
    value: number,
): S
shiftForValue
packages/canvas-sdk/src/parameters/index.ts:330
The displacement that puts the sweep on value at this clock reading — what dragging the slider stores.
(axis: ParameterAxis, steps: StepController, value: number): number
sweptValue
packages/canvas-sdk/src/parameters/index.ts:310
Where a swept parameter stands right now, given the reader's displacement of it.
(axis: ParameterAxis, steps: StepController, shiftMs?: number): number

The sweep runs its range end to end over duration: from the moment its anchor fires — the same anchor engine every other cue reads, so a cue.parameter(at: 3 + 1.5s) starts when the rest of step 3's choreography says it does. Past the window it holds the far end, the way a fired keyframe holds the value it moved to.

shiftMs is what the reader's drag left behind: a DISPLACEMENT of the sweep's own elapsed time, never of the scene clock. The clock is shared with every cue in the scene, and moving it to scrub a parameter would fire choreography the reader had not reached and un-fire what they had. A displacement rather than a fixed value because playing must still work afterwards — the sweep carries on at its own rate from wherever they left it, and the cues carry on undisturbed, because both ride the one clock that never moved.

The author's default: is the sweep's own starting displacement, so it begins where the author put it and runs to the far end — and a reader who drags BELOW it still reaches the bottom of the range, because the slider spans the range and the displacement spans the slider.

A discrete parameter lands on its nearest stop, so a mark slicing by it shows a row the data actually holds and never a blend of two.

#Interfaces

FreeParamScope
packages/canvas-sdk/src/parameters/index.ts:451
Which of an environment's own attributes are NAMES rather than expressions, and which identifiers are an attribute's formal arguments.

Both are vocabulary facts, so both come from the environment. Q1 on an axis ruled in quarters is a quarter, not Q × 1 wanting a slider for Q; and the y in a surface's expression: is the vertical axis it is being evaluated over, not a letter anyone can drag.

An environment that declares neither — a map, say — gets the plain reading, which is the right one for it.

formal
Per node identifier: an attribute, and the identifiers it binds itself.
Readonly<Record<string, { attribute: string; names: readonly string[] }>>
onAxis
Nodes whose coordinate attributes are read on the axis of that name.
ReadonlySet<string>
standing
Nodes that name their place with on:, on the axis they do not measure.
ReadonlySet<string>
ParameterAxis
packages/canvas-sdk/src/parameters/index.ts:46
One parameter, resolved: what it ranges over, how it reads, and what moves it.
columnRequired
The column it runs over, when over: bound one — a mark's period: matches against it.
unknown
declaredRequired
False for a free letter nobody declared — it still gets a slider.
boolean
discreteRequired
It stands on one stop at a time (discrete:) rather than moving through the gaps. The stops are the data's own values, or the step: ladder when one was written.
boolean
initialRequired
Where it starts: the author's default:, else the first stop.
number
kindRequired
What the values ARE, for the readout — null where they are plain numbers and a decimal is the honest reading.
numberdatemonthweekdayhourweek
labelRequired
The author's name: as inline content, when they gave one.
unknown
maxRequired
The top of its range.
number
minRequired
The bottom of its range — the data's, under over:, else the author's.
number
nodeRequired
The parameter or cue.parameter node it was read from.
CompiledNode
stepRequired
Distance between stops — the data's own spacing unless told otherwise.
number
stopsRequired
The values it may stand on, ascending.
number[]
sweepRequired
The scene's sweep of it, when it is a cue.parameter.
ParameterSweep | null
variableRequired
The letter it occupies in the environment's parameter map.
string
ParameterSession
packages/canvas-sdk/src/parameters/index.ts:406
The two maps a reader's drag can land in, held by both environments' sessions.
paramsRequired
Where the reader put each plain letter — a VALUE.
Record<string, number>
sweeps
How far the reader displaced each swept letter — a TIME, not a value.
Record<string, number>
ParameterSweep
packages/canvas-sdk/src/parameters/index.ts:83
The scene's drive over a cue.parameter: when it starts, how long it runs, how it eases.
atRequired
When the sweep starts.
CueAnchor
durationMsRequired
How long it takes to run its range end to end.
number
easingRequired
Whether it runs at a constant rate or eases in and out.
linearsmooth

Last updated