Log in to post a comment.
// Forked from "The Sine Map" by mdiamond // https://turtletoy.net/turtle/b8ae13c558 const a = 4; const scale = 100; const iterations = 1000; /* Try changing the value of k and the start coordinate */ const k = 1; const start = [0,0]; setup(); const turtle = getTurtle(); function walk(i) { turtle.setpos(iterate(turtle.pos())); return i < iterations; } function iterate([x, y]) { [x, y] = [x / scale, y / scale]; return [ Math.sin(k * (x-y+a)) * scale, Math.sin(k * (x+y+a)) * scale ]; } function getTurtle () { const turtle = new Turtle(); turtle.penup(); [x,y]=start for (let i=0; i<300; i++) { [x,y]=iterate([x,y]) } turtle.goto([x,y]); turtle.pendown(); return turtle; } function setup() { Canvas.setpenopacity(0.7); }