Log in to post a comment.

const turtle = new Turtle();

const rectSize = 100; // min=1, max=100, step=1
const rectLooseness = 20; // min=0, max=25, step=1
const rectLooseness2 = 3; // min=0, max=25, step=1
const rectSize2 = 50; // min=1, max=100, step=1
const circleSize = 2; // min=1, max=100, step=1
const circleLooseness = 33; // min=0, max=25, step=1
const totalLines = 1111; // min=1, max=2000, step=1

const density = 20;
const outerScale = 20;
const size = 90;
const _size = outerScale - size;
const stops = Array.from(new Array(Math.ceil(72*density)), x => size * Math.random());
let lastStop;

const lerp = (from,to, t) => from + (to - from) * t;
const or = (a, b) => Math.random() < 0.75 ? a : b;
const getLooseness = (amount) => lerp(-amount * 0.5, amount * 0.5, Math.random());

const getCircleEdge = radius => {
    const angle = Math.PI * 0.42 * Math.random();
    return [
        Math.sin(angle) * radius, 
        Math.cos(angle) * radius
    ]
}

function getSquareEdge(a, b) {
    const rect = [
        lerp(a, b, Math.random()),
        or(a, b)
    ];
    if (Math.random() > 0.9) rect.push(rect.shift());
    return rect;
}

function getSquareEdge2(a, b) {
    const rect2 = [
        lerp(a, b, Math.random()),
        or(a, b)
    ];
    if (Math.random() < 0.9) rect2.push(rect2.shift());
}

function walk(step) {
    turtle.goto( getSquareEdge(-rectSize + getLooseness(rectLooseness), rectSize + getLooseness(rectLooseness)) );
    turtle.goto( getSquareEdge2(-rectSize2 + getLooseness(rectLooseness2), rectSize2 + getLooseness(rectLooseness2)) );
    turtle.jump( getCircleEdge(circleSize + getLooseness(circleLooseness)) );
    return step < totalLines;
}