[Tutor] Ongoing trouble with Turtle's end_fill()

Dick Moores rdmoores at gmail.com
Wed Aug 6 15:33:51 CEST 2008


On Wed, Aug 6, 2008 at 4:50 AM, Kent Johnson <kent37 at tds.net> wrote:
> On Tue, Aug 5, 2008 at 6:49 PM, Dick Moores <rdmoores at gmail.com> wrote:
>> For a while now I've had trouble with end_fill(). Sometimes I can use
>> it to fill a figure such as a square, triangle or rectangle, but
>> sometimes not.
>>
>> Here's a barebones script using end_fill(). As you can see, it draws a
>> square twice, but fails to fill it. Pleas show me how to use it
>> correctly in tandem with begin_fill().
>
> Here is a version that does fill:
> from turtle import *
> import time
>
> setup(width=1000, height=700, startx=0, starty=0)
> for n in range(2):
>   color_name = 'red'
>   x, y = 50, 50
>   color(color_name)
>   print color_name
>   up()
>   goto(x, y)
>   down()
>   begin_fill()
>   goto(x, -y)
>   goto(-x, -y)
>   goto(-x, y)
>   end_fill()
>   print "end_fill()"
>   goto(x, y)
>   time.sleep(1)
>   clear()
>
> I have no idea why this one works and yours doesn't. Your program is
> very similar to the filled square in turtle.demo() which does work.

Well, Kent, it seems you have found the right places for begin_fill()
and end_fill().
The 450-line script I was writing now works perfectly at last, in what
is now version 15.

Thanks very much. And my thanks also to Alan.

Dick


More information about the Tutor mailing list