Eyeballs

Quick one.
Exports to a googly GIF.

Log in to post a comment.

// LL 2021

const turtle = new Turtle();

const angle1 = 0.4; // min=0 max=1 step=0.01
const angle2 = 0.;  // min=0 max=1 step=0.01
const offset = 0.5; // min=0 max=1.1 step=0.01
const iris = 0.25;  /// min=0.01 max=1 step=0.01

function walk(i, t) {
    const angles = [angle1+t, angle1-angle2-t];
    const list = [], circles = [];
    [0, 1].forEach(e => {
        const cx = 35 - e * 70, cy = 0, r = 40;
        const cx2 = cx + r * offset * Math.cos(angles[e] * Math.PI * 2) + r * iris ** 1.5 * Math.cos(-Math.PI * 2 / 3);
        const cy2 = cy + r * offset * Math.sin(angles[e] * Math.PI * 2) + r * iris ** 1.5 * Math.sin(-Math.PI * 2 / 3);
        const cx3 = cx + r * offset * Math.cos(angles[e] * Math.PI * 2);
        const cy3 = cy + r * offset * Math.sin(angles[e] * Math.PI * 2);
        list.push({x:cx2, y:cy2, r:r * iris ** 2.35});
        list.push({x:cx2, y:cy2, r:r * iris ** 2.3});
        for (var r2=0; r2<r*iris; r2+=0.1) list.push({x:cx3, y:cy3, r:r2});
        for (var r2=r; r2<r*1.1 ; r2+=0.1) list.push({x:cx, y:cy, r:r2});
    });

    list.forEach(circle => {
        const steps = 200;
        const astep = Math.PI * 2 / steps;
        for (var j=0; j<steps; j++) {
            const a0 = j * astep, a1 = a0 + astep;
            const x0 = circle.x + circle.r * Math.cos(a0), y0 = circle.y + circle.r * Math.sin(a0);
            const x1 = circle.x + circle.r * Math.cos(a1), y1 = circle.y + circle.r * Math.sin(a1);
            var good = true;
            for (var k=0, c=circles.length; k<c && good; k++) {
                if (Math.max(Math.hypot(x0-circles[k].x, y0-circles[k].y), Math.hypot(x1-circles[k].x, y1-circles[k].y)) < circles[k].r) good = false;
            }
            if (good) { turtle.jump(x0, y0); turtle.goto(x1, y1); }
        }
        circles.push(circle);
    });
    
    return false;
}