Created
September 23, 2016 15:37
-
-
Save justvanrossum/3d39639f5fef54dfd630a5bc9fadc06c to your computer and use it in GitHub Desktop.
DrawBot: Generate a progress-spinner-like animation with growing circles.
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
# Result: | |
# http://dailydrawbot.tumblr.com/post/150807743869/growing-circles | |
def circle(pt, radius): | |
diameter = 2 * radius | |
x, y = pt | |
oval(x - radius, y - radius, diameter, diameter) | |
nFrames = 50 | |
canvasSize = 500 | |
radius = 0.27 * canvasSize | |
nCircles = 12 | |
for i in range(nFrames): | |
framePhase = i / nFrames | |
newPage(canvasSize, canvasSize) | |
frameDuration(1/20) | |
fill(0) | |
rect(0, 0, canvasSize, canvasSize) | |
translate(canvasSize/2, canvasSize/2) | |
for i in range(nCircles): | |
circlePhase = i / nCircles | |
a = 2 * pi * circlePhase | |
x = radius * cos(a) | |
y = radius * sin(a) | |
cr = ((circlePhase + framePhase) % 1) | |
fill(1, (1 - cr) ** 0.7) | |
circle((x, y), cr * 110) | |
saveImage("GrowingCircles.gif") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment