Animations

Input: fromStringsToScene(inputFrames, inputOptions)

Turns frames of code into a SceneData object that contains the animation information.

Parameter inputFrames

An array of objects conforming to the following TypeScript type:

type InputFrame = {
  code: string;
  ranges?: InputRange[];
  decorations?: InputDecoration[];
};
12345
type InputFrame = {
  code: string;
  ranges?: InputRange[];
  decorations?: InputDecoration[];
};

Each object represents one keyframe in the resulting animation.

Parameter inputOptions

An object conforming to the following TypeScript type:

type InputOptions = {
  language: LanguageDefinition;
  tabSize: number;
};
1234
type InputOptions = {
  language: LanguageDefinition;
  tabSize: number;
};

Return value

A SceneData object. Contains the language definition, animation information and some metadata. Best passed straight to toAnimationHTML().

Output: toAnimationHTML(sceneData, animationOptions)

Turns scene data and animation options into a giant string of HTML and CSS that renders the animation.

Parameter sceneData

The animation information generated by fromStringsToScene(). The object interface may change at any time. Use with caution.

Parameter animationOptions

An object conforming to the following TypeScript type:

type AnimationOptions = {
  rootClassSeed?: number;
  debugOverride?: boolean;
  theme?: Theme;
};
12345
type AnimationOptions = {
  rootClassSeed?: number;
  debugOverride?: boolean;
  theme?: Theme;
};

Return value

A string of HTML containing the animation, expressed as a <div> and a <style> element.

You can jump between keyframes by switching between the classes frame0, frame1, frameN etc. on the element with the class cm-animation or use the Code.Movie runtime element.