1. schlangen
  2. pygamedraw

Commits

schlangen  committed 2c6866d

Fixed line ending (multipart) drawing. (except for #9)

  • Participants
  • Parent commits 8034eb5
  • Branches default
  • Tags gsoc

Comments (0)

Files changed (1)

File lib/pen.py

View file
  • Ignore whitespace
                 raise ValueError("Unknown line style: %s" % self.line_style)
 
 
-    def _draw_line_endings(self, surf, first_vert, last_vert):
+    def _draw_line_ending(self, surf, vert, ending):
         """
-        draw special line endings, depending on ``self.line_start`` and
-        ``self.line_ending``\ .
+        draw special line ending, depending on ending that is either
+        ``self.line_start`` or ``self.line_ending``\ .
         """
-        for ending, vert in ((self.line_start, first_vert), 
-                              (self.line_ending, last_vert)):
-            if ending == ROUND_ENDING and self.width > 1:
-                self.circle(surf, vert.point, self.width/2, fill=True)
+        if ending == ROUND_ENDING and self.width > 1:
+            #! todo: use ellipse(rect) to draw also odd widths
+            self.circle(surf, vert.point, self.width/2, fill=True)
 
     #  http://trevinca.ei.uvigo.es/~formella/doc/ig04/node57.html
     def _draw_ellipse(self, rect, start=0, stop=360, mask=None):
 
         verts = self._get_verts_for_line(points[:], closed)
         
+        if not closed:
+            self._draw_line_ending(surf, verts[0], self.line_start)
+            
         last_vert = verts[0]
         for vert in verts[1:]:
             self._draw_line_segment(surf, last_vert, vert)
             last_vert = vert
             
         if not closed:
-            self._draw_line_endings(surf, verts[0], verts[-1])
+            self._draw_line_ending(surf, verts[-1], self.line_ending)
         self.multipart = False
         self.last_pos = None
         self.last_mask = None