Gridism ◻️

Use the sliders to make variations of the artwork.

Log in to post a comment.

const turtle = new Turtle();

const grid = 23; // min=5, max=75, step=2
const density = .4; // min=0.05, max=1.0, step=0.01
const length = 6; // min=3, max=15, step=1
const spacing = 3; // min=0, max=50, step=0.1
const lines = 15; // min=1, max=50, step=1
const size = 7/9 * 200 / grid;

function getX(x) { return x - (grid/2|0) - 0.5 };
function getY(y) { return y - (grid/2|0) - 0.5 };

function walk(i) {
    const x = getX(i % grid);
    const y = getY(i / grid | 0);
    if (density > Math.random()) {
        for (let idx = 0; idx < lines; idx++) {
            let r = Math.max(0,Math.min((-0.5+Math.random()) * length | 0, grid / 2 - x)) * size;
            let t = idx/lines;
            turtle.jump(size * x, size * y + t*spacing);
            turtle.goto(size * x + r, size * y + t*spacing);
        }
    }
    if (density > Math.random()) {
        for (let idx = 0; idx < lines; idx++) {
            let r = Math.max(0,Math.min((-0.5+Math.random()) * length | 0, grid / 2 - y)) * size;
            let t = idx/lines;
            turtle.jump(size * x + t*spacing, size * y);
            turtle.goto(size * x + t*spacing, size * y + r);
        }
    }
    return i < grid * grid - 1;
}