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>>

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>;

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