Like lacing a wheel
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax Canvas.setpenopacity(.7); const drawCircle = 1; // min=0, max=1, step=1 const grid = 5; // min=1, max=10, step=1 const margin = .1; // min=0, max=.5, step=.01 // Global code will be evaluated once. const turtle = new Turtle(); // The walk function will be called until it returns false. function walk(i) { let col = i % grid; let row = i / grid | 0; let x = 100 - ((col + .5) * (200 / grid)); let y = 100 - ((row + .5) * (200 / grid)); let r = ((200 / grid) * (1 - margin)) / 2; draw(x, y, r, i + 3); return i < (grid * grid); } function draw(x, y, r, p) { if(drawCircle) { turtle.penup(); turtle.goto(x, y - r); turtle.pendown(); turtle.circle(r); } let points = []; for(let j = 0; j < Math.PI * 2; j += Math.PI * 2 / p) { points.push( [ x + (r * Math.sin(j)), y + (r * Math.cos(j)) ] ); } for (let k = 0; k < points.length; k++) { for(let kk = k + 1; kk < points.length; kk++) { turtle.penup(); turtle.goto(points[k]); turtle.pendown(); turtle.goto(points[kk]); } } }