Dev.to AI 🤖 Ai 👁 0 📖 3 min read

The Math Behind an Infinite Zoom: Planning Nested Frames So the Loop Never Breaks

An infinite zoom is a sequence of images where each new picture lives inside the centre of the previous one. Play them back with a smooth scale and the camera seems to fall forward forever. It looks like magic, but it is

An infinite zoom is a sequence of images where each new picture lives inside the centre of the previous one. Play them back with a smooth scale and the camera seems to fall forward forever. It looks like magic, but it is really just a bit of geometry plus some careful prompt planning. Here is how I think about it.

1. Every frame is the previous frame, scaled down

Pick a zoom factor k, for example 2. Frame n+1 is pasted into the centre of frame n at 1/k of its width. During playback you scale the whole stack continuously from 1x to kx, and the moment you reach kx the inner frame fills the screen. That is the cut point, and nobody notices it because the picture on screen hasn't changed.

def frame_scale(t, k=2.0, frames=8):
    """t in [0, 1) over the whole video -> (frame index, scale of that frame)."""
    pos = t * frames                 # which hand-off we are in
    i = int(pos)
    local = pos - i                  # 0..1 inside this hand-off
    return i % frames, k ** local    # geometric, not linear, growth

The detail that trips people up is the growth curve. Scale has to grow geometrically (k ** local), not linearly. A linear ramp makes each hand-off speed up and then stall, and the viewer feels a little "bump" at every seam.

2. The centre of each frame is reserved

Because the next scene is pasted into the middle 1/k of the frame, that area is effectively a window. When you describe a scene, plan what sits there:

  • a doorway, a window, a picture frame, a pupil, a coin, a screen
  • something with a clear edge, so the inner image has a natural border
  • not text, and not a busy texture, which will show the seam

3. One connecting detail per hand-off

Write the whole path as one line before generating anything:

mountain valley -> cabin window -> desk by the window -> photo on the desk -> face in the photo

Each arrow is a hand-off, and each one needs a single object that exists in both scenes. Describe that object with the same words (colour, material, shape) in both prompts. That repetition is what makes two separately generated images read as one continuous shot.

4. Keep light and palette locked

Choose one light direction and three or four colours for the whole chain. Geometry can line up perfectly and the loop will still feel broken if frame 4 is warm sunset and frame 5 is cold noon.

5. Close the loop

For a true loop, the last scene's centre should contain the first scene. A good trick is to let the final detail be an object that already appeared, small, in frame 1. Then i % frames in the function above wraps around cleanly.

6. Test as thumbnails

Before final renders, lay all frames out as small thumbnails in a row. At that size you only see shapes and colours, which is exactly what the eye tracks during a fast zoom. Any frame whose central shape jumps is the one to regenerate.

Tooling

You can do all of this by hand: generate each frame with your favourite image model, then composite and animate with a short script (Pillow plus ffmpeg is enough). If you'd rather skip the compositing, Infinite Zoom Art takes a list of scene descriptions and builds the looping zoom in the browser. Either way, the planning steps above are what decide whether the result feels seamless.

Summary

  • Pick a zoom factor and grow scale geometrically.
  • Reserve the centre of every frame for the next scene.
  • One shared, identically described detail per hand-off.
  • Fixed light direction and palette.
  • Last frame contains the first.
  • Check the chain as thumbnails.

If you try this, I'd love to see the path you wrote down. More looping zoom examples are on Infinite Zoom Art.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.