Everything is connected

Walking arcs around circles, saving starting points for the next layer. Only drawing a third of a circle with a low opacity pen creates a nice sketched effect.

Log in to post a comment.

const size = 8;
const sizeStep = 0.1;
const iterations = 20;

const turtle = new Turtle();
const positions = [{x:-size, y: 0, h: 180, r: size, d: 0}];
const savePos = (x, y, h, r, d) => {
    const xr = Math.round(x);
    const yr = Math.round(y);
    if (!positions.find(p => p.x==xr && p.y==yr)) {
        positions.splice(0, 0, {x: xr, y: yr, h, r, d});
    }
}
const getLastPos = () => positions.pop();

Canvas.setpenopacity(0.1);

function walk(i) {
    const lastPos = getLastPos();
    if (lastPos.d > iterations) return false;
    turtle.penup();
    turtle.goto(lastPos.x, lastPos.y);
    turtle.seth(lastPos.h+180);
    turtle.pendown();
    for (let n = 0; n < 2; n++) {
        for (let angle = 0; angle < 60; angle++) {
            turtle.right(1);
            turtle.forward(lastPos.r*Math.PI/180);
        }
        savePos(turtle.x(), turtle.y(), turtle.h(), lastPos.r+sizeStep, lastPos.d+1);
    }
    return true;
}