eye eye eye

I can see what you do in the shadows

Log in to post a comment.

Canvas.setpenopacity(-0.2);

const t = new Turtle();

const alpha = 0.15
const mind = 0.5

function subdivide(x1, y1, x2, y2) {
    let dx = x2 - x1, dy = y2 - y1
    let cx = (x1 + x2) / 2, cy = (y1 + y2) / 2
    let a = alpha * (Math.random() * 2 - 1)
    
    return [cx + a * dy, cy - a * dx]
}

function draw(x1, y1, x2, y2) {
    if ((x1 - x2)**2 + (y1 - y2)**2 < mind**2) {
        t.jump(x1, y1)
        t.goto(x2, y2)
    }
    else {
        [nx, ny] = subdivide(x1, y1, x2, y2)
        
        draw(x1, y1, nx, ny)
        draw(nx, ny, x2, y2)
    }
}

const R1 = 20, R2 = 45
const dphi = Math.PI / 101 / 3

let shift = R2 / 2

for (let phi = 0; phi < 2 * Math.PI; phi += dphi) {
    draw(R1 * Math.cos(phi) - 50, R1 * Math.sin(phi) - shift, R2 * Math.cos(phi) - 50, R2 * Math.sin(phi) - shift)
}

for (let phi = 0; phi < 2 * Math.PI; phi += dphi) {
    draw(R1 * Math.cos(phi) + 50, R1 * Math.sin(phi) - shift, R2 * Math.cos(phi) + 50, R2 * Math.sin(phi) - shift)
}

const R3 = 1.8 * R2, R4 = 0.5 * R2
let cy = 100 - (100 - R2) / 2

for (let phi = 0; phi < 2 * Math.PI; phi += dphi / 2) {
    draw(0, cy - shift, R3 * Math.cos(phi), cy + R4 * Math.sin(phi) - shift)
}

const R5 = R1 / 5

for (let phi = 0; phi < 2 * Math.PI; phi += dphi * 16) {
    t.jump(-2 * R5 + R5 * Math.cos(phi), 0.8 * R2 - shift + R5 * Math.sin(phi))
    t.goto(-2 * R5 + (R5 + 1) * Math.cos(phi), 0.8 * R2 - shift + (R5 + 1) * Math.sin(phi))

    t.jump(2 * R5 + R5 * Math.cos(phi), 0.8 * R2 - shift + R5 * Math.sin(phi))
    t.goto(2 * R5 + (R5 + 1) * Math.cos(phi), 0.8 * R2 - shift + (R5 + 1) * Math.sin(phi))
}

/*const R6 = 110, R7 = 150

for (let phi = 0; phi < 2 * Math.PI; phi += dphi * 4) {
    draw(R6 * Math.cos(phi), R6 * Math.sin(phi), R7 * Math.cos(phi), R7 * Math.sin(phi))
}*/