Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristhofer Travieso <cristhofert97@gmail.com>2012-09-01 15:43:54 (GMT)
committer Cristhofer Travieso <cristhofert97@gmail.com>2012-09-01 15:43:54 (GMT)
commitcbb8b7299ce02b1304e00e840c98017367f1b820 (patch)
tree374689ef41c811d2d29d817f58cf3a37137b1509
parentb54f1378dcfe728ebe6584dba93b0672c7ddb1d6 (diff)
Draw circles at mouse position
-rwxr-xr-xgame.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/game.py b/game.py
index 199bb6e..a40d99f 100755
--- a/game.py
+++ b/game.py
@@ -47,7 +47,7 @@ class Canvas(Gtk.DrawingArea):
self.connect('draw', self._draw_cb)
self.connect('button-press-event', self._click_cb)
- self.show_all()
+ self.show_all()
def set_mode(self, mode=MODE_CIRCLE):
self._mode = mode
@@ -68,7 +68,7 @@ class Canvas(Gtk.DrawingArea):
context.set_source_rgb(*stroke)
context.set_line_width(12)
context.set_line_cap(cairo.LINE_CAP_ROUND)
-
+
x = (alloc.width - BETWEEN_LINE_SPACE * 3) / 2
y = (alloc.height - BETWEEN_LINE_SPACE * 3) / 2
@@ -101,11 +101,21 @@ class Canvas(Gtk.DrawingArea):
context.arc(x, y, SIZE / 2, 0, 360)
context.stroke()
+ context.set_source_rgb(*fill)
+ for cross in self._crosses:
+ x, y = cross
+ a = BETWEEN_LINE_SPACE / 2
+ context.move_to(x - a, y - a)
+ context.line_to(x + a, y + a)
+
+ context.move_to(x + a, y - a)
+ context.line_to(x - a, y + a)
+ context.stroke()
# TODO: Create a function for draw crosses
def _click_cb(self, widget, event):
pos = self.get_pos(event.x, event.y)
-
+
if self._mode == MODE_CIRCLE and pos:
self._circles.append(pos)
@@ -126,4 +136,3 @@ if __name__ == "__main__":
window.maximize()
window.show_all()
Gtk.main()
-