]> granicus.if.org Git - python/commitdiff
Patch #1519566: Remove unused _tofill member.
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 10 Jul 2006 22:11:28 +0000 (22:11 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 10 Jul 2006 22:11:28 +0000 (22:11 +0000)
Make begin_fill idempotent.
Update demo2 to demonstrate filling of concave shapes.

Doc/lib/libturtle.tex
Lib/lib-tk/turtle.py
Misc/NEWS

index 6b9585f0019c766291ecfcbf2132cea0b5f00077..2b329b7209e2f6c2a2073dba33d97e29588ea835 100644 (file)
@@ -108,7 +108,9 @@ and call \code{fill(0)} when you finish to draw the path.
 \end{funcdesc}
 
 \begin{funcdesc}{begin\_fill}{}
-Switch turtle into filling mode; equivalent to \code{fill(1)}.
+Switch turtle into filling mode; 
+Must eventually be followed by a corresponding end_fill() call.
+Otherwise it will be ignored.
 \versionadded{2.5}
 \end{funcdesc}
 
index 9fa447c189434ef2b942e7741553b52ea7e8f4ec..4cface736c59c024a4f6380007ba80ab39de0b0c 100644 (file)
@@ -86,7 +86,6 @@ class RawPen:
         self._color = "black"
         self._filling = 0
         self._path = []
-        self._tofill = []
         self.clear()
         canvas._root().tkraise()
 
@@ -306,19 +305,15 @@ class RawPen:
                                             {'fill': self._color,
                                              'smooth': smooth})
                 self._items.append(item)
-                if self._tofill:
-                    for item in self._tofill:
-                        self._canvas.itemconfigure(item, fill=self._color)
-                        self._items.append(item)
         self._path = []
-        self._tofill = []
         self._filling = flag
         if flag:
             self._path.append(self._position)
-        self.forward(0)
 
     def begin_fill(self):
         """ Called just before drawing a shape to be filled.
+            Must eventually be followed by a corresponding end_fill() call.
+            Otherwise it will be ignored.
 
         Example:
         >>> turtle.begin_fill()
@@ -331,7 +326,8 @@ class RawPen:
         >>> turtle.forward(100)
         >>> turtle.end_fill()
         """
-        self.fill(1)
+        self._path = [self._position]
+        self._filling = 1
 
     def end_fill(self):
         """ Called after drawing a shape to be filled.
@@ -901,15 +897,30 @@ def demo2():
             speed(speeds[sp])
     color(0.25,0,0.75)
     fill(0)
-    color("green")
 
-    left(130)
+    # draw and fill a concave shape
+    left(120)
     up()
-    forward(90)
+    forward(70)
+    right(30)
+    down()
     color("red")
-    speed('fastest')
+    speed("fastest")
+    fill(1)
+    for i in range(4):
+        circle(50,90)
+        right(90)
+        forward(30)
+        right(90)
+    color("yellow")
+    fill(0)
+    left(90)
+    up()
+    forward(30)
     down();
 
+    color("red")
+    
     # create a second turtle and make the original pursue and catch it
     turtle=Turtle()
     turtle.reset()
index 770b87f02bb65ad3f0d131cd452a438de2d7b5c9..fd6c17ce299b1dc06f564846dbe65f8db5e5f165 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -46,6 +46,8 @@ Core and builtins
 Library
 -------
 
+- Patch #1519566: Update turtle demo, make begin_fill idempotent.
+
 - Bug #1508010: msvccompiler now requires the DISTUTILS_USE_SDK
   environment variable to be set in order to the SDK environment
   for finding the compiler, include files, etc.