Re: [Tutor] Polygon fill in turtle

2018-03-27 Thread Alan Gauld via Tutor
On 27/03/18 22:10, Roger Lea Scherer wrote:

> outlineColor = input("What color would you like for the outline?")
> filler = input("And what color would you like to fill it with? ")
> 
> hadir.begin_fill()
> hadir.color(outlineColor)
> print(filler)
> for i in range(sides):
> hadir.forward(length)
> hadir.left(360 / sides)
> hadir.up()
> hadir.end_fill()


You don't actually set the fill color anywhere.

Here is a sequence I used that worked:

>>> t1 = turtle.Turtle()
>>> t1.color('red','blue')
>>> t1.begin_fill()
>>> t1.circle(40)
>>> t1.end_fill()

Note the call to color() to set the pen and fill colors.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Polygon fill in turtle

2018-03-27 Thread Roger Lea Scherer
I looked at Stackoverflow, followed, but could not succeed. I want to fill
the polygon with a different color than the pen color. When I print out the
filler it is the correct color, but the actual fill is not. Here it is:
(tada!)

# create a user-defined polygon
import turtle


wn = turtle.Screen()
hadir = turtle.Turtle()
hadir.speed(8)

sides = int(input("Please enter the number of sides of a polygon you want
drawn: "))
length = int(input("How long would you like each side? "))
outlineColor = input("What color would you like for the outline?")
filler = input("And what color would you like to fill it with? ")

hadir.begin_fill()
hadir.color(outlineColor)
print(filler)
for i in range(sides):
hadir.forward(length)
hadir.left(360 / sides)
hadir.up()
hadir.end_fill()

Thanks, as always.

-- 
Roger Lea Scherer
623.255.7719
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor