# Rewriting this this in python: # https://gist.github.com/beesandbombs/2abe9464e2f43e75807879036a1962ca import math recording = False result = None N = 16 ia = math.atan(math.sqrt(.5)) samplesPerFrame = 4 numFrames = 136 shutterAngle = .6 def setup(): global result, recording pixelDensity(1 if recording else 2) result = [[0 for j in range(3)] for x in range(width*height)] size(720, 720, P3D); smooth(8) rectMode(CENTER) colorMode(HSB, 1) noFill() strokeWeight(1.5) def push(): pushMatrix() pushStyle() def pop(): popStyle() popMatrix() def _draw(t, c): background(0); push() translate(width / 2, height / 2) rotateX(-ia) rotateY(QUARTER_PI) for i in range(0, N): stroke((i / float(N) + t) % 1, 1, 1) push() rotateY(QUARTER_PI * sin(TWO_PI * t - .75 * PI * i / N)) box(80 + 15 * i) pop() pop() def draw(): global recording, result if recording: for i in range(0, width * height): for a in range(0, 3): result[i][a] = 0 c = 0; for sa in range(0, samplesPerFrame): t = map(frameCount - 1 + sa * shutterAngle / samplesPerFrame, 0, numFrames, 0, 1) _draw(t, c); loadPixels(); for i in range(0, len(pixels)): result[i][0] += pixels[i] >> 16 & 0xff result[i][1] += pixels[i] >> 8 & 0xff result[i][2] += pixels[i] & 0xff loadPixels(); for i in range(0, len(pixels)): pixels[i] = 0xff << 24 | \ int(result[i][0] * 1.0 / samplesPerFrame) << 16 | \ int(result[i][1] * 1.0 / samplesPerFrame) << 8 | \ int(result[i][2] * 1.0 / samplesPerFrame); updatePixels() saveFrame("f###.gif") if frameCount == numFrames: exit() else: t = mouseX * 1.0 / width; c = mouseY * 1.0 / height; _draw(t, c);