Realistic motion often looks flat on screen. Exaggeration pushes each pose further from rest (bigger eyes, a deeper crouch, a higher jump) so the idea is clear at a glance. It’s a dial, not a switch: a game might want 1.8 and a banking app 0.5.
Drag the slider, then press Do the take or click the canvas.
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>10 · Exaggeration — 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: 340px; margin: var(--space-sm) 0; cursor: pointer; }</style></head><body><h1>Exaggeration</h1><p>Push poses past realism so the idea is clear at a glance. One slider drives both modules: the canvas poses go through <code>exaggerate()</code> and the CSS reads <code>--toon-exaggeration</code>.</p><label>Exaggeration <input id="ex" type="range" min="0" max="2.5" step="0.05" value="1"> <output id="out">1</output></label><canvas id="c" style="cursor:pointer" role="img" aria-label="Loop stands still. On a take, Loop squints, then shoots upward with huge eyes before settling back; the slider sets how exaggerated the take is."></canvas><p class="demo-try"><button type="button" class="demo-act" id="act">Do the take</button> Drag the slider, then press <i>Do the take</i> or click the canvas.</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('10-exaggeration', (document, Toon, DemoTheme) => { const T = DemoTheme; // design tokens, live (see demo-theme.js) const { createStage, ticker, poses, ease, exaggerate, withSquash, groundShadow } = Toon; const stage = createStage(document.getElementById('c')); const { ctx } = stage; const ex = document.getElementById('ex'), out = document.getElementById('out'); ex.oninput = () => { document.documentElement.style.setProperty('--toon-exaggeration', ex.value); out.textContent = ex.value; };
const REST = { sy: 1, eye: 1, y: 0, brow: 0 }; const take = [ // a classic cartoon "take" { at: 0, pose: REST }, { at: 0.18, pose: { sy: 0.8, eye: 0.5, y: 0, brow: 4 } }, // anticipation squint { at: 0.3, pose: { sy: 1.35, eye: 1.8, y: 45, brow: -10 }, ease: ease.outBack }, // the take { at: 0.7, pose: { sy: 1.25, eye: 1.7, y: 35, brow: -9 } }, // moving hold { at: 1, pose: REST, ease: ease.outElastic }, ]; let pose = REST, playing = false; const act = () => { if (playing) return; playing = true; poses(take, { duration: 1600, onUpdate: p => (pose = p) }).then(() => (playing = false)); }; stage.canvas.addEventListener('click', act); document.getElementById('act').addEventListener('click', act);
stage.loop(() => { const k = +ex.value, H = 130, x = stage.width / 2, ground = stage.height - 40; // [EXAGGERATION] amplify each pose's distance from rest const sy = Math.max(0.3, exaggerate(pose.sy, k, 1)), eye = Math.max(0.15, exaggerate(pose.eye, k, 1)); const y = pose.y * k, brow = pose.brow * k; stage.clear(); ctx.fillStyle = T.ground; ctx.fillRect(0, ground, stage.width, 40); ctx.fillStyle = T.groundLine; ctx.fillRect(0, ground, stage.width, 2); groundShadow(ctx, x, ground, 34, y, { maxHeight: 200 }); const mood = eye > 1.25 ? 'surprised' : eye < 0.8 ? 'focused' : 'neutral'; // squint → take → settle withSquash(ctx, x, ground - H / 2 - 4 - y, { sx: 1 / sy, sy }, c => Cast.draw(c, 'loop', { x: 0, y: 0, h: H, fill: T.secondary, ink: T.ink, bg: T.surface, mood, noWink: true, eyeScale: Math.max(0.6, Math.min(2.2, mood === 'surprised' ? eye / 1.25 : 1)) }), { x: 0, y: H / 2 + 4 }); });});</script></body></html>Exaggeration in CSS
Section titled “Exaggeration in CSS”Set --toon-exaggeration on a container to scale every squash, height, swing and wind-up inside it. This snippet runs as-is:
<link rel="stylesheet" href="toon.css">
<!-- --toon-exaggeration scales every preset inside. --><div id="dial" style="--toon-exaggeration:1; --toon-height:70px; display:grid; gap:16px"> <div style="display:grid; justify-items:center; padding-top:150px"> <div class="toon-bounce" style="width:48px; height:48px; border-radius:50%; background:var(--toon-color)"></div> <div class="toon-shadow toon-bounce-shadow" style="width:56px; height:12px"></div> </div> <button class="toon-press toon-anticipate" type="button">Hover and press me</button></div><label>Exaggeration <input id="ex" type="range" min="0" max="2" step="0.1" value="1" aria-valuetext="1 times"> <output id="out">×1</output></label>
<script>// 0 is no deformation, 1 the default, 2 twice as far.const ex = document.getElementById('ex');ex.oninput = () => { document.getElementById('dial').style .setProperty('--toon-exaggeration', ex.value); document.getElementById('out').textContent = `×${ex.value}`; ex.setAttribute('aria-valuetext', `${ex.value} times`);};</script>Drag the slider below, then hover over or press the button. At 0 nothing deforms; at 2 everything goes twice as far:
Every preset multiplies its squash, height and swing by --toon-exaggeration, so one value tunes a whole product. For fixed levels, use the .toon-subtle (0.5) and .toon-exaggerate (1.8) modifiers instead.
Exaggeration in Canvas
Section titled “Exaggeration in Canvas”This take (a cartoon double take of surprise) runs as-is. The key poses go through samplePoses(), then exaggerate() pushes each value away from its rest value by the slider’s amount.
<script src="toon.js"></script><canvas style="width:100%; height:180px" role="img" aria-label="A round character does a surprised take: it squints, then stretches upward with wide eyes and raised brows, then settles. The slider sets how far each pose goes"></canvas><label>Exaggeration <input id="ex" type="range" min="0" max="2" step="0.1" value="1" aria-valuetext="1 times"> <output id="out">×1</output></label><button id="take" type="button">Do the take</button>
<script>const { createStage, samplePoses, exaggerate, ease, withSquash, clamp } = Toon;const stage = createStage(document.querySelector('canvas'));const ex = document.getElementById('ex');ex.oninput = () => { document.getElementById('out').textContent = `×${ex.value}`; ex.setAttribute('aria-valuetext', `${ex.value} times`);};// The take, as key poses. sy: height scale, eye: eye scale,// y: lift in px, brow: brow lift in px. At rest: 1, 1, 0, 0.const REST = { sy: 1, eye: 1, y: 0, brow: 0 };const take = [ { at: 0, pose: REST }, { at: 0.2, pose: { sy: 0.85, eye: 0.4, y: 0, brow: -3 } }, { at: 0.32, pose: { sy: 1.25, eye: 1.6, y: 24, brow: 6 }, ease: ease.outBack }, { at: 0.7, pose: { sy: 1.2, eye: 1.5, y: 20, brow: 5 } }, { at: 1, pose: REST, ease: ease.outElastic },];const LENGTH = 1.6; // seconds for the whole takeconst still = matchMedia('(prefers-reduced-motion: reduce)') .matches;// Reduced motion: hold the wide-eyed pose until the button.let start = still ? null : 0, now = 0;document.getElementById('take').onclick = () => (start = now);
stage.loop((dt, time) => { now = time; if (!still && now - start > LENGTH + 1) start = now; // again const p = start === null ? 0.5 : clamp((now - start) / LENGTH); const pose = samplePoses(take, p); // Push every channel away from its rest value by k. const k = +ex.value; const sy = Math.max(0.3, exaggerate(pose.sy, k, 1)); const eye = Math.max(0.15, exaggerate(pose.eye, k, 1)); const lift = Math.max(0, pose.y * k); const brow = pose.brow * k;
const ctx = stage.ctx, x = stage.width / 2, r = 30; const floor = stage.height - 20;3 collapsed lines
const fill = getComputedStyle(document.documentElement) .getPropertyValue('--toon-color').trim() || '#ff6b4a'; const ink = getComputedStyle(document.body).color; stage.clear(); ctx.fillStyle = ink; ctx.fillRect(0, floor, stage.width, 2); // Squash the body around its base, then lift it. const s = { sx: 1 / sy, sy }; withSquash(ctx, x, floor - r - lift, s, (c) => { c.beginPath(); c.arc(0, 0, r, 0, Math.PI * 2); c.fillStyle = fill; c.fill(); c.lineWidth = 2.5; c.strokeStyle = ink; c.stroke(); c.fillStyle = ink; c.lineCap = 'round'; for (const side of [-1, 1]) { c.beginPath(); // eye c.ellipse(side * 10, -4, 3.5 * Math.min(eye, 1.6), 6 * eye, 0, 0, Math.PI * 2); c.fill(); c.beginPath(); // brow c.moveTo(side * 5, -16 - brow); c.lineTo(side * 15, -16 - brow); c.stroke(); } c.beginPath(); // mouth: a gasp when surprised if (eye > 1.3) c.ellipse(0, 12, 4, 5, 0, 0, Math.PI * 2); else c.arc(0, 8, 6, 0.2 * Math.PI, 0.8 * Math.PI); c.stroke(); }, { x: 0, y: r });});</script>Exaggeration: tuning tips
Section titled “Exaggeration: tuning tips”- Exaggerate the important beat, not every frame. In a take, the surprise pose gets the big push and everything else stays readable.
- Stay consistent. Pick one exaggeration level per product or scene; mixing levels feels accidental.
- Clamp the results. High factors can turn a scale negative or push a shape off the canvas. The snippet keeps the height scale at 0.3 or more.
- Exaggerate in time, too.
ease.overshoot()andease.elastic()fly past the target before settling, which reads as extra energy without bigger poses.
The demo also shows anticipation: the squint before the take makes the jump land harder.
For every option, see the Canvas exaggerate function and the CSS custom properties.