Euler Spiral, based on twitter.com/matthen2/status/1249611168265547776 by @matthen2.
Log in to post a comment.
Canvas.setpenopacity(0.75);
const turtle = new Turtle();
const stepSize = 0.55; // min=0.01, max=2, step=0.01
let angleStep = 0.73; // min=0.01, max=2, step=0.01
const steps = 400000; // min=0, max=1000000, step=1
const goldenAngleMult = 0; // min=0, max=1, step=1 (No, Yes)
// Use an irrational number for the angleStep to get interesting patterns
if (goldenAngleMult) {
const goldenAngle = Math.PI * (3 - Math.sqrt(5));
angleStep *= goldenAngle;
}
let angle = turtle.heading();
// The walk function will be called until it returns false.
function walk(i) {
turtle.right(angle);
turtle.forward(stepSize);
angle += angleStep;
return i < steps;
}