Commit 879ef48e authored by UVA Multi-touch's avatar UVA Multi-touch

Added fullscreen option to test draw program.

parent f1245e5d
#!/usr/bin/env python #!/usr/bin/env python
import pygame, sys, time import pygame
from touch import add, MultiTouchListener import sys
import time
from touch import add, MultiTouchListener, screen_size
from math import degrees, cos, sin from math import degrees, cos, sin
from events import Rotate from events import Rotate
pygame.init() pygame.init()
FULLSCREEN = '-f' in sys.argv[1:]
# Config # Config
FINGER_RADIUS = 20 FINGER_RADIUS = 20
CENTROID_RADIUS = 15 CENTROID_RADIUS = 15
W, H = 640, 480 W, H = screen_size if FULLSCREEN else (640, 480)
BG_COLOR = 0, 0, 0 BG_COLOR = 0, 0, 0
LINE_COLOR = 128, 128, 128 LINE_COLOR = 128, 128, 128
...@@ -30,6 +34,9 @@ BEAM_INCREMENT = .8 ...@@ -30,6 +34,9 @@ BEAM_INCREMENT = .8
# Create canvas GUI in the current thread # Create canvas GUI in the current thread
screen = pygame.display.set_mode((W, H)) screen = pygame.display.set_mode((W, H))
if FULLSCREEN:
pygame.display.toggle_fullscreen()
def rotate_point(point, axis, angle): def rotate_point(point, axis, angle):
px, py = point px, py = point
...@@ -125,7 +132,7 @@ def pinch(event): ...@@ -125,7 +132,7 @@ def pinch(event):
# Start touch event listener in separate thread # Start touch event listener in separate thread
listener = MultiTouchListener(verbose=1, tuio_verbose=0) listener = MultiTouchListener(verbose=0, tuio_verbose=0)
listener.bind('rotate', rotate) listener.bind('rotate', rotate)
listener.bind('pinch', pinch) listener.bind('pinch', pinch)
listener.bind('tap', lambda e: taps.append([coord(*e.xy), FINGER_RADIUS])) listener.bind('tap', lambda e: taps.append([coord(*e.xy), FINGER_RADIUS]))
...@@ -134,8 +141,15 @@ listener.bind('double_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [0])) ...@@ -134,8 +141,15 @@ listener.bind('double_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [0]))
listener.start(threaded=True) listener.start(threaded=True)
# Start GUI event loop # Start GUI event loop
import sys
try: try:
while not filter(lambda e: e.type == pygame.QUIT, pygame.event.get()): while True:
for e in pygame.event.get():
if e.type == pygame.QUIT or (e.type == pygame.KEYDOWN
and e.key == 113):
sys.exit()
update() update()
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment