Lissajous curves

Some Lissajous curves: https://en.wikipedia.org/wiki/Lissajous_curve

Created by reinder on 2018/11/19
256
0

Log in to post a comment.

// Lissajous curves. Created by Reinder Nijhoff 2018
// @reindernijhoff
//
// https://turtletoy.net/turtle/982e9ce2ae
//

Canvas.setpenopacity(.5);

const div = 11;
const steps = 1000;
const turtles = [];
const s = 200;

for (let x=0; x<div; x++) {
    for (let y=0; y<div; y++) {
        turtles.push(new Turtle((x + .5) * s/div - s/2, (y + .9) * s/div - s/2));
    }
}

function walk(i) {
    for (let x=0; x<div; x++) {
        for (let y=0; y<div; y++) {
            turtles[y+x*div].goto( 
                (x + .5 + .4 * Math.sin((x+1)*i*2*Math.PI/steps)) * s/div - s/2, 
                (y + .5 + .4 * Math.cos((y+1)*i*2*Math.PI/steps)) * s/div - s/2);
        }
    }
    return i < steps;
}