adjustable Willmott squares

Based on

turtletoy.net/turtle/753891e78f

Created by zoso95 on 2019/8/13
Forked from Willmott squares
62
0

Log in to post a comment.

Canvas.setpenopacity(1);


let x_freq = 1.1; // min=0, max=10, step=0.1
let y_freq = 12.5; // min=0, max=20, step=0.5
let x_scale = 150; // min=0, max=200, step=10
let y_scale = 25; // min=0, max=200, step=10


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

const width=195;
const height=195;
const cubesPerSide=40;
const cubeSpacing=width/(cubesPerSide);
const cubeSize=width/(cubesPerSide*0.95);
const minX=-(width)/2 ;
const minY=-(height)/2;

// The walk function will be called until it returns false.
function walk(i) {
    for(let y=0;y<cubesPerSide;++y) {
        for(x=0;x<cubesPerSide;++x) {
            turtle.penup();
            turtle.goto(minX+x*cubeSpacing+cubeSpacing/2,minY+y*cubeSpacing+cubeSpacing/2);
            
            // play with these numbers to get new effects! DO IIIIIIT~~~!
            turtle.setheading(
                Math.sin(x_freq*x/cubesPerSide)*x_scale
                +Math.cos(y_freq*(x+y)/cubesPerSide)*y_scale);
                
            turtle.forward(cubeSize/2); turtle.right(90);
            turtle.pendown();
            turtle.forward(cubeSize/2); turtle.right(90);
            turtle.forward(cubeSize); turtle.right(90);
            turtle.forward(cubeSize); turtle.right(90);
            turtle.forward(cubeSize); turtle.right(90);
            turtle.forward(cubeSize/2); 
        }
    }
    return false;
}