Environments

The definition itself — what defineEnvironment takes, what the registry does with it, and the helpers a definition reads its own node tree with.

@internote/canvas-sdk76 exports
On this page

Every environment starts with defineEnvironment, which checks a definition's shape when you write it: a name, a Surface, and anything else it needs. The EnvironmentDefinition it takes lists everything a definition can hold, on both the compiler's side and the reader's.

A definition does nothing until EnvironmentRegistry has it. Registering makes the environment available to hosts and adds its attributes and vocabulary to what the compiler accepts.

import { defineEnvironment, EnvironmentRegistry } from '@internote/canvas-sdk';

export const greetingEnvironment = defineEnvironment({
    name: 'greeting',
    body: { inline: 'all' },
    attributes: { size: { type: 'float', default: 1, animatable: 'number' } },
    Surface: GreetingSurface,
});

EnvironmentRegistry.register(greetingEnvironment);

An environment whose attributes hold expressions also declares freeParameters: the names its marks leave open, each of which becomes a loose parameter in the scene's table. The host cannot work these out, because which identifiers in a body are free is a vocabulary fact — Q1 on an axis ruled in quarters is a quarter, not Q × 1.

Anything an environment plays by itself — a clock ticking, dots flowing, a change rippling through — checks isStill first, and draws the settled state when it is true. It is true for a reader who asked for reduced motion, and for a host drawing a still picture (ctx.still), such as an exported figure, where a moment caught mid-tick would be a different picture every time.

The rest are for reading a compiled node from inside an environment:

#Functions

#Classes

#Constants

#Interfaces

#Types

Last updated