浏览代码

Added polygon color change on double tap.

Taddeus Kroes 13 年之前
父节点
当前提交
55dbb2eb7f
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 6 2
      tests/testapp.py
  2. 0 1
      tests/utils.py

+ 6 - 2
tests/testapp.py

@@ -38,7 +38,7 @@ class Rectangle(mt.RectangularArea):
 class Polygon(BoundingBoxArea):
     def __init__(self, x, y, points, margin=0, color=BLUE, border_color=RED):
         super(Polygon, self).__init__(x, y, points)
-        self.fill_color = color
+        self.color = color
         self.border_color = border_color
         self.margin = margin
 
@@ -46,6 +46,10 @@ class Polygon(BoundingBoxArea):
         self.on_pinch(self.handle_pinch)
         self.on_rotate(self.handle_rotate)
         self.on_flick(self.handle_flick)
+        self.on_double_tap(self.circulate_color)
+
+    def circulate_color(self, g):
+        self.color = self.color[2:] + self.color[:2]
 
     def flick_drag(self, amt):
         tx, ty = self.flick_direction
@@ -105,7 +109,7 @@ class Polygon(BoundingBoxArea):
         for x, y in zip(*self.points):
             cr.line_to(x, y)
 
-        cr.set_source_rgb(*self.fill_color)
+        cr.set_source_rgb(*self.color)
         cr.fill()
 
 

+ 0 - 1
tests/utils.py

@@ -114,7 +114,6 @@ def inside_shape(p, verts):
 
         # Compute x intersection value
         xisect = x0 + (x1 - x0) * (y - y0) / (y1 - y0)
-        print xisect, x
 
         if xisect >= x:
             inside = not inside