From fb7c9ebc779f33f14907dabba5f20573ac726a30 Mon Sep 17 00:00:00 2001 From: Bert Freudenberg Date: Mon, 05 Nov 2012 01:01:57 +0000 Subject: Show current touches as circle and crosshair --- diff --git a/.gitignore b/.gitignore index 849ddff..e2e795a 100644 --- a/.gitignore +++ b/.gitignore @@ -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]: -- cgit v0.9.1