Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax const a = -2; // min=-2 max=2 step=0.01 const b = -1.6; // min=-2 max=2 step=0.01 const c = 0.63; // min=-2 max=2 step=0.01 const d = -0.87; // min=-2 max=2 step=0.01 const steps = 1000000; // min=1000 max=10000000 step=100 const scale = 46; // min=0 max=100 step=1 const opacity = 0.02; // min=0 max=1 step=0.01 Canvas.setpenopacity(opacity); // Global code will be evaluated once. const turtle = new Turtle(); turtle.penup(); turtle.goto(0, 0); turtle.pendown(); let x = 0.5; // Initial condition for x let y = -0.1; // Initial condition for y // The walk function will be called until it returns false. function walk(i) { const newX = Math.sin(a * y) + c * Math.cos(a * x); const newY = Math.sin(b * x) + d * Math.cos(b * y); // Draw the point scaled to the canvas size //turtle.goto(newX * 50, newY * 50); turtle.jump(newX*scale, newY*scale); turtle.forward(1); // Update x and y for the next iteration x = newX; y = newY; return i < steps; // Stop after the specified number of steps. }