diff options
author | Bert Freudenberg <bert@freudenbergs.de> | 2012-11-05 01:01:57 (GMT) |
---|---|---|
committer | Bert Freudenberg <bert@freudenbergs.de> | 2012-11-05 01:01:57 (GMT) |
commit | fb7c9ebc779f33f14907dabba5f20573ac726a30 (patch) | |
tree | 4fd84ebe1c3092560f9e5b230566e4ebc96576f1 | |
parent | 505e8c7e890d550f9e0f49574248ad3a109bb03e (diff) |
Show current touches as circle and crosshair
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | activity.py | 19 |
2 files changed, 19 insertions, 1 deletions
@@ -1 +1,2 @@ +*.pyo dist/ diff --git a/activity.py b/activity.py index b09d20f..8e4fa8f 100644 --- a/activity.py +++ b/activity.py @@ -25,6 +25,7 @@ from gi.repository import Gtk from gi.repository import Gdk from random import random +from math import pi as M_PI from sugar3.activity import activity from sugar3.graphics.toolbarbox import ToolbarBox @@ -107,10 +108,26 @@ class TouchArea(Gtk.DrawingArea): self.queue_draw() def __draw_cb(self, widget, ctx): - ctx.set_line_width(5) + alloc = self.get_allocation() for seq in self.points: + # draw crosshair at last point + ctx.set_line_width(1) + ctx.set_source_rgb(0.5, 0.5, 0.5) + p = self.points[seq][-1] + ctx.move_to(p[0], 0) + ctx.line_to(p[0], alloc.height) + ctx.move_to(0, p[1]) + ctx.line_to(alloc.width, p[1]) + ctx.stroke() + # use finger's color (r, g, b) = self.colors[seq] ctx.set_source_rgb(r, g, b) + # draw circle at last point + ctx.set_line_width(10) + ctx.arc(p[0], p[1], 30, 0, 2 * M_PI) + ctx.stroke() + # draw trail from first to last point + ctx.set_line_width(5) p = self.points[seq][0] ctx.move_to(p[0], p[1]) for p in self.points[seq]: |