# Method and function circle2 to insert into # turtle.py # to discuss: should circle2 replace circle? # they visually behave differently def circle2(self, radius, extent = None): """ Draw a circle with given radius. """ # docstring as given in circle if extent is None: extent = self._fullcircle frac = abs(extent)/self._fullcircle steps = 1+int(min(11+abs(radius)/6.0, 59.0)*frac) w = 1.0 * extent / steps w2 = 0.5 * w l = 2.0 * radius * sin(w2*self._invradian) if radius < 0: l, w, w2 = -l, -w, -w2 self.left(w2) for i in range(steps): self.forward(l) self.left(w) self.right(w2) # around line 750: def circle2(radius, extent=None): _getpen().circle2(radius, extent) ###################################################### #### testscript: # testing circle2 # assumes insertion of method and function circle2 into turtle.py # tests if circle and circle2 draw identical lines # test ok. # filling with circle2 ok. from turtle import * from time import sleep p = Pen() width(2) begin_fill() for i in range(18): circle(-18,90) circle(18,110) color("red") end_fill() sleep(1.5) p.width(2) p.speed('fastest') p.begin_fill() for i in range(18): p.circle2(-18,90) p.circle2(18,110) p.color("green") p.end_fill() print position() print p.position()