This file is indexed.

/usr/share/pymt-examples/apps/touchtracer/touchtracer.py is in python-pymt 0.5.1-0ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# PYMT Plugin integration
IS_PYMT_PLUGIN = True
PLUGIN_TITLE = 'Touch Tracer'
PLUGIN_AUTHOR = 'Thomas Hansen'
PLUGIN_DESCRIPTION = ''

from OpenGL.GL import *
from pymt import *
import os
from os.path import join

current_dir = os.path.dirname(__file__)
crosshair = Image.load(join(current_dir, 'crosshair.png'))
crosshair.scale = 0.6


def drawCrossLabel(x, y, ID):
    drawLabel('ID: %s' % str(ID), pos=(x+30, y),
              font_size=12, anchor_x='left', anchor_y='bottom')
    drawLabel('x:%d y:%d' % (int(x), int(y)), pos=(x+30, y),
              font_size=10, anchor_x='left', anchor_y='top')
    crosshair.x = x - (crosshair.width / 2.) * crosshair.scale
    crosshair.y = y - (crosshair.height / 2.) * crosshair.scale
    crosshair.draw()


class TouchTracer(MTWidget):
    def __init__(self, **kwargs):
        super(TouchTracer, self).__init__(**kwargs)
        self.touchPositions = {}

    def on_touch_down(self, touch):
        color = get_random_color()
        self.touchPositions[touch.id] = [(touch.id,color,touch.x,touch.y)]


    def on_touch_up(self, touch):
        if touch.id in self.touchPositions:
            del self.touchPositions[touch.id]


    def on_touch_move(self, touch):
        if touch.id in self.touchPositions:
            # don't append same position on the line
            if len(self.touchPositions[touch.id]) > 1:
                pos = self.touchPositions[touch.id][-1]
                if int(pos[0]) == int(touch.x) and int(pos[1]) == int(touch.y):
                    return
            self.touchPositions[touch.id].append((touch.x,touch.y))


    def draw(self):
        set_brush(join(current_dir, 'particle.png'), 10)
        w = self.get_parent_window()
        set_color(.1, .1, .1)
        drawRectangle(size=w.size)
        for p in self.touchPositions:
            lines = []
            touchID,color,x,y = self.touchPositions[p][0]
            set_color(*color)
            lines += [x, y]
            for pos in self.touchPositions[p][1:]:
                lines += pos
            if len(lines) > 2:
                paintLine(lines)
            x, y = lines[-2:]
            drawCrossLabel(x, y, touchID)

def pymt_plugin_activate(w, ctx):
    ctx.c = TouchTracer()
    w.add_widget(ctx.c)

def pymt_plugin_deactivate(w, ctx):
    w.remove_widget(ctx.c)

if __name__ == '__main__':
    w = MTWindow()
    ctx = MTContext()
    pymt_plugin_activate(w, ctx)
    runTouchApp()
    pymt_plugin_deactivate(w, ctx)