Spiral
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();
turtle.penup();
turtle.goto(0,0);
turtle.pendown();
const ITERS = 1000
// The walk function will be called until it returns false.
function walk(i) {
const amplitude = i*i/10000;
const revolutions = ITERS/10
const angle = 2*Math.PI*i/revolutions
const x = Math.cos(angle) * amplitude;
const y = Math.sin(angle) * amplitude;
console.log(x);
console.log(y);
turtle.goto(x, y);
return i < ITERS;
}