paper-motion

Pointer label

pointer-label

A short line lands on the screen, a curved arrow draws from it to a control, and the control answers with a pulse.

Install
$ npx paper-motion add pointer-label

Writes a scene to pieces/, wired to your brand folder.

Tune it, then add it to your kit
Parameters
label
button
format
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>pointer-label</title>
<!--
  Annotation · pointer label (5 s). A short line lands on the screen, then a curved arrow draws from it to the control
  it talks about; the head snaps on, the control answers with a pulse, and the camera leans in on the pair.
  Arrive 0–0.9 s · Label 1.0–1.6 s · Arrow 1.4–2.2 s · Answer 2.3 s · Hold to 5 s.
  Vertical: a tall screen without sidebar, the label set on two lines under the button; square: a squarer screen.
-->
<style>
  #stage { overflow: hidden; }
  .abs { position: absolute; box-sizing: border-box; }
  #comp { position: absolute; box-sizing: border-box; }
  #screen { position: absolute; inset: 0; overflow: hidden; display: grid; grid-template-columns: 16% 1fr; }
  .side { display: flex; flex-direction: column; gap: 1.1em; padding: 2.2em 1.6em; }
  .main { position: relative; display: flex; flex-direction: column; gap: 1.4em; padding: 2em 2.2em; }
  .bar { display: flex; align-items: center; gap: 1em; }
  .btn { padding: 0.75em 1.5em; border-radius: 0.6em; font-size: 1.25em; white-space: nowrap; }
  #preview { flex: 1; border-radius: 0.8em; position: relative; overflow: hidden; }
  i { display: block; height: 0.6em; border-radius: 999px; }
  #ink { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
  #label { position: absolute; white-space: nowrap; }
  #halo { position: absolute; border-radius: 0.8em; pointer-events: none; }
</style>
</head>
<body>
<main id="stage">
  <div id="bg" class="abs" style="inset:0"></div>
  <div id="world"><div id="comp"><div id="screen"></div><div id="halo"></div><svg id="ink"><path id="arc"/><path id="head"/></svg><div id="label"></div></div></div>
</main>
<script type="module">
import { scene, progress, ease, spring } from 'paper-motion';
import { wordRise } from 'paper-motion/moves';
import { camera } from 'paper-motion/kit';
import { loadBrand } from 'paper-motion/brand';

const CONFIG = {
  background: null,
  label: 'One click renders it all.',
  button: 'Render',
  format: [1920, 1080],
};

const B = await loadBrand();
const [W, H] = CONFIG.format, SHORT = Math.min(W, H), D = 5;
const s = scene({ width: W, height: H, fps: 30, duration: D, background: B.color('ground') });
const bgId = CONFIG.background ?? B.set.entries.find((e) => e.shader && !e.image)?.id;
if (bgId) B.shader(s, '#bg', bgId);
document.querySelector('#bg').style.opacity = 0.3;
const $ = (id) => document.getElementById(id);

const DIST = SHORT * 0.62, K = 1 + DIST / (SHORT * 1.7);
const cam = camera($('stage'), $('world'), { perspective: SHORT * 1.7 });
const tall = H > W, square = W === H;
const comp = $('comp'), cw = (tall ? W * 0.88 : square ? W * 0.84 : W * 0.7) * K, ch = cw * (tall ? 1.45 : square ? 0.8 : 0.58), R = (B.tokens?.shape?.radius ?? 12) * (SHORT / 1080) * K;
const ground = B.color('ground'), muted = B.color('muted'), figure = B.color('figure'), accent = B.color('accent', '#E9E4D8');
Object.assign(comp.style, { width: `${cw}px`, height: `${ch}px` });
const screen = $('screen');
Object.assign(screen.style, { borderRadius: `${R}px`, background: B.surface(0.2), border: `1.5px solid ${muted}55`, boxShadow: `0 ${SHORT * 0.04}px ${SHORT * 0.12}px rgba(0,0,0,0.5)`, fontSize: `${cw * (tall ? 0.024 : square ? 0.0145 : 0.0105)}px`, fontFamily: B.font('text') });
const line = (w, c = muted, o = 0.45) => `<i style="width:${w}%;background:${c};opacity:${o}"></i>`;
if (tall) screen.style.gridTemplateColumns = '1fr';
screen.innerHTML = `<div class="side" style="background:${ground}${tall ? ';display:none' : ''}">${line(70, figure, 0.9)}${line(85)}${line(60)}${line(75)}${line(50)}</div>
<div class="main"><div class="bar">${line(18, figure, 0.9)}<div style="flex:1"></div><div class="btn" style="border:1px solid ${muted}55;color:${muted}">Preview</div><div class="btn" id="target" style="background:${accent};color:${ground};font-weight:500">${CONFIG.button}</div></div>
<div id="preview" style="background:${ground};border:1px solid ${muted}33"><div id="pv" style="position:absolute;inset:0;opacity:0.5"></div></div></div>`;
if (bgId) B.shader(s, $('pv'), bgId);
const label = B.style($('label'), 'display', { short: SHORT * K, color: 'figure' });
label.textContent = CONFIG.label; label.style.fontSize = `${ch * 0.06}px`; label.style.textShadow = '0 2px 30px rgba(0,0,0,0.8)';
if (tall) Object.assign(label.style, { fontSize: `${cw * 0.085}px`, whiteSpace: 'normal', width: `${cw * 0.6}px`, textAlign: 'right', lineHeight: '1.15' });
cam.place(comp, { x: 0, y: 0, z: 0 });
await document.fonts.ready;

// geometry in the screen's own pixels: the button, and a label placed below-left of it over the preview
const target = $('target'), pr = screen.getBoundingClientRect(), sc = cw / pr.width, br = target.getBoundingClientRect();
const bx = (br.left - pr.left) * sc, by = (br.top - pr.top) * sc, bw = br.width * sc, bh = br.height * sc;
const lw = label.offsetWidth, lh = label.offsetHeight;
const lx = cw * (tall ? 0.14 : square ? 0.3 : 0.38), ly = ch * (tall ? 0.3 : 0.5);
Object.assign(label.style, { left: `${lx}px`, top: `${ly}px` });
// the arc: from the end of the label, rising in a loose curve into the button's lower edge
const U = tall ? cw * 0.62 : ch;                                     // the arc's own unit: the height in wide frames, the width in tall
const p0 = [lx + lw + U * 0.02, ly + lh * 0.45], p3 = [bx + bw * 0.35, by + bh + U * 0.025];
const p1 = [p0[0] + U * 0.22, p0[1] + U * 0.02], p2 = [p3[0] - U * 0.02, p3[1] + U * 0.2];
const arc = $('arc'), head = $('head');
arc.setAttribute('d', `M${p0} C${p1} ${p2} ${p3}`);
const sw = SHORT * 0.005 * K;
for (const el of [arc, head]) Object.assign(el.style, { fill: 'none', stroke: accent, strokeWidth: `${sw}`, strokeLinecap: 'round', strokeLinejoin: 'round' });
const L = arc.getTotalLength(); arc.style.strokeDasharray = `${L}`;
// the head: two short strokes along the arc's last tangent
const ang = Math.atan2(p3[1] - p2[1], p3[0] - p2[0]), hl = U * 0.035;
const wing = (d) => [p3[0] - Math.cos(ang + d) * hl, p3[1] - Math.sin(ang + d) * hl];
head.setAttribute('d', `M${wing(0.55)} L${p3} L${wing(-0.55)}`);
const HL = head.getTotalLength(); head.style.strokeDasharray = `${HL}`;
const halo = $('halo');
Object.assign(halo.style, { left: `${bx}px`, top: `${by}px`, width: `${bw}px`, height: `${bh}px`, border: `${sw * 0.7}px solid ${accent}` });
const T = { label: 1.0, arc: [1.4, 2.2], hit: 2.3 };
const mx = (Math.min(lx, bx) + Math.max(lx + lw, bx + bw)) / 2 - cw / 2, my = (by + ly + lh) / 2 - ch / 2;

s.update((t) => {
  const arrive = progress(t, 0, 0.9, ease.outCubic), lean = progress(t, 0.9, 2.8, ease.inOutCubic);
  cam.at({ x: mx * lean, y: my * lean, z: DIST + SHORT * 0.3 * (1 - arrive) - SHORT * (tall ? 0.38 : 0.55) * lean, yaw: -8 * (1 - arrive) + 3 * lean, pitch: 3 * (1 - arrive) - 1 * lean });
  comp.style.opacity = String(progress(t, 0, 0.35));
  wordRise(label, t, { start: T.label, each: B.pace.stagger, duration: 0.7 });
  const a = progress(t, ...T.arc, ease.inOutCubic);
  arc.style.strokeDashoffset = `${L * (1 - a)}`; arc.style.opacity = a > 0 ? '1' : '0';
  const h = progress(t, T.arc[1] - 0.05, T.arc[1] + 0.15, ease.outCubic);
  head.style.strokeDashoffset = `${HL * (1 - h)}`; head.style.opacity = h > 0 ? '1' : '0';
  // the answer: the button presses and a halo rings out from it
  const hit = t >= T.hit ? spring(t - T.hit, { stiffness: 300, damping: 12 }) : 0;
  target.style.transform = `scale(${1 + (t >= T.hit ? 0.08 * (1 - hit) : 0)})`;
  const ring = progress(t, T.hit, T.hit + 0.8, ease.outCubic);
  halo.style.opacity = String(t >= T.hit ? 0.9 * (1 - ring) : 0);
  halo.style.transform = `scale(${1 + ring * 0.5}, ${1 + ring * 1.1})`;
});
B.cue(s, 'transition', 0); B.cue(s, 'text', T.label); B.cue(s, 'land', T.hit);
B.sound(s);
await s.start();
</script>
</body>
</html>
Defaults

Structure

Pointer label01 / 05
Arrive
arrive
0.0 / 5 s
01Arrive
02Label
04Answer
05Hold
03Arrow
0 s5 s
  1. 010–0.9 sArrivearrive
  2. 021–1.6 sLabellabel
  3. 031.4–2.2 sArrowarrow
  4. 042.3–2.9 sAnsweranswer
  5. 052.9–5 sHoldhold

The script, sketched: the beats in order and their length, in the brand's colors and type. The clip above is the engine's render of the same recipe.

Notes

  • Wired to the brand folder: needs brand/tokens.json (a palette and a font pair work) and, for the field, a shader-set entry.
  • Recomposes for 16:9, 9:16 and 1:1: set format and the layout and camera follow.

Spec

Id
pointer-label
Type
Blocks
Version
1.0.0
Engine
>=0.2.6
License
MIT

Related