Skip to content

anim-format (runtime format) / textUnitAt

Function: textUnitAt() ​

ts
function textUnitAt(
   spec, 
   unit, 
   count, 
   frame, 
   out?
): TextUnitState;

THE per-unit maths: what preset spec does at frame (fractional ok) to unit unit of count (letters / words / lines in reading order), stacked INTO out (offsets and turns add, scale and alpha multiply, hidden wins). Returns out.

Timing (staggered presets): the bar runs from start to its last frame (start + length - 1); unit turn r starts at delay + r × stagger and takes duration frames; "Fit to the bar" (default) works the stagger out so the last unit finishes on the bar's last frame. Before its start a unit holds the preset's first state (a typewriter's letters are hidden before the bar), after the bar everything is as typed. Wave: a sine running through the units over the bar (period frames a wave, spread units per wave), eased in / out at the bar's ends; none outside the bar.

Parameters ​

ParameterType
specTextAnimSpec
unitnumber
countnumber
framenumber
out?TextUnitState

Returns ​

TextUnitState

HereSplash — 2D animation for the web