Created
January 16, 2018 22:44
-
-
Save agyeiarcher/40fa552a942d5b6ba1458a344c04be84 to your computer and use it in GitHub Desktop.
Rotating Squares
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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