There are at least two problems with the present circle function. 1)
Gregor has pointed out the oddity of the filling. (As I understand it,
it's odd in that the filling occurs inside the circle that is drawn and
you may have been trying to draw a figure with circle segments and you
actually wanted the bounded region to be filled but the bounded region
is actually on the exterior of a circle that was used--see the yin()
function of Gregor's recent post.) 2) From a  pedagogical point of
view, the fact that the circle is drawn without respect to speed is not
good. It's instructive, for example, to see how Gregor's yin-yang image
is drawn, but by using the present circle() you can't really follow the
progress.

Here's a prototype (less smart than the present circle, but heading in
the right direction, I hope) that fixes both of these issues. It draws
a circle as approximated by a polygon. Since it only uses forward() and
turns, it responds to the speed setting. If you run Gregor's yin()
demo, you will see it fill properly, too.

###
def circle(r, xtnt=360.0, segs=30):
    '''use the forward() and turn primitives to draw a circle as a
polygon'''
    th=xtnt/float(segs)
    h=2*abs(r)*sin(th*pi/180) #would be better to compute segs
                                        #so that h is some fraction of
window size
    forward(h/2.0)
    if r<0:
        turn=right
    else:
        turn=left
    for i in xrange(segs-1):
        turn(th)
        forward(h)
    turn(th)
    forward(h/2.0)
###

/chris


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"edupython" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/edupython
-~----------~----~----~----~------~----~------~--~---

Reply via email to