Jellyfish in a light shaft
Nature footage from code: translucent jellyfish, each on its own rhythm
- 0–5 s a large jellyfish rises through the foreground, close past a smaller one
- 5–9 s two jellyfish meet in mid water, one crossing behind the other's tentacles
- 9–12.5 s a light shaft finds a bell near the surface, caustics and gonads light up
- 12.5–15.5 s the shaft wanders on and lifts a distant swarm out of the haze
- 15.5–18 s the swarm dissolves, the next bell rises from below – back to the first frame
- Organic loop
- 18 s Loop
- 1080² · 30 fps
- Canvas 2D
- 2.3 MB
Prompt
Build an 18-second seamless loop, 1080×1080, in Canvas 2D and plain JavaScript (no libraries, no image, font or audio files): translucent jellyfish in deep petrol-blue water, shot like a nature film. No text in the picture.
DESIGN
Water: a vertical gradient from #0B5661 at the top to #021E27 at the bottom, a wide cyan glow from above left, a faint coral glow from below right, dithered against banding, a soft dark vignette. Four slanted cyan light shafts drift slowly sideways; each is a broad soft body with two narrower rays breathing inside it, fading out towards the depth.
Jellyfish in depth layers: one near and large (bell radius 166 px, sharp), one in mid water (86 px, sharp), one slightly behind it (62 px, a little soft), three far ones (27–34 px, pale, blurred) and a swarm of nine tiny ones that only appears for a few seconds. Far ones are drawn on low-resolution layers and blurred; every animal is composited onto the water with "screen".
The bell is a real body, not an outline: a cap of revolution seen slightly from below, with an outer and an inner wall (thick clear jelly at the crown, thin at the margin), 16 radial canals (every other one forks towards the margin on the large animal), four ruffled coral gonad rings around the crown joined by a stomach cross, a margin line that ripples, a short velum with 16 lappets, and a small cyan light in every notch. Light gathers at the edges: wide soft strokes clipped to the bell, cyan on the lit side, coral on the far side. Two families of wandering caustic lines shimmer on the upper bell, a soft sheen sits on the crown, and a faint cyan body of light surrounds each bell. Four oral arms hang from a short stalk as ruffled, translucent coral ribbons. 16–28 hair-thin tentacles per animal, pale cyan at the root and coral towards the tip, with tiny knots on the large one.
Marine snow in three layers: far specks, mid specks, a few large out-of-focus discs in front. Each particle fades in, sinks and drifts for one loop, and brightens inside a light shaft.
STORYBOARD
0–5 s The large jellyfish rises from the lower right through the foreground, heading up and left, passing close to the mid-water one; the third enters from the right edge.
5–9 s The large one leaves at the top left, its tentacles trailing across the frame. The two smaller ones meet in mid water: one climbs, the other crosses behind its tentacles.
9–12.5 s The brightest light shaft comes to rest on the climbing bell near the surface: caustics, gonads and crown light up; then it banks into a turn and one strong stroke carries it out through the upper right.
12.5–15.5 s The shaft wanders on to the left. The crossing jellyfish shrinks and blurs as it swims away, and a swarm of tiny jellyfish lifts out of the haze where the light now falls.
15.5–18 s The swarm dissolves, the mid-water jellyfish rises again from below, the crown of the large one reaches the bottom edge — the first frame.
MOTION
One pulse curve for all: the bell squeezes in 15 % of the period and recovers over the next 80 %. Thrust is the positive rate of that squeeze; speed is the periodic solution of v' = thrust − drag·v, so each stroke gives a lunge and a glide. Every animal has its own period (the loop divided by 6, 7, 8, 9, 10 or 12) and phase. The margin lags the bell by 5 % of the period, the velum by 12 %, and the bell nods slightly into each stroke.
Each jellyfish owns an endless path: integrate speed along a gently swaying heading over one loop into a table and remember the displacement per loop. Draw the copies at t − 18, t and t + 18; large animals wrap off screen, far ones while they are faded into the haze, so the loop closes by construction.
Tentacles and oral arms are not simulated: each link samples the bell's own past — position, heading and margin width — with a delay that grows along the chain, the squeeze rounded off and damped further down, plus a travelling sway and a slow common drift. They stretch after each stroke and catch up during the glide.
Marine snow knows when a bell passes closest and how near; from that moment it is dragged along the bell's heading in steps, pulled towards the wake, then released. The camera drifts a few pixels, nearer layers moving more. The margin lights flash with each stroke, running round the rim, and fade while the bell refills.
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 second from 0 to 18, every 0.1 s around 5, 9, 12.5 and 15.5 and from 17.5 to 0.5, plus 2× crops of the large bell at 3.4 and 4.0 and a 3× crop of the lit bell at 10.6. 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
Translucent jellyfish in deep petrol-blue water: the bells squeeze quickly and recover slowly, every stroke gives a lunge forward, tentacles and oral arms trail behind with a delay. Cyan light shafts wander through the frame, marine snow drifts in three depth layers. 18 seconds of Canvas 2D, no library, with the prompt.
What I learned building it
The motion becomes believable not through a simulation but through the right order: first the stroke, from it the speed, from that the path. The tentacles then only sample that path with a delay. Every frame stays computable, and the loop closes by itself.
Inspiration
The starting point was a prompt by @AntSeed ((opens in a new tab)) on Skillry. You'll find the original wording there; the prompt above is my own 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 -
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 -
Cube stack Short film 0:07 -
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