Fork: Unknown Turtles

An homage.

Log in to post a comment.

// Forked from "Unknown Turtles" by maraz
// https://turtletoy.net/turtle/ca12448d34

Canvas.setpenopacity(-1);

const turtle = new Turtle();
const height = 10;
const width = 50;
const zstart = 70;
const layer = 2;
const layers = 80;  //min=20 max=300 step=1
const gap = 1; //min=0.25 max=2 step=0.1
const roughness = 0.5 //min=0.0 max=2 step=0.1
const perspective = 0.15;
const peak = 1 //min=0 max=5 step=0.1
turtle.penup();

function walk(i) {
    const left = -width+perspective*i*gap;
    const right = width-perspective*i*gap;
    const z = zstart-layer*i*gap;
    turtle.goto(left, z);
    for (let n = left; n < right; n++) {
        if (Math.random() > 0.5) {
            const maxh = height-Math.random()*roughness;
            const h = z+maxh*Math.log10(Math.abs(turtle.x())+peak);
            turtle.goto(n, h);
            turtle.pendown();
        }
    }
    turtle.penup();
    turtle.goto(right, z);
    return i < layers;
}