[Tutor] Ongoing trouble with Turtle's end_fill()
gregor.lingl at aon.at
Fri Aug 8 00:47:54 CEST 2008
Alan Gauld schrieb:
> "Dick Moores" <rdmoores at gmail.com> wrote
>> 1. The turtle has some behavior I don't see how to eliminate. If you
>> refer to lines 223, 225, 227, 229, etc., you'll see that the turtle
>> always faces in the direction it is moving when drawing a rectangle.
> That is correct behaviour for a turtle!
> Remember turtle graphics are notionally about moving a physical
> drawing device (the turtle) around on the floor or desk. If the turtle
> doesn't turn to face the direction of travel it can't travel that way!
> IMHO that's just a feature of the technology and any other behaviour
> would be out of keeping with the intent.
development of this rectangle pattern program is going verry fast and
as I see Dick has managed to abridge his program by some
fifty lines (using the new turtle module).
Most of his questions got superb answers by Alan, so I'll add only
a few remarks:
In fact Dick doesn't use any turtle graphics functions in it's precise
meaning. Instead he uses a (global) Cartesian coordinate system and
moves the turtle only by calling goto().
(This approach is perfectly ok for his task, of course).
Turtle graphics by contrast uses a local coordinate system of the "turtle"
and moves it by calling only forward(), back(), left() and right()
>> Using the Python2.6 beta2 version of turtle.py, the turtle can be seen
>> at each corner spinning to orient itself to the new direction. I don't
>> want this.
So you eliminated the superfluous setheading() calls.
> While far from common in turtle implementations (I have only seen
> it in my old CP/M Logo version) it is a feature that would be true
> of a physical turtle too. Its not really a bug but a "feature" I guess!
>> 2. The turtle can also be seen moving from the last corner of the last
>> rectangle to the first corner of the next. I don't want this.
This is ideed an intended difference between the new and the old
turtle module. I consider this to be an improvement of the animation
of the turtle. (You can observe another improvement by trying out
e. g. left(1080) ) The intention is that the beginning programmer
can visually observe what he or she has programmed and thus more
easily identify errors in his/her program. To that end the turtle
moves and turns at the specified speed regardless of the state of
the pen (up or down).
If you don't like this you can set speed to 0 which - paradoxically -
means that the animation is turned off and the turtle jumps instantaneously.
(Think of something like speed(False))
> Again true of a physical turtle... But if you set speed to fastest
> does that work?
Yes, that is speed(0). See above
> Also in the old turtle moduile there was a way to
> hide the turtles movements completely and just draw the finished
> graphic - which was orders of magnitude faster for complex
> shapes - is that still available in turtle26?
Yes it is (of course ;-) ). Use tracer in the same way as in the old one.
> One way to hide the turtle would be top change colour to the
> background color. That would make themoving turtle invisible...
As Dick discoverd you can use hideturtle() and showturtle()
>> 3. When the screen is cleared between cycles by line 367, the blank
>> screen shows for a second or so. I don't want this.
>> In my program using the old turtle I've had to create
>> colored-backgrounds by drawing a rectangle almost as large as the
>> screen (see my draw_background() beginning at line 365). With the new
>> turtle, the background color can be set by, for example,
>> screen.bgcolor("orange"). But even so, in the V16 I was trying to
>> write, that blank screen still shows for a second or so. With the old
>> turtle, the transition from one "background" to another seems
>> instantaneous. No white blank screen visible at all.
> Sounds like a valid complaint that one...
This again is a result of the animation of the turtle. Of course a correct
use of bgcolor() solves this problem - as Dick did now -, but also use
or tracer(False) would have solved it.
P.S.: If you are interested, you can download a series of sample programs
covering a broad range from very easy to fairly advanced, which
intend to show some features and capabilities of the new turtle module
These will be included in the source distribution - but not in the Windows
More information about the Tutor