Commit 55dbb2eb authored by Taddeüs Kroes's avatar Taddeüs Kroes

Added polygon color change on double tap.

parent 010cb2bc
...@@ -38,7 +38,7 @@ class Rectangle(mt.RectangularArea): ...@@ -38,7 +38,7 @@ class Rectangle(mt.RectangularArea):
class Polygon(BoundingBoxArea): class Polygon(BoundingBoxArea):
def __init__(self, x, y, points, margin=0, color=BLUE, border_color=RED): def __init__(self, x, y, points, margin=0, color=BLUE, border_color=RED):
super(Polygon, self).__init__(x, y, points) super(Polygon, self).__init__(x, y, points)
self.fill_color = color self.color = color
self.border_color = border_color self.border_color = border_color
self.margin = margin self.margin = margin
...@@ -46,6 +46,10 @@ class Polygon(BoundingBoxArea): ...@@ -46,6 +46,10 @@ class Polygon(BoundingBoxArea):
self.on_pinch(self.handle_pinch) self.on_pinch(self.handle_pinch)
self.on_rotate(self.handle_rotate) self.on_rotate(self.handle_rotate)
self.on_flick(self.handle_flick) 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): def flick_drag(self, amt):
tx, ty = self.flick_direction tx, ty = self.flick_direction
...@@ -105,7 +109,7 @@ class Polygon(BoundingBoxArea): ...@@ -105,7 +109,7 @@ class Polygon(BoundingBoxArea):
for x, y in zip(*self.points): for x, y in zip(*self.points):
cr.line_to(x, y) cr.line_to(x, y)
cr.set_source_rgb(*self.fill_color) cr.set_source_rgb(*self.color)
cr.fill() cr.fill()
......
...@@ -114,7 +114,6 @@ def inside_shape(p, verts): ...@@ -114,7 +114,6 @@ def inside_shape(p, verts):
# Compute x intersection value # Compute x intersection value
xisect = x0 + (x1 - x0) * (y - y0) / (y1 - y0) xisect = x0 + (x1 - x0) * (y - y0) / (y1 - y0)
print xisect, x
if xisect >= x: if xisect >= x:
inside = not inside inside = not inside
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment