Stroke draw

An icon or connecting line draws itself, so the eye follows the path.

Rendered video, with motion blur.

0.00 / 2.40 s

Live preview, driven by the code below. No motion blur.

What it does

Each stroke grows from nothing to its full length; any fill fades in after its stroke has finished.

Curve

Ease in-out cubic

Values

S is the frame's short side, 1080 px at 1080p. Unmeasured inputs in the preview are illustrations, not rules.

FactValue
Purpose
Build, enter
Acts on
Mark
Typical length
0.4 to 0.8 s (12 to 24 frames at 30 fps)
Caution
Draw strokes only; fills fade in after, and the width never changes.
PropertyValue
Icons
0.5 to 0.8 s, ease-in-out cubic
Connector lines
0.4 to 0.6 s, ease-out cubic
Several strokes
Stagger 0.06 to 0.1 s
Fill
Fades in over 0.15 s after its stroke finishes
Stroke width
Stays constant
Export samples
12; 1 when still

Starting values from research. Measure against a reference before relying on them.

Code

ts
export const seg = (t: number, a: number, b: number) => Math.max(0, Math.min(1, (t - a) / (b - a)));

export const lerp = (a: number, b: number, k: number) => a + (b - a) * k;

export const out = (k: number) => (k >= 1 ? 1 : 1 - Math.pow(2, -10 * k));

export const io = (k: number) => (k < 0.5 ? 16 * k ** 5 : 1 - Math.pow(-2 * k + 2, 5) / 2);

export const inn = (k: number) => k * k * k;

export const cubicOut = (k: number) => 1 - Math.pow(1 - k, 3);

export const h = (i: number, j: number) => { const x = Math.sin(i * 127.1 + j * 311.7) * 43758.5453; return x - Math.floor(x); };

export const phase = (t: number, start = 0, duration = 0.6) => seg(t, start, start + duration);

export const easeInOut = (p: number) => p < 0.5 ? 4 * p ** 3 : 1 - (-2 * p + 2) ** 3 / 2;

export function strokeDraw(t: number, start: number, duration: number, connector = false) {
  const p = phase(t, start, duration);
  return { dashOffset: 1 - (connector ? cubicOut(p) : easeInOut(p)), fillOpacity: phase(t, start + duration, 0.15) };
}

Best practices

Use it forAvoid
Icons arriving in a feature list
Drawing fills or growing the stroke width
Lines joining two things in a diagram
Long, winding paths that take over the scene

Reduced motion: a simple opacity fade over 0.2 s.