Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DrawBot: create a grid of Lissajous curve variations.
# http://dailydrawbot.tumblr.com/post/160078796339/lissajous-grid
# remade from https://twitter.com/fermatslibrary/status/857580490425020416
def lissajous(a, b, phase, radius):
numSteps = 340
points = []
for i in range(numSteps):
angle = 2 * pi * i / numSteps
x = radius * sin(a * angle + phase)
y = -radius * sin(b * angle)
points.append((x, y))
return points
canvasSize = 500
numFrames = 72
numShapes = 5
gridSize = canvasSize / numShapes
radius = 0.375 * gridSize
for frame in range(numFrames):
t = frame / numFrames
newPage(canvasSize, canvasSize)
frameDuration(1/20)
fill(1)
rect(0, 0, canvasSize, canvasSize)
stroke(0)
strokeWidth(2)
lineJoin("round")
fill(None)
for a in range(1, numShapes + 1):
for b in range(1, numShapes + 1):
save()
translate(gridSize * a - 0.5 * gridSize,
canvasSize - gridSize * b + 0.5 * gridSize)
points = lissajous(b, a, 2 * pi * t, radius)
polygon(*points)
restore()
saveImage("LissajousGrid.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.