Is there a way to check if a polygon is completely closed?How do I check if a list is empty?How do I check whether a file exists without exceptions?Is there a way to run Python on Android?What's the canonical way to check for type in Python?Nicest way to pad zeroes to a stringHow do I check if a string is a number (float)?How to substring a string in Python?Check if a given key already exists in a dictionaryFastest way to check if a value exist in a listMost elegant way to check if the string is empty in Python?

Gravitational Force Between Numbers

Why does Bran want to find Drogon?

“For nothing” = “pour rien”?

Are there any German nonsense poems (Jabberwocky)?

Why is this integration method not valid?

Why does the hash of infinity have the digits of π?

...And they were stumped for a long time

Of strange atmospheres - the survivable but unbreathable

Why sampling a periodic signal doesn't yield a periodic discrete signal?

USPS Back Room - Trespassing?

The Maltese Falcon

Python program for fibonacci sequence using a recursive function

Final exams: What is the most common protocol for scheduling?

3 prong range outlet

Why did Jon Snow admit his fault in S08E06?

Is "vegetable base" a common term in English?

How can I properly write this equation in Latex?

Why is unzipped directory exactly 4.0k (much smaller than zipped file)?

Variable declaraton with extra in C

Is my plasma cannon concept viable?

Why did Jon Snow do this immoral act if he is so honorable?

Do copyright notices need to be placed at the beginning of a file?

If I arrive in the UK, and then head to mainland Europe, does my Schengen visa 90 day limit start when I arrived in the UK, or mainland Europe?

Is keeping the forking link on a true fork necessary (Github/GPL)?



Is there a way to check if a polygon is completely closed?


How do I check if a list is empty?How do I check whether a file exists without exceptions?Is there a way to run Python on Android?What's the canonical way to check for type in Python?Nicest way to pad zeroes to a stringHow do I check if a string is a number (float)?How to substring a string in Python?Check if a given key already exists in a dictionaryFastest way to check if a value exist in a listMost elegant way to check if the string is empty in Python?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am trying to draw a red Stop sign, outlined in white. However, I can't seem to figure out why the red octagon is not filling in.



If the octagon is still open, would that be why it's not filling? If it is, how can I check to see if it's open?



import turtle
turtle.bgcolor("black")
turtle.penup()
turtle.goto(-104,-229)
# Draws white octagon outline
for i in range(8):
turtle.pensize(10)
turtle.color("white")
turtle.pendown()
turtle.forward(193)
turtle.right(5)
turtle.left(50)

# Draws red octagon
turtle.penup()
turtle.goto(-100,-220)
for i in range(8):
turtle.pensize(10)
turtle.color("red")
turtle.fillcolor("red")
turtle.begin_fill()
turtle.pendown()
turtle.forward(185)
turtle.right(5)
turtle.left(50)
turtle.end_fill()

# Writes "STOP"
turtle.penup()
turtle.goto(5,-50)
turtle.setheading(360 / 8 / 2)
turtle.pendown()
turtle.stamp()
turtle.pencolor("white")
turtle.shapesize(0.9)
turtle.stamp()
turtle.shapesize(1.0)
turtle.write("STOP", align="center", font=("Arial",110,"normal"))
turtle.done()









share|improve this question




























    1















    I am trying to draw a red Stop sign, outlined in white. However, I can't seem to figure out why the red octagon is not filling in.



    If the octagon is still open, would that be why it's not filling? If it is, how can I check to see if it's open?



    import turtle
    turtle.bgcolor("black")
    turtle.penup()
    turtle.goto(-104,-229)
    # Draws white octagon outline
    for i in range(8):
    turtle.pensize(10)
    turtle.color("white")
    turtle.pendown()
    turtle.forward(193)
    turtle.right(5)
    turtle.left(50)

    # Draws red octagon
    turtle.penup()
    turtle.goto(-100,-220)
    for i in range(8):
    turtle.pensize(10)
    turtle.color("red")
    turtle.fillcolor("red")
    turtle.begin_fill()
    turtle.pendown()
    turtle.forward(185)
    turtle.right(5)
    turtle.left(50)
    turtle.end_fill()

    # Writes "STOP"
    turtle.penup()
    turtle.goto(5,-50)
    turtle.setheading(360 / 8 / 2)
    turtle.pendown()
    turtle.stamp()
    turtle.pencolor("white")
    turtle.shapesize(0.9)
    turtle.stamp()
    turtle.shapesize(1.0)
    turtle.write("STOP", align="center", font=("Arial",110,"normal"))
    turtle.done()









    share|improve this question
























      1












      1








      1








      I am trying to draw a red Stop sign, outlined in white. However, I can't seem to figure out why the red octagon is not filling in.



      If the octagon is still open, would that be why it's not filling? If it is, how can I check to see if it's open?



      import turtle
      turtle.bgcolor("black")
      turtle.penup()
      turtle.goto(-104,-229)
      # Draws white octagon outline
      for i in range(8):
      turtle.pensize(10)
      turtle.color("white")
      turtle.pendown()
      turtle.forward(193)
      turtle.right(5)
      turtle.left(50)

      # Draws red octagon
      turtle.penup()
      turtle.goto(-100,-220)
      for i in range(8):
      turtle.pensize(10)
      turtle.color("red")
      turtle.fillcolor("red")
      turtle.begin_fill()
      turtle.pendown()
      turtle.forward(185)
      turtle.right(5)
      turtle.left(50)
      turtle.end_fill()

      # Writes "STOP"
      turtle.penup()
      turtle.goto(5,-50)
      turtle.setheading(360 / 8 / 2)
      turtle.pendown()
      turtle.stamp()
      turtle.pencolor("white")
      turtle.shapesize(0.9)
      turtle.stamp()
      turtle.shapesize(1.0)
      turtle.write("STOP", align="center", font=("Arial",110,"normal"))
      turtle.done()









      share|improve this question














      I am trying to draw a red Stop sign, outlined in white. However, I can't seem to figure out why the red octagon is not filling in.



      If the octagon is still open, would that be why it's not filling? If it is, how can I check to see if it's open?



      import turtle
      turtle.bgcolor("black")
      turtle.penup()
      turtle.goto(-104,-229)
      # Draws white octagon outline
      for i in range(8):
      turtle.pensize(10)
      turtle.color("white")
      turtle.pendown()
      turtle.forward(193)
      turtle.right(5)
      turtle.left(50)

      # Draws red octagon
      turtle.penup()
      turtle.goto(-100,-220)
      for i in range(8):
      turtle.pensize(10)
      turtle.color("red")
      turtle.fillcolor("red")
      turtle.begin_fill()
      turtle.pendown()
      turtle.forward(185)
      turtle.right(5)
      turtle.left(50)
      turtle.end_fill()

      # Writes "STOP"
      turtle.penup()
      turtle.goto(5,-50)
      turtle.setheading(360 / 8 / 2)
      turtle.pendown()
      turtle.stamp()
      turtle.pencolor("white")
      turtle.shapesize(0.9)
      turtle.stamp()
      turtle.shapesize(1.0)
      turtle.write("STOP", align="center", font=("Arial",110,"normal"))
      turtle.done()






      python turtle-graphics






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 23:26









      KaitKait

      224




      224






















          2 Answers
          2






          active

          oldest

          votes


















          1














          You need to put the begin and end fill outside the loop as it would be just filling one line at a time



          # Draws red octagon
          turtle.penup()
          turtle.goto(-100,-220)
          turtle.pensize(10)
          turtle.color("red")
          turtle.fillcolor("red")
          turtle.begin_fill()
          for i in range(8):
          turtle.pendown()
          turtle.forward(185)
          turtle.right(5)
          turtle.left(50)
          turtle.end_fill()





          share|improve this answer






























            0














            I see two issues with your code. First, you put the begin_fill() and end_fill() inside your octogon loop -- they should wrap around the outside of the loop, not be part of it. Second, you've generally made things more complicated than necessary including throwing in code that has no bearing on your result (e.g stamp(), shapesize(), setheading(), etc.). Here's simplfied rework of your code with the fill fixed:



            from turtle import Screen, Turtle

            SIDE = 200
            PEN_SIZE = 10
            FONT_SIZE = 150
            FONT = ("Arial", FONT_SIZE, "bold")

            screen = Screen()
            screen.bgcolor("black")

            turtle = Turtle()
            turtle.hideturtle()
            turtle.pensize(PEN_SIZE)
            turtle.penup()

            # Draw white octagon with red fill
            turtle.goto(-SIDE/2, -SIDE/2 + -SIDE/(2 ** 0.5)) # octogon geometry
            turtle.color("white", "red") # color() sets both pen and fill colors
            turtle.pendown()

            turtle.begin_fill()
            for _ in range(8):
            turtle.forward(SIDE)
            turtle.left(45)
            turtle.end_fill()

            turtle.penup()

            # Write "STOP"
            turtle.goto(0, -FONT_SIZE/2) # roughly font baseline
            turtle.pencolor("white")

            turtle.write("STOP", align="center", font=FONT) # write() doesn't need pendown()

            screen.exitonclick()





            share|improve this answer

























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319316%2fis-there-a-way-to-check-if-a-polygon-is-completely-closed%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              You need to put the begin and end fill outside the loop as it would be just filling one line at a time



              # Draws red octagon
              turtle.penup()
              turtle.goto(-100,-220)
              turtle.pensize(10)
              turtle.color("red")
              turtle.fillcolor("red")
              turtle.begin_fill()
              for i in range(8):
              turtle.pendown()
              turtle.forward(185)
              turtle.right(5)
              turtle.left(50)
              turtle.end_fill()





              share|improve this answer



























                1














                You need to put the begin and end fill outside the loop as it would be just filling one line at a time



                # Draws red octagon
                turtle.penup()
                turtle.goto(-100,-220)
                turtle.pensize(10)
                turtle.color("red")
                turtle.fillcolor("red")
                turtle.begin_fill()
                for i in range(8):
                turtle.pendown()
                turtle.forward(185)
                turtle.right(5)
                turtle.left(50)
                turtle.end_fill()





                share|improve this answer

























                  1












                  1








                  1







                  You need to put the begin and end fill outside the loop as it would be just filling one line at a time



                  # Draws red octagon
                  turtle.penup()
                  turtle.goto(-100,-220)
                  turtle.pensize(10)
                  turtle.color("red")
                  turtle.fillcolor("red")
                  turtle.begin_fill()
                  for i in range(8):
                  turtle.pendown()
                  turtle.forward(185)
                  turtle.right(5)
                  turtle.left(50)
                  turtle.end_fill()





                  share|improve this answer













                  You need to put the begin and end fill outside the loop as it would be just filling one line at a time



                  # Draws red octagon
                  turtle.penup()
                  turtle.goto(-100,-220)
                  turtle.pensize(10)
                  turtle.color("red")
                  turtle.fillcolor("red")
                  turtle.begin_fill()
                  for i in range(8):
                  turtle.pendown()
                  turtle.forward(185)
                  turtle.right(5)
                  turtle.left(50)
                  turtle.end_fill()






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 23 at 23:36









                  Tom PowisTom Powis

                  484512




                  484512























                      0














                      I see two issues with your code. First, you put the begin_fill() and end_fill() inside your octogon loop -- they should wrap around the outside of the loop, not be part of it. Second, you've generally made things more complicated than necessary including throwing in code that has no bearing on your result (e.g stamp(), shapesize(), setheading(), etc.). Here's simplfied rework of your code with the fill fixed:



                      from turtle import Screen, Turtle

                      SIDE = 200
                      PEN_SIZE = 10
                      FONT_SIZE = 150
                      FONT = ("Arial", FONT_SIZE, "bold")

                      screen = Screen()
                      screen.bgcolor("black")

                      turtle = Turtle()
                      turtle.hideturtle()
                      turtle.pensize(PEN_SIZE)
                      turtle.penup()

                      # Draw white octagon with red fill
                      turtle.goto(-SIDE/2, -SIDE/2 + -SIDE/(2 ** 0.5)) # octogon geometry
                      turtle.color("white", "red") # color() sets both pen and fill colors
                      turtle.pendown()

                      turtle.begin_fill()
                      for _ in range(8):
                      turtle.forward(SIDE)
                      turtle.left(45)
                      turtle.end_fill()

                      turtle.penup()

                      # Write "STOP"
                      turtle.goto(0, -FONT_SIZE/2) # roughly font baseline
                      turtle.pencolor("white")

                      turtle.write("STOP", align="center", font=FONT) # write() doesn't need pendown()

                      screen.exitonclick()





                      share|improve this answer





























                        0














                        I see two issues with your code. First, you put the begin_fill() and end_fill() inside your octogon loop -- they should wrap around the outside of the loop, not be part of it. Second, you've generally made things more complicated than necessary including throwing in code that has no bearing on your result (e.g stamp(), shapesize(), setheading(), etc.). Here's simplfied rework of your code with the fill fixed:



                        from turtle import Screen, Turtle

                        SIDE = 200
                        PEN_SIZE = 10
                        FONT_SIZE = 150
                        FONT = ("Arial", FONT_SIZE, "bold")

                        screen = Screen()
                        screen.bgcolor("black")

                        turtle = Turtle()
                        turtle.hideturtle()
                        turtle.pensize(PEN_SIZE)
                        turtle.penup()

                        # Draw white octagon with red fill
                        turtle.goto(-SIDE/2, -SIDE/2 + -SIDE/(2 ** 0.5)) # octogon geometry
                        turtle.color("white", "red") # color() sets both pen and fill colors
                        turtle.pendown()

                        turtle.begin_fill()
                        for _ in range(8):
                        turtle.forward(SIDE)
                        turtle.left(45)
                        turtle.end_fill()

                        turtle.penup()

                        # Write "STOP"
                        turtle.goto(0, -FONT_SIZE/2) # roughly font baseline
                        turtle.pencolor("white")

                        turtle.write("STOP", align="center", font=FONT) # write() doesn't need pendown()

                        screen.exitonclick()





                        share|improve this answer



























                          0












                          0








                          0







                          I see two issues with your code. First, you put the begin_fill() and end_fill() inside your octogon loop -- they should wrap around the outside of the loop, not be part of it. Second, you've generally made things more complicated than necessary including throwing in code that has no bearing on your result (e.g stamp(), shapesize(), setheading(), etc.). Here's simplfied rework of your code with the fill fixed:



                          from turtle import Screen, Turtle

                          SIDE = 200
                          PEN_SIZE = 10
                          FONT_SIZE = 150
                          FONT = ("Arial", FONT_SIZE, "bold")

                          screen = Screen()
                          screen.bgcolor("black")

                          turtle = Turtle()
                          turtle.hideturtle()
                          turtle.pensize(PEN_SIZE)
                          turtle.penup()

                          # Draw white octagon with red fill
                          turtle.goto(-SIDE/2, -SIDE/2 + -SIDE/(2 ** 0.5)) # octogon geometry
                          turtle.color("white", "red") # color() sets both pen and fill colors
                          turtle.pendown()

                          turtle.begin_fill()
                          for _ in range(8):
                          turtle.forward(SIDE)
                          turtle.left(45)
                          turtle.end_fill()

                          turtle.penup()

                          # Write "STOP"
                          turtle.goto(0, -FONT_SIZE/2) # roughly font baseline
                          turtle.pencolor("white")

                          turtle.write("STOP", align="center", font=FONT) # write() doesn't need pendown()

                          screen.exitonclick()





                          share|improve this answer















                          I see two issues with your code. First, you put the begin_fill() and end_fill() inside your octogon loop -- they should wrap around the outside of the loop, not be part of it. Second, you've generally made things more complicated than necessary including throwing in code that has no bearing on your result (e.g stamp(), shapesize(), setheading(), etc.). Here's simplfied rework of your code with the fill fixed:



                          from turtle import Screen, Turtle

                          SIDE = 200
                          PEN_SIZE = 10
                          FONT_SIZE = 150
                          FONT = ("Arial", FONT_SIZE, "bold")

                          screen = Screen()
                          screen.bgcolor("black")

                          turtle = Turtle()
                          turtle.hideturtle()
                          turtle.pensize(PEN_SIZE)
                          turtle.penup()

                          # Draw white octagon with red fill
                          turtle.goto(-SIDE/2, -SIDE/2 + -SIDE/(2 ** 0.5)) # octogon geometry
                          turtle.color("white", "red") # color() sets both pen and fill colors
                          turtle.pendown()

                          turtle.begin_fill()
                          for _ in range(8):
                          turtle.forward(SIDE)
                          turtle.left(45)
                          turtle.end_fill()

                          turtle.penup()

                          # Write "STOP"
                          turtle.goto(0, -FONT_SIZE/2) # roughly font baseline
                          turtle.pencolor("white")

                          turtle.write("STOP", align="center", font=FONT) # write() doesn't need pendown()

                          screen.exitonclick()






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Mar 23 at 23:59

























                          answered Mar 23 at 23:51









                          cdlanecdlane

                          21k21245




                          21k21245



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319316%2fis-there-a-way-to-check-if-a-polygon-is-completely-closed%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                              Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript