Skip to content

Instantly share code, notes, and snippets.

@agyeiarcher
Created January 16, 2018 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agyeiarcher/40fa552a942d5b6ba1458a344c04be84 to your computer and use it in GitHub Desktop.
Save agyeiarcher/40fa552a942d5b6ba1458a344c04be84 to your computer and use it in GitHub Desktop.
Rotating Squares
BG = 1500
NSQUARES = 50
SQUARESIZE = 2000
NFRAMES = 96
TOTALROTATION=15
for frame in range(NFRAMES):
newPage(BG,BG)
frameDuration(1/24)
phase = 2 * pi * frame / NFRAMES #angle in radians
print sin(phase)
#perfectly distribute rotation across frames
STARTANGLE = TOTALROTATION * sin(phase)
ENDANGLE = TOTALROTATION * sin(phase +0.5*pi)
fill(0)
stroke(1)
strokeWidth(10)
#generate pile of squares
translate(BG/2, BG/2)
for i in range (NSQUARES+1):
SQUARESIZE = SQUARESIZE
f = i/NSQUARES
save()
rotate(STARTANGLE + f*(ENDANGLE-STARTANGLE))
rect(-SQUARESIZE/2, -SQUARESIZE/2, SQUARESIZE, SQUARESIZE)
scale(0.9, 0.9)
saveImage("rotatingsquares.mp4")
#made after Just van Rossum's tutorial: https://vimeo.com/149247423
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment