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(); const scale = 10; const R = 1; const outline = 1; //min=0 max=1 step=1 (No, Yes) // containing rectangle if(outline ==1){ turtle.penup(); turtle.goto(-7.5 * scale,7.0 * scale); turtle.left(90); turtle.pendown(); turtle.forward(14.5 * scale); turtle.right(90); turtle.forward(15 * scale); turtle.right(90); turtle.forward(14.5 * scale); turtle.right(90); turtle.forward(15 * scale); } /* P1 turtle.penup(); turtle.goto(-3.5 * scale,4.0 * scale); turtle.pendown(); turtle.circle(1); // P2 turtle.penup(); turtle.goto(0.5 * scale,4.0 * scale); turtle.pendown(); turtle.circle(1); // P3 turtle.penup(); turtle.goto(-3.5 * scale,0 * scale); turtle.pendown(); turtle.circle(1); // P4 turtle.penup(); turtle.goto(-0.5 * scale,0.0 * scale); turtle.pendown(); turtle.circle(1); // P5 turtle.penup(); turtle.goto(0.5 * scale,0.0 * scale); turtle.pendown(); turtle.circle(1); */ // line to p1 // P1 turtle.penup(); turtle.goto(-3.5 * scale,7.0 * scale); turtle.pendown(); turtle.setheading(270); turtle.forward(3 * scale); // P3 R4 outer bottom left arc turtle.setheading(180); turtle.circle(R * 4 * scale, 90); // P4 R7.5 outer top left arc turtle.seth(-90); turtle.circle(R * 7.5 * scale, 180); // P5 R7.0 outer top left arc turtle.seth(90); turtle.circle(R * 7.0 * scale, 90); // P2 R3.0 outer bottom right arc turtle.seth(180); turtle.circle(R * 3.0 * scale, 90); // end of outer loop // start of loop 2 // P1 R1.0 inner 1 arc turtle.seth(90); turtle.circle(R * 1.0 * scale, -90); // P3 R4 inner 1 arc turtle.setheading(180); turtle.circle(R * 3 * scale, 90); // P4 R3 inner 1 arc turtle.seth(-90); turtle.circle(R * 6.5 * scale, 180); // P5 R6.0 inner 1 arc turtle.seth(90); turtle.circle(R * 6.0 * scale, 90); // P2 R2.0 inner 1 bottom right arc turtle.seth(180); turtle.circle(R * 2.0 * scale, 90); // end of inner 1 loop // start of loop 3 // P1 R2.0 inner 2 arc turtle.seth(90); turtle.circle(R * 2.0 * scale, -90); // P3 inner 2 arc turtle.setheading(180); turtle.circle(R * 2 * scale, 90); // P4 inner 2 arc turtle.seth(-90); turtle.circle(R * 5.5 * scale, 180); // P5 inner 2 arc turtle.seth(90); turtle.circle(R * 5.0 * scale, 90); // end of inner 2loop // a turtle.seth(180); turtle.circle(R * 1.0 * scale, 60); // start inner 3rd arc // P2 inner 1 bottom right arc // arc 14 turtle.penup(); turtle.goto(0.5 * scale, 5 * scale); turtle.pendown(); turtle.seth(180); turtle.circle(R * 1 * scale, 180); // arc 15 turtle.seth(180); turtle.circle(R * 3.0 * scale, -90); // arc 16 turtle.seth(90); turtle.circle(R * 3.5 * scale, -180); // end of inner 3rd loop ends at p3 // start of inner 6 // arc 17 turtle.penup(); turtle.goto(-1.5 * scale, 4 * scale); turtle.pendown(); turtle.seth(270); turtle.circle(R * 2 * scale, 90); // P5 inner 2 arc // arc 18 turtle.seth(180); turtle.circle(R * 2.0 * scale, -90); // P5 inner 5 arc // arc 19 turtle.seth(90); turtle.circle(R * 2.5 * scale, -180); // P5 inner 5 arc // arc 20 turtle.seth(90); turtle.circle(R * 1 * scale, 180); // P3 inner 3 arc // arc 21 turtle.circle(R * 4.5 * scale, 180); // P5 inner 3 arc // arc 22 turtle.circle(R * 4.0 * scale, 90); // ends at p2 // arc 23 turtle.penup(); turtle.goto(-3.5 * scale, 2.0 * scale); turtle.pendown(); turtle.seth(180); turtle.circle(R * 2 * scale, -90); // arc 24 turtle.seth(-90); turtle.circle(R * 1.5 * scale, 180); // arc 25 turtle.seth(90); turtle.circle(R * 1 * scale, 180); // arc 26 turtle.seth(270); turtle.circle(R * 0.5 * scale, 180); // vertical final line turtle.penup(); turtle.goto(-2.5 * scale,7.0 * scale); turtle.pendown(); turtle.seth(270); turtle.forward(3 * scale); function cir(x,y,radius){ turtle.penup(); turtle.goto(x , y - radius ); turtle.pendown(); turtle.circle(radius); // }