Skip to content
Snippets Groups Projects
Commit 55dbb2eb authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Added polygon color change on double tap.

parent 010cb2bc
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment