Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax Canvas.setpenopacity(1); // Global code will be evaluated once. const turtle = new Turtle(); const radius= 80; // min=1, max=100, step=1 const nLines = 40; // min=1, max=100, step=1 // The walk function will be called until it returns false. function walk(i) { const {x,y} = getRandomPointOnCircle(radius) turtle.goto(x,y); return i < nLines; } const getRandomPointOnCircle = radius => { const angle = Math.PI*2 * Math.random(); const x = Math.sin(angle) * radius; const y = Math.cos(angle) * radius; return {x,y} } turtle.penup(); const {x,y} = getRandomPointOnCircle(radius) turtle.goto(x,y); turtle.pendown();