Skip to content

Instantly share code, notes, and snippets.

@pents90
Created February 24, 2016 22:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pents90/10bf3b84aea6b16dde8b to your computer and use it in GitHub Desktop.
Save pents90/10bf3b84aea6b16dde8b to your computer and use it in GitHub Desktop.
Drawbot animation that takes advantage of the strange aliasing effects of quantized trigonometric functions. The result is here: https://twitter.com/pents90/status/701557854147362817
# DrawBot
import math;
SIZE = 512
FRAMES = 120
STEP = 8
size(SIZE,SIZE)
for t in xrange(0, FRAMES):
fill(0,0,0)
rect(0,0,SIZE,SIZE)
for x in xrange(0, SIZE, STEP):
tx = math.cos(x * math.pi * 2 / SIZE + math.pi) + 1
for y in xrange(0, SIZE, STEP):
ty = math.cos(y * math.pi * 2 / SIZE + math.pi) + 1
if (math.sin(tx * (t + 1) * ty) < 0):
fill(0,0,0)
else:
fill(1,1,1)
rect(x,y,STEP,STEP)
if (t < FRAMES - 1):
newPage()
saveImage(u"~/Desktop/animation.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment