Looking for meaning

Order out of chaos

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(-0.05);

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

let q;
let s;
let d;

const tri = () => {
    turtle.penup();
    turtle.home();
    turtle.pendown();
    const x = 40
    const a = 360
    turtle.right(Math.random()*a)
    turtle.forward(x)
    q = turtle.pos()
    turtle.right(Math.random()*a)
    turtle.forward(x)
    s = turtle.pos()
    turtle.right(Math.random()*a)
    turtle.forward(x)
    d = turtle.pos()
}

const precision = 1

// The walk function will be called until it returns false.
function walk(i) {
    tri()
    if (i > 10000) {
        return false
    
    }
    const dx = Math.abs(turtle.x())
    const dy = Math.abs(turtle.y())
    const bbb = dx > precision || dy > precision
    
    if (bbb === false) {
        pos = turtle.pos()
        for (var j = 0; j < 1000; j++){
            turtle.goto(d[0], d[1])
            turtle.goto(s[0], s[1])
            turtle.goto(q[0], q[1])
        }
    }
    console.log(i)
    return bbb
}