Skip to content

Instantly share code, notes, and snippets.

@eliheuer
Created January 22, 2016 04:32
Show Gist options
  • Save eliheuer/a30e451f9be37c81f22b to your computer and use it in GitHub Desktop.
Save eliheuer/a30e451f9be37c81f22b to your computer and use it in GitHub Desktop.
# Eli Heuer's daily DrawBot exercise!
# 01/21/16 -- 001
# Rendered with DrawBot:
# http://www.drawbot.com/
# setting up the canvas and main variables
canvas = 512 # size of the gif in pixels
square_size = 128 # size of the square
num_frames = 64 # number of frames in the animation
step = 0 # steps in looping animation
# main loop that makes each frame
for frame in range(num_frames):
newPage(canvas, canvas)
frameDuration(1/20)
fill(0.8)
rect(0, 0, canvas, canvas)
phase = 2 * pi * frame / num_frames
x_pos = 180 * sin(phase + 1 * pi)
y_pos = 180 * cos(phase + 1 * pi)
translate(canvas/2, canvas/2)
print "x_pos: "
print x_pos
print "y_pos: "
print y_pos
# animation loop
for frame in range(num_frames):
save()
step = step + 8
fill(1)
stroke(0.2)
rotate(step)
translate(x_pos / 2, y_pos)
rect(-square_size/2, -square_size/2,
64, 32)
restore()
saveImage("ehdb_01_21_16_001.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment