Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
// based on https://forresto.github.io/turtle-svg/#code/jY7LDoIwEEX3/Yq7LIlIwWCMRFcuXfoDDZliEyimlLow/LsFNUaN0d2cM3ceSYKdlWdIWCp722lP6E6ypFjputamQrCe1sxLi46qhozbk6ncERukecFUb0qnW4PeaMe1IytHjHBhgFZ4KmwhbhpvYcRIo2JqWC7mWX6HrynFX175Ff9n6cAG1rSeDi1fiBkyEazrrRk5WQWY5pah+Dz+aF0B

Canvas.setpenopacity(1);

// Global code will be evaluated once.
const turtle = new Turtle();
// Draw a recursive space-filling curve:
const segmentLength = 5; //min=1 max=70 step=1
function unit(iteration) {
  if (iteration > 0) {
    unit(iteration - 1);
    turtle.right(90);
    unit(iteration - 1);
    turtle.forward(segmentLength);
    unit(iteration - 1);
    turtle.right(90);
    unit(iteration - 1);
  }
}
turtle.penup()
turtle.goto(50 * segmentLength /4.42, -50 * segmentLength /4.71);  // there must be a better way!
turtle.pendown()
turtle.right(45);
unit(5);
turtle.forward(segmentLength );
unit(5);