Skip to content

Staging

Point attention at one thing: highlight it and quiet everything else.

Edit this page

Staging means directing attention, so the viewer looks at one thing at a time. Use contrast in color, light, motion and size to lead the eye, and give the important thing a clear silhouette and a moment to itself. In the demo, Loop performs under the spotlight while a crowd of gray Bricks stands still and watches.

Now showing: StagingOpen the Staging demo on its own page (opens in a new tab)
Show the demo's source

The complete page: it loads toon.css and toon.js, plus demo-theme.js (theme colors), demo-runtime.js (gives the demo its own clock) and, for the characters, cast.js.

<!doctype html>
<html lang="en" data-style="saturday">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>03 · Staging — toon</title>
<link rel="stylesheet" href="../src/toon.css">
<link rel="stylesheet" href="demo.css">
<style>
body { font-size: 15px; line-height: 1.5; max-width: var(--demo-max-width); margin: 2rem auto; padding: 0 1rem; }
canvas { display: block; width: 100%; height: 320px; margin-bottom: var(--space-sm); cursor: pointer; }
</style>
</head>
<body>
<h1>Staging</h1>
<p>Present one idea at a time so it reads instantly. The performer (Loop) is colored, moving and lit; the crowd of
Bricks is gray, still and in shadow, and every one of them looks at the performer.</p>
<canvas id="c" style="cursor:pointer" role="img" aria-label="A spotlit performer, Loop, hops in the middle of the stage while a crowd of dim, gray Bricks stands still and watches. Giving someone else the stage turns them into the performer and moves the spotlight to them."></canvas>
<p class="demo-try"><button type="button" class="demo-act" id="act">Next performer</button> Press <i>Next performer</i> or click anyone to give them the stage: they step up as the new Loop, and the spotlight follows on a spring.</p>
<script src="../src/toon.js"></script>
<script src="demo-theme.js"></script>
<script src="cast-shapes.js"></script>
<script src="cast.js"></script>
<script src="demo-runtime.js"></script>
<script>
ToonDemos.register('03-staging', (document, Toon, DemoTheme) => {
const T = DemoTheme; // design tokens, live (see demo-theme.js)
const { createStage, ticker, noise, Spring, groundShadow } = Toon;
const stage = createStage(document.getElementById('c'));
const { ctx } = stage;
const actors = Array.from({ length: 14 }, (_, i) => ({ seed: i * 9.3, bx: 0.07 + (i % 7) * 0.143, by: i < 7 ? 0.42 : 0.78 }));
let hero = 10;
const spring = { stiffness: 60, damping: 13 };
const spot = { x: new Spring(stage.width / 2, spring), y: new Spring(stage.height / 2, spring) };
const pos = (a, t) => ({ x: a.bx * stage.width + noise(t * 0.3 + a.seed) * 16,
y: a.by * stage.height + noise(t * 0.3 + a.seed + 50) * 6 });
stage.canvas.addEventListener('click', e => {
const r = stage.canvas.getBoundingClientRect(), mx = e.clientX - r.left, my = e.clientY - r.top;
let best = 0, dist = Infinity;
actors.forEach((a, i) => { const p = pos(a, ticker.time), d = Math.hypot(p.x - mx, p.y - my); if (d < dist) { dist = d; best = i; } });
hero = best;
});
stage.loop((dt, t) => {
stage.clear(T.stage); // the theatre stays dark in both modes
const h = pos(actors[hero], t);
actors.forEach((a, i) => {
const p = pos(a, t), isHero = i === hero;
if (isHero) { // Loop performs: hops, arms up, lit
const hop = Math.abs(Math.sin(t * 4)) * 30;
groundShadow(ctx, p.x, p.y + 22, 16, hop, { maxHeight: 90, alpha: 0.5 });
Cast.draw(ctx, 'loop', { x: p.x, y: p.y - 10 - hop, h: 62, fill: T.stageHero, ink: T.stageInk, bg: T.stage, mood: 'happy' });
} else { // the crowd: quiet Bricks, all watching the hero
groundShadow(ctx, p.x, p.y + 22, 16, 0, { maxHeight: 90, alpha: 0.5 });
Cast.draw(ctx, 'brick', { x: p.x, y: p.y + 4, h: 34, fill: T.stageCrowd, ink: T.stageInk, look: { x: Math.sign(h.x - p.x), y: 0 } });
}
});
spot.x.target = h.x; spot.y.target = h.y - 12;
spot.x.step(dt); spot.y.step(dt);
stage.spotlight(spot.x.value, spot.y.value, 55, { dim: 0.72 }); // [STAGING] light leads the eye
});
document.getElementById('act').addEventListener('click', () => { hero = (hero + 1) % actors.length; });
});
</script>
</body>
</html>

To feature one item in a group, add .toon-stage to the container. This snippet runs as-is:

<link rel="stylesheet" href="toon.css">
<div class="toon-stage" role="group" aria-label="Cards"
style="display:flex; flex-wrap:wrap; gap:10px">
<button aria-pressed="false" style="width:60px; height:80px">
Film</button>
<button aria-pressed="true" class="is-featured"
style="width:60px; height:80px">Art</button>
<button aria-pressed="false" style="width:60px; height:80px">
Music</button>
<button aria-pressed="false" style="width:60px; height:80px">
Dance</button>
</div>
<script>
// Pressing a card pins it with .is-featured. Press it again
// to unpin it.
const cards = document.querySelector('.toon-stage');
cards.addEventListener('click', (e) => {
const card = e.target.closest('button');
if (!card) return;
const pin = !card.classList.contains('is-featured');
for (const c of cards.children) {
c.classList.remove('is-featured');
c.setAttribute('aria-pressed', 'false');
}
card.classList.toggle('is-featured', pin);
card.setAttribute('aria-pressed', String(pin));
});
</script>

Below, Art starts pinned with .is-featured. Hover, tab to or press another card to give it the stage:

Now showing: CSS stagingOpen the CSS staging demo on its own page (opens in a new tab)

When one child is featured, hovered or focused, its siblings fade to 40% and shrink to 96% in 300 ms. Only opacity and scale change, so the browser can run it on the GPU; for a pointed light instead, lay a .toon-spotlight overlay over the group.

Draw the scene, then call stage.spotlight() to darken everything outside a soft circle. The light’s position runs through a Spring, so it glides to each new performer instead of jumping. The performer also stands out by color, size and motion.

  • Animate one thing at a time. If everything moves, nothing stands out. Keep the crowd still or on slow idle motion.
  • Use several kinds of contrast together. Color, brightness, motion and size reinforce each other. The Canvas snippet uses all four.
  • Move focus smoothly. A sudden jump disorients the viewer. A short eased glide (300 ms in CSS, a soft spring in Canvas) keeps their place.
  • Fade, don’t blur. Animating filter: blur() on the background repaints every sibling on every frame. Fading and shrinking reads the same and stays smooth.

In the demo, the crowd drifts on slow noise, a secondary action that keeps the scene alive without pulling focus.

For every option, see the Canvas stage and spotlight and the CSS staging preset.