waves

Some simple periodic lines

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax

// Global code will be evaluated once.
const t = new Turtle();
t.penup();
t.goto(-50,-20);
t.pendown();

const w = 1<<9;
const h = 1<<9;
const scl = 200/w;
let ang = 0;
function rx(nx) {return (((nx+0.5)/w)-0.5)*200}
function line(x0,y0,x1,y1) {
    t.jump(rx(x0), rx(y0));
    t.goto(rx(x1),rx(y1));
}

const N = 100;
function* draw() {
    for (let y = 0; y < 2*N; y++) {
        for (let x = 0; x < N; x++) {
            let x0 = w/(2*N+1)*(1+2*x)
            let y0 = h/(2*N)*(1+y)
            line(x0,y0,x0+w/(2*N+1)*(1+0.8*Math.sin((x*x*x/4000+y)/8)),y0)
            
        }
    }
}

const di = draw();
// The walk function will be called until it returns false.
function walk(i) {
    return !di.next().done
}