Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@justvanrossum
Created September 23, 2016 15:37
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 justvanrossum/3d39639f5fef54dfd630a5bc9fadc06c to your computer and use it in GitHub Desktop.
Save justvanrossum/3d39639f5fef54dfd630a5bc9fadc06c to your computer and use it in GitHub Desktop.
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