Instantly share code, notes, and snippets.

Embed
What would you like to do?
DrawBot: Generate a progress-spinner-like animation with growing circles.
# 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