Skip to content

Instantly share code, notes, and snippets.

@justvanrossum
Created December 3, 2020 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justvanrossum/37aa4dd028afa73cc67e26527eb670c0 to your computer and use it in GitHub Desktop.
Save justvanrossum/37aa4dd028afa73cc67e26527eb670c0 to your computer and use it in GitHub Desktop.
# boring version of https://twitter.com/beesandbombs/status/1334541858366775298
# <3 beesandbombs!
canvasSize = 800
numFrames = 50
numSquares = 50
radius = 0.3 * canvasSize
squareSize = 0.2 * canvasSize
for frame in range(numFrames):
newPage(canvasSize, canvasSize)
frameDuration(1/25)
fill(1)
rect(0, 0, canvasSize, canvasSize)
translate(canvasSize/2, canvasSize/2)
stroke(0)
strokeWidth(2)
for i in range(2):
path = BezierPath()
path.rect(i * -canvasSize/2, -canvasSize/2, canvasSize/2, canvasSize)
with savedState():
clipPath(path)
for j in range(numSquares):
if not i:
j += numSquares / 2
angle = tau * j / numSquares
x = radius * cos(angle)
y = radius * sin(angle)
with savedState():
translate(x, y)
rotate(-90 * frame / numFrames + 90 * j / numSquares)
rect(-squareSize/2, -squareSize/2, squareSize, squareSize)
saveImage("CircleOfSquares.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment