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;
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
add a comment |
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
add a comment |
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
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
python turtle-graphics
asked Mar 23 at 23:26
KaitKait
224
224
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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()
add a comment |
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()
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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()
add a comment |
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()
add a comment |
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()
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()
answered Mar 23 at 23:36
Tom PowisTom Powis
484512
484512
add a comment |
add a comment |
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()
add a comment |
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()
add a comment |
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()
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()
edited Mar 23 at 23:59
answered Mar 23 at 23:51
cdlanecdlane
21k21245
21k21245
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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