Created
January 2, 2016 22:51
-
-
Save eliheuer/c9fea033beb6b0018c92 to your computer and use it in GitHub Desktop.
Daily Python kata rendered with Drawbot
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
# fork of -- https://gist.github.com/justvanrossum/19cf56af4ccb2477a868 | |
# from http://dailydrawbot.tumblr.com/ | |
#rendered 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 = 512 | |
RADIUS = 0.38 * CANVAS | |
STEPS = 13 # 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.2) | |
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, 1-i/STEPS, 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