Skip to content

Instantly share code, notes, and snippets.

@eliheuer
Created January 20, 2016 00:13
Show Gist options
  • Save eliheuer/3a4d77b2ef5fdb45814e to your computer and use it in GitHub Desktop.
Save eliheuer/3a4d77b2ef5fdb45814e to your computer and use it in GitHub Desktop.
# Eli Heuer's daily DrawBot exercise!
# 01/19/16 -- 001
# Rendered with DrawBot:
# http://www.drawbot.com/
# This code started from this tutorial screencast:
# https://vimeo.com/149247423
# Thanks to Just van Rossum
# 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
# 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 = 90 * sin(phase)
y_pos = 90 * sin(phase + 0.5 * pi)
translate(canvas/2, canvas/2)
# animation loop
for frame in range(num_frames):
save()
fill(1)
stroke(0.2)
rotate(frame*8)
translate(x_pos, y_pos)
rect(-square_size/2, -square_size/2,
square_size, square_size)
restore()
saveImage("ehdb_01_19_16_002.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment