Cube stack
A 7-second portrait loop with six cube characters and squash & stretch
- 0–1.6 s the big blue cube drops out of the pipe and lands with a squash, the green one plops on top, the one below blinks
- 1.6–2.9 s coral, yellow and pink land on the beat, the squash runs down the stack as a chain, the tower wobbles more
- 2.9–4.75 s the smallest peeks out of the pipe, looks down and plops on top, the tower sways, everyone looks worried
- 4.75–5.9 s the last swing becomes the fall, the cubes tumble into the floor pipe one after another
- 5.9–7 s the big one is left alone, looks at the pipe, hops in happily and drops in from the top again
- Short film
- 7 s Loop
- 1080 × 1920 · 30 fps
- Canvas 2D
- 422 KB
Prompt
Build a 7-second looping short in portrait 9:16 — stage 1080×1920 CSS px: six little cube characters drop one by one out of a pipe onto a stack, the tower sways harder with every cube, tips over, and they pour into a pipe in the floor; the big one at the bottom hops in last and drops out of the top pipe again, which is frame 0.
DESIGN
Soft, friendly 3D in Canvas 2D on a seamless pastel backdrop (lilac at the top, warm cream towards the floor, a soft light behind the tower, a faint vignette; rendered once and reused so it stays pixel-identical). Camera slightly above the cubes: each cube is a rounded front face (corner radius 24 %) plus a visible top face (a rounded trapezoid, 17 % of the width deep, squashed with the cube, fading out as a cube rolls past 45°, narrower at the back), so a smaller cube on a bigger one shows the bigger one's top around it; it sits centred in depth on the face below. One light from the upper left: front face graded light to dark, lit top-left bevel and shaded bottom-right bevel as offset strokes clipped to the face, a soft specular spot, tinted lilac shadows (no black). Soft contact shadows on the floor and a shadow blob on the top face below each cube; a falling cube's shadow grows as it approaches. Two cream-white cylinders: one hangs from the top edge, its opening seen from below; one stands on the floor to the right, its opening seen from above. Six characters, sizes 176 → 108 px, each with its own face (dark oval eyes with a white catchlight, a mouth made of two curves, soft blush): calm periwinkle with half-closed lids, cheerful mint with an open grin, nervous coral with round eyes and a small "o", smug butter with lidded eyes and a crooked smile, shy pink looking down with strong blush, cheeky sky blue winking with its tongue out. Base framing 1.15×; pipe mouth just below the top 10 %, floor just above the bottom 22 %, nothing important in the right 12 %. No text, no particles, no glow.
STORYBOARD
0–1.6 The big periwinkle cube is already falling (stretched, wide eyes, "o" mouth), lands with a squash, the mint one drops on it; the cubes below look up at each faller and blink as the chain reaches them.
1.6–2.9 Coral, butter and pink land at a steady 0.68 s beat; each landing squashes the newcomer, then each cube below a beat later and a little less; every landing kicks the tower into a slightly bigger wobble.
2.9–4.75 The small blue one slides halfway out of the pipe, looks left and right down at the tower, then drops on top. Two growing swings; all faces turn worried and look towards the lean; the camera pushes in 4 %.
4.75–5.9 The last swing to the right becomes the fall: the column tips over the base's right edge, the cubes come apart and tumble in quarter turns into the floor pipe one after another, nearest first, each flung a little higher the higher it sat; the pipe swells briefly with every one it swallows; the camera eases back.
5.9–7 The big one rocks back flat with a soft thud, looks at the pipe, blinks, crouches, hops in with a happy face and a quarter roll — and drops out of the top pipe again: frame 0.
MOTION
Falls under gravity (9000 px/s²) with stretch growing with speed. Squash is an impact that arrives within two frames and returns critically damped, 1 − (1 + w·t)·e^(−w·t); nothing overshoots. Each level tilts relative to the one below about the corner it leans onto (blocks rock on their edges). Flights are Hermite curves sideways and parabolas vertically, starting from the cube's actual position and speed on the stack and ending in the pipe opening. A cube in a pipe is clipped by the opening minus its near rim band, so it sinks behind a straight line. Faces blend parameter sets (eye opening, lid, squint, mouth width, opening, curve, skew, gaze) per state; breathing and blinks run on whole cycles per 7 s. Motion blur: while a cube falls, flies or the column tips, average whole-frame samples over a 0.35-frame shutter, one per ~4 px of travel.
TECHNIQUE
- One self-contained HTML page plus one JS file (no inline script, no libraries, no network requests). Stage exactly 1080×1080 CSS px, or the size named above (1080×1920 for portrait).
- Expose window.MOTION = { duration, fps: 30, width, height, seek(t) } with the stage size in width and height. seek(t) redraws the frame for time t from scratch: no state between frames, no Math.random (seeded PRNG only), no Date, no CSS transitions, no timers.
- Loop: seek(0) and seek(duration) must look identical.
- With ?render=1 the stage sits unscaled at the top left (for frame capture). Without it, scale the stage to fit the window and loop with requestAnimationFrame.
- prefers-reduced-motion: show one representative still, no loop.
CHECK
Render stills at the listed times, look at every one, fix anything that overlaps, is cut off, aliased or unreadable, then render again. Report only when frame 0 equals the last frame.
Stills: every 0.1 s across the whole clip, crops of the landings at 2× and of the pipe openings at 2×, and frame 0 against frame 7. How to recreate it
-
Give the prompt to a coding agent
Create an empty folder and paste the prompt into Claude Code, Codex or Cursor. The agent writes one HTML page and one script — the animation then runs right in the browser.
-
Let it check the stills
The prompt makes the agent render stills and look at them itself. Only refine what you don't like in the picture: “scene 3 is too busy” works better than a new prompt.
-
Render to MP4
Because every animation can draw any frame exactly through
window.MOTION.seek(t), a small script renders it frame by frame — no stutter, no screen recording. Then ffmpeg joins the frames into a clip.
# 1 · Render every frame (Chrome, Node ≥ 22) node render.mjs http://localhost:3000/ \ frames/ frames 30 # 2 · Join the frames into an MP4 ffmpeg -framerate 30 -i frames/%05d.png \ -c:v libx264 -preset slow -crf 22 \ -pix_fmt yuv420p -movflags +faststart \ my-motion.mp4
Background
Six little cubes with faces drop one by one out of a pipe onto a stack. Every landing squashes the cubes below, the faces blink and squint, the tower sways harder and harder, tips over, and they all tumble into a pipe in the floor. The big one hops in after them and drops out of the top again. 7 seconds, 9:16, built as code, with a prompt to recreate it.
What I learned building it
A stack only feels heavy when a landing squashes more than the newcomer: every cube below gives a beat later and a little less. And blocks don't turn around their centre, they rock over the edge they're leaning onto.
Inspiration
The model was a video by @esch_o ((opens in a new tab)) on TikTok. What I built is my own take on the format, not the video itself; the prompt above describes exactly this version.
More motions
-
An agent platform, introduced UI motion 0:15 -
Agents that pick the model UI motion 0:14 -
A sentence becomes an app UI motion 0:15 -
An operating system, introduced UI motion 0:47.2 -
Your new design partner Voice-over 0:54.3 -
Ten kilometres, floating UGC ad 0:12.6 -
The journey of an order Explainer 0:34 -
Make it move Kinetic typography 0:08 -
From noise to a workflow Particles 0:14 -
The Gimli Glider Voice-over 0:19 -
Oscilloscope intro Oscilloscope 0:20 -
A keystroke in cross-section Explainer 0:20 -
A ring called Orbit UI motion 0:10 -
The bug that wants to stay Short film 0:20 -
Shin, not foot Voice-over 0:17 -
Jellyfish in a light shaft Organic loop 0:18 -
A logo that comes alive Logo reveal 0:08 -
How circles draw any shape Explainer 0:20 -
Pixel wizard Pixel art 0:16 -
The shortest war Voice-over 0:16 -
Loose mosaic wall Mosaic 0:20 -
Near fall Physics simulation 0:09 -
A Negroni, explained Explainer 0:20 -
Where the fuel money goes Voice-over 0:19.5 -
One print, nothing else Title sequence 0:20 -
Infinite zoom into the detail Infinite zoom 0:15 -
A request at 22:47 Chat story 0:17 -
Claude Code in three steps Voice-over 0:17.5 -
The inbox factory Isometric loop 0:12 -
From 0 to 100 % soft Physics simulation 0:10 -
One line, three inks Showreel 0:20 -
The request breaks out Physics simulation 0:15 -
The slicing machine Isometric loop 0:09 -
How backlinks work Explainer 0:20 -
A ball that grows with every bounce Physics simulation 0:10 -
One shape, fourteen states UI motion 0:14 -
What makes a home Paper cut-out 0:20 -
Words that carry Kinetic typography 0:20 -
Shard logo reveal Logo reveal 0:11