A simple touch tracer
Require PyMT 0.4 ou 0.5
from pymt import *
class Tracer(MTWidget):
def on_touch_down(self, touch):
touch.userdata['points'] = list(touch.pos)
def on_touch_move(self, touch):
touch.userdata['points'].extend(touch.pos)
def draw(self):
# draw a black background
set_color(0, 0, 0)
drawRectangle(size=getWindow().size)
# draw lines
set_color(1, 1, 1)
for touch in getCurrentTouches():
drawLine(touch.userdata['points'])
runTouchApp(Tracer())
class Tracer(MTWidget):
def on_touch_down(self, touch):
touch.userdata['points'] = list(touch.pos)
def on_touch_move(self, touch):
touch.userdata['points'].extend(touch.pos)
def draw(self):
# draw a black background
set_color(0, 0, 0)
drawRectangle(size=getWindow().size)
# draw lines
set_color(1, 1, 1)
for touch in getCurrentTouches():
drawLine(touch.userdata['points'])
runTouchApp(Tracer())
