turtle-graphicslogo-lang

LOGO WebTurtle... draw a half circle at each vertex?


For my college programming class I am having to use Web Turtle. I am trying to draw a spiral like this enter image description here

I know you must start with drawing a 36 sided polygon like this

SHOWTURTLE
REPEAT 36
  DRAW 10
  RIGHT 10
NEXT

But after that I am lost, I tried this:

SHOWTURTLE
REPEAT 36
  DRAW 10
  RIGHT 10
  GO HALF
NEXT
END


# HALF
  REPEAT 18
    DRAW 10
    RIGHT 10
  NEXT
RETURN 

This results in just a circle over my 36 sided polygon however. I know what I need to do but I cant put into the code. I need to draw a half circle at every vertex of the 36 sided polygon. I don't know why this coming harder to me then JavaScript did! Any tips would be awesome!


Solution

  • So the problem was that I was not rotating the turtle outward before drawing the half circle.Thats why it was just creating a circle over and over. By adding left 180 before drawing the semicircle and then reverting afterwards the problem is fixed.

    SHOWTURTLE
    COLOR BLUE
    THICK 3
    LEFT 90
    MOVE 140
    RIGHT 90
    REPEAT 36
       DRAW 10
       RIGHT 10
       GO SEMICIRCLE
       RIGHT 10
       GO REVERT
    NEXT
    END
    END
    
    # SEMICIRCLE
      REPEAT 18
         DRAW 10
         RIGHT 10
      NEXT
    RETURN
    
    # REVERT
      LEFT 180
      REPEAT 18
         MOVE 10
         LEFT 10
      NEXT
      RIGHT 180
    RETURN