Skip to content
Blur the bits.
← Back to shelvesThe Bitbrary
Motion notebook · Edition 2

Four seconds in orbit

Make a loop you can render again

For a repeating orbit, choose the length before placing the object. Render frames 0 through 95. The next frame returns to phase zero, so the first pose only appears once per cycle.

From the source

The BitBlur example renders 96 frames at 24 fps with Python. A phase change or a new colour can be rendered from the same script.

Inspect orbit.py ↗

Try it

  1. Save orbit.py and the Python check below in the same folder. Name the check check_orbit.py and run python check_orbit.py. It runs in landscape and portrait before any video is encoded.
  2. Compare the 96-frame export with a deliberately faulty 97-frame version. The check compares adjacent frames and wraps the last frame back to the first.
  3. Encode frames 0 through 95 with python orbit.py loop.mp4. Play it through twice to judge the speed of the crest as it crosses the seam.
from orbit import render

for size in [(320, 180), (180, 320)]:
    frames = [render(i, *size) for i in range(97)]
    assert frames[96] == frames[0]

    def holds(seq):
        return [i for i, frame in enumerate(seq)
                if frame == seq[(i + 1) % len(seq)]]

    assert holds(frames[:96]) == []
    assert holds(frames) == [96]
    print(size, "passed")

Both sizes pass. Frame 96 proves the orbit returns to its starting pose. Including it in the movie holds that pose for one extra frame at the restart, about 42 ms at 24 fps. The check catches a duplicate frame. A loop can still change speed abruptly even when every frame is different.

Production notes ↗