A grid of animated spirals



  • 0_1520364143306_SpiralGrid2-clean.gif

    def spiral(cx, cy, diameter, angle):
        with savedState():
            translate(cx, cy)
            scale(diameter / 1000)
            for i in range(100):
                rect(406, 0, 95, 95)
                rotate(angle)
                scale(0.99)
    
    gridSize = 100
    margin = 50
    canvasSize = 500
    numFrames = 40
    
    for frame in range(numFrames):
        t = frame / numFrames
        newPage(canvasSize, canvasSize)
        frameDuration(1/20)
        fill(0)
        rect(0, 0, canvasSize, canvasSize)
        fill(1)
        translate(margin, margin)
        for i in range(5):
            for j in range(5):
                a = 2 * pi * (t + (i + j) / 8)
                angle = 31 + 2 * sin(a)
                spiral(i*gridSize, j*gridSize, 95, angle)
    
    saveImage("~/Desktop/SpiralGrid.gif")
    

Log in to reply