Skip to content

Instantly share code, notes, and snippets.

@justvanrossum
Last active June 28, 2019 05:50
Show Gist options
  • Save justvanrossum/19cf56af4ccb2477a868 to your computer and use it in GitHub Desktop.
Save justvanrossum/19cf56af4ccb2477a868 to your computer and use it in GitHub Desktop.
Generate a blobby animated gif with DrawBot.
# FREQUENCY = 1
# http://dailydrawbot.tumblr.com/post/135252661206/the-blob
# FREQUENCY = 2
# http://dailydrawbot.tumblr.com/post/135266061309/the-blob-2
def centerOval(pt, radiusX, radiusY):
x, y = pt
oval(x - radiusX, y - radiusY, 2 * radiusX, 2 * radiusY)
CANVAS = 500
RADIUS = 0.38 * CANVAS
STEPS = 130 # try 13
VIEWANGLE = radians(35)
FREQUENCY = 1
AMPLITUDE = 0.15
NFRAMES = 50
for frame in range(NFRAMES):
newPage(CANVAS, CANVAS)
frameDuration(1/20)
fill(0.0)
rect(0, 0, CANVAS, CANVAS)
strokeWidth(0.8)
fill(1)
translate(CANVAS/2, CANVAS/2)
for i in reversed(range(STEPS)):
fill(1-i/STEPS)
angle = pi * (i + 0.5) / STEPS
r = RADIUS * sin(angle)
waveAngle = FREQUENCY * (2 * pi * (i / STEPS + frame/NFRAMES))
wave = 1 + AMPLITUDE * sin(waveAngle)
save()
translate(0, wave * cos(VIEWANGLE) * RADIUS * cos(angle))
r = wave * r
centerOval((0, 0), r, r * sin(VIEWANGLE))
restore()
if NFRAMES > 20:
saveImage("TheBlob-f%s.gif" % FREQUENCY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment