Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
multitouch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
multitouch
Commits
6c3dfa9c
Commit
6c3dfa9c
authored
May 10, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some improvements to test draw program.
parent
e495a60f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
src/draw.py
src/draw.py
+8
-6
No files found.
src/draw.py
View file @
6c3dfa9c
#!/usr/bin/env python
#!/usr/bin/env python
import
pygame
,
sys
,
time
import
pygame
,
sys
,
time
from
touch
import
add
,
MultiTouchListener
from
touch
import
MultiTouchListener
from
math
import
degrees
,
cos
,
sin
from
math
import
degrees
,
cos
,
sin
from
events
import
Rotate
from
events
import
Rotate
...
@@ -19,14 +19,16 @@ RECT_COLOR = 0, 200, 0
...
@@ -19,14 +19,16 @@ RECT_COLOR = 0, 200, 0
RECT_POS
=
W
/
2
,
H
/
2
RECT_POS
=
W
/
2
,
H
/
2
RECT_SIZE
=
W
/
6.
,
H
/
6.
RECT_SIZE
=
W
/
6.
,
H
/
6.
TAP_RADIUS
=
6
0
TAP_RADIUS
=
6
5
TAP_INCREMENT
=
.
25
TAP_INCREMENT
=
.
3
BEAM_COLOR
=
255
,
50
,
50
BEAM_COLOR
=
255
,
50
,
50
BEAM_LENGTH
=
50
BEAM_LENGTH
=
50
BEAM_WIDTH
=
3
BEAM_WIDTH
=
3
BEAM_INCREMENT
=
.
8
BEAM_INCREMENT
=
.
8
MAX_SCALE
=
10
# 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
))
...
@@ -60,7 +62,7 @@ def update():
...
@@ -60,7 +62,7 @@ def update():
# Apply scale and rotation to a fixed-size rectangle canvas
# Apply scale and rotation to a fixed-size rectangle canvas
canvas
=
pygame
.
Surface
(
RECT_SIZE
)
canvas
=
pygame
.
Surface
(
RECT_SIZE
)
canvas
.
fill
(
RECT_COLOR
)
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
=
transformed
.
get_rect
()
rect
.
center
=
W
/
2
,
H
/
2
rect
.
center
=
W
/
2
,
H
/
2
screen
.
blit
(
transformed
,
rect
)
screen
.
blit
(
transformed
,
rect
)
...
@@ -121,13 +123,13 @@ def rotate(event):
...
@@ -121,13 +123,13 @@ def rotate(event):
def
pinch
(
event
):
def
pinch
(
event
):
global
scale
global
scale
scale
*=
event
.
amount
scale
=
max
(
scale
*
event
.
amount
,
MAX_SCALE
)
# Start touch event listener in separate thread
# Start touch event listener in separate thread
listener
=
MultiTouchListener
(
verbose
=
1
,
tuio_verbose
=
0
)
listener
=
MultiTouchListener
(
verbose
=
1
,
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
]))
listener
.
bind
(
'single_tap'
,
lambda
e
:
dtaps
.
append
(
list
(
coord
(
*
e
.
xy
))
+
[
1
]))
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
]))
listener
.
bind
(
'double_tap'
,
lambda
e
:
dtaps
.
append
(
list
(
coord
(
*
e
.
xy
))
+
[
0
]))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment