Unknown Turtles

An homage.

Log in to post a comment.

Canvas.setpenopacity(-1);

const turtle = new Turtle();
const height = 10;
const width = 50;
const zstart = 70;
const layer = 2;
const layers = 80;
const perspective = 0.15;
turtle.penup();

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