Commit 6c3dfa9c authored by Taddeus Kroes's avatar Taddeus Kroes

Added some improvements to test draw program.

parent e495a60f
#!/usr/bin/env python
import pygame, sys, time
from touch import add, MultiTouchListener
from touch import MultiTouchListener
from math import degrees, cos, sin
from events import Rotate
......@@ -19,14 +19,16 @@ RECT_COLOR = 0, 200, 0
RECT_POS = W / 2, H / 2
RECT_SIZE = W / 6., H / 6.
TAP_RADIUS = 60
TAP_INCREMENT = .25
TAP_RADIUS = 65
TAP_INCREMENT = .3
BEAM_COLOR = 255, 50, 50
BEAM_LENGTH = 50
BEAM_WIDTH = 3
BEAM_INCREMENT = .8
MAX_SCALE = 10
# Create canvas GUI in the current thread
screen = pygame.display.set_mode((W, H))
......@@ -60,7 +62,7 @@ def update():
# Apply scale and rotation to a fixed-size rectangle canvas
canvas = pygame.Surface(RECT_SIZE)
canvas.fill(RECT_COLOR)
transformed = pygame.transform.rotozoom(canvas, degrees(angle), scale * 2)
transformed = pygame.transform.rotozoom(canvas, degrees(angle), scale)
rect = transformed.get_rect()
rect.center = W / 2, H / 2
screen.blit(transformed, rect)
......@@ -121,13 +123,13 @@ def rotate(event):
def pinch(event):
global scale
scale *= event.amount
scale = max(scale * event.amount, MAX_SCALE)
# Start touch event listener in separate thread
listener = MultiTouchListener(verbose=1, tuio_verbose=0)
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('single_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [1]))
listener.bind('double_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [0]))
......
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