Commits

Anonymous committed c800a5c Merge

Merge mask workaround with latest development version.

  • Participants
  • Parent commits 9a8acea, 3e7c0de

Comments (0)

Files changed (3)

File lib/attributehandling.py

     def __getattr__(self, name):
         if name in self.std_attrs or name in self.extra_attrs:
             name = "_%s" % name
-        return getattr(self, name)
+        return object.__getattribute__(self, name)
     
     def __setattr__(self, name, value):
         func = None
                     return ((below_m1 == (p[1] > (p[0]-Z[0]) * m1 + Z[1])) or
                             (below_m2 == (p[1] > (p[0]-Z[0]) * m2 + Z[1])))
 
-
+            end_pixel_cache = [[False, None] for i in xrange(4)]
+            ends = []
             def set_px(x, y):
                 """
                 set pixel at (x,y) and mirrored positions
                 """
-                if (x-cx) >= w:
-                    return
-                for p in [(x-cx, y-cy), (w-x-(1-cx), y-cy),
-                          (x-cx, h-y-(1-cy)), (w-x-(1-cx), h-y-(1-cy))]:
+#                if (x-cx) >= w:
+#                    return
+                for i, p in enumerate([(x-cx, y-cy), (w-x-(1-cx), y-cy),
+                          (x-cx, h-y-(1-cy)), (w-x-(1-cx), h-y-(1-cy))]):
                     if is_part(p):
                         mask.set_at(p)
+                        if end_pixel_cache[i][1] is None:
+                            print end_pixel_cache, i
+#                            self._draw_small_line(mask, rect.center, p)
+                            ends.append(p)
+                        end_pixel_cache[i][1] = p
+#                        if end_pixel_cache[i][0] is None:
+#                            print "1"
+#                            end_pixel_cache[i][0] = p
+#                            self._draw_small_line(mask, rect.center, p)
+                            
+                    else:
+                        if end_pixel_cache[i][1] is not None:
+#                            self._draw_small_line(mask, rect.center, end_pixel_cache[i][1])
+                            ends.append(end_pixel_cache[i][1])
+                            print end_pixel_cache, i, "#"
+                        end_pixel_cache[i][1] = None
+                    if end_pixel_cache[i][0] is False:
+                        end_pixel_cache[i][0] = end_pixel_cache[i][1]
+#                        if (end_pixel_cache[i][0] is not None and
+#                            end_pixel_cache[i][1] is None):
+#                            end_pixel_cache[i][1] = p
+#                            self._draw_small_line(mask, rect.center, p)
+#                            print "2"
+
+            
+
+    
         else:
+            end_pixel_cache = None
             def set_px(x, y):
                 """
                 set pixel at (x,y) and mirrored positions
         else:
             #! add dc here
             dc = []
+            
+            # test
+        if end_pixel_cache:
+            print end_pixel_cache
+            print ends
+            print sorted(ends)
+            ends = sorted(ends)
+            while ends:
+                end = ends.pop(0)
+                if ends and abs(end[0] - ends[0][0]) <= 1:
+                    ends.pop(0)
+                else:
+                    dc += self._draw_borderline(mask, rect.center, end)
+         #   for points in end_pixel_cache:
+         #       for p in points:
+         #           self._draw_small_line(mask, rect.center, p)
+#                    self._draw_ellipse(rect, mask=mask)
+            # end test
         return mask, dc
 
     #} end of internal shape definitions

File lib/solidpen.py

 import sys
+import pygame2
 from lib.pen import Pen
 
 if sys.version_info[0] >= 3:
     """
     Pen that draws all pixels in the same color.
     """
+    extra_attrs = {"color": lambda c: c if type(c) == pygame2.Color else None}
     def __init__(self, color):
         """
         :type color: tuple