Frame

Frames: what an animation gives each tick, its value and whether it has settled; its last Frame is done: true. A spring's and a decay's carry their velocity too (Physics), so an animation that replaces one can start at its speed. A Frame handed to you can be rewritten at the next tick: copy one you keep.

import * as Frame from "@wardic/core/Frame"

const sink = (frame: Frame.Frame<number>) => {
  draw(frame.value)
  if (Frame.isPhysics(frame)) speed = frame.velocity
}

Interfaces

Frame

One tick of an animation: its value, and whether it has settled.

Extended by

Type Parameters

V

V

Properties

done
readonly done: boolean;

Whether it has settled: true on its last Frame.

value
readonly value: V;

The value this tick.


MultiPhysics

Machine.springValues' Frame: each key's value and each key's velocity. A spring that replaces it can start from both, so its motion carries on. It's rewritten each tick: copy both before you keep them.

Extends

  • Frame<Record<string, number>>

Extended by

Properties

done
readonly done: boolean;

Whether it has settled: true on its last Frame.

Inherited from

Frame.done

value
readonly value: V;

The value this tick.

Inherited from

Frame.value

velocity
readonly velocity: Record<string, number>;

SpringValues

Machine.springValues' own Frame: its records, and the same values and velocities by index, in keys' order. A sink that reads them every frame reads positions and velocities: storing a number under a key a frame costs where an index doesn't. A velocity record the run wasn't asked to write (records: "value") holds its start. Rewritten each tick, as its records are.

Extends

Properties

done
readonly done: boolean;

Whether it has settled: true on its last Frame.

Inherited from

MultiPhysics.done

keys
readonly keys: readonly string[];
positions
readonly positions: readonly number[];
value
readonly value: V;

The value this tick.

Inherited from

MultiPhysics.value

velocities
readonly velocities: readonly number[];
velocity
readonly velocity: Record<string, number>;
Inherited from

MultiPhysics.velocity

Type Aliases

Physics

type Physics = Frame<number> & object;

A spring's or a decay's Frame: a number, and its velocity now, so an animation that replaces it keeps its speed.

Type Declaration

velocity
readonly velocity: number;

Functions

isPhysics()

function isPhysics(frame): frame is Physics;

Whether frame carries a velocity: a spring's, a decay's.

Parameters

frame

Frame<number>

Returns

frame is Physics


isSpringValues()

function isSpringValues(frame): frame is SpringValues;

Whether a record Frame is Machine.springValues' own, with its keys by index (#663).

Parameters

frame

MultiPhysics

Returns

frame is SpringValues