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
cd83ef17
Commit
cd83ef17
authored
Apr 27, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First attempt to fix pinch (failed).
parent
a76d047d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
src/draw.py
src/draw.py
+7
-4
src/events.py
src/events.py
+1
-1
src/touch.py
src/touch.py
+10
-0
No files found.
src/draw.py
View file @
cd83ef17
...
...
@@ -44,20 +44,23 @@ def coord(x, y):
# Rotated rectangle
angle
=
0
scale
=
1
w
,
h
=
W
,
H
def
update
():
global
rotations
global
rotations
,
w
,
h
,
scale
cx
,
cy
=
coord
(
*
listener
.
centroid
)
# Clear previous frame
screen
.
fill
(
BG_COLOR
)
# Apply rotation to rectangle canvas
canvas
=
pygame
.
Surface
((
W
,
H
))
canvas
=
pygame
.
Surface
((
w
,
h
))
canvas
.
fill
(
BG_COLOR
)
pygame
.
draw
.
rect
(
canvas
,
RECT_COLOR
,
RECT_POS
+
RECT_SIZE
)
w
,
h
=
int
(
round
(
scale
*
w
)),
int
(
round
(
scale
*
h
))
scale
=
1
scaled_canvas
=
pygame
.
transform
.
scale
(
canvas
,
coord
(
scale
,
scale
))
scaled_canvas
=
pygame
.
transform
.
scale
(
canvas
,
(
w
,
h
))
rotated_canvas
=
pygame
.
transform
.
rotate
(
scaled_canvas
,
degrees
(
angle
))
rect
=
rotated_canvas
.
get_rect
()
rect
.
center
=
W
/
2
,
H
/
2
...
...
@@ -85,7 +88,7 @@ def rotate(event):
def
pinch
(
event
):
global
scale
scale
+
=
event
.
amount
scale
=
event
.
amount
# Start touch event listener in separate thread
...
...
src/events.py
View file @
cd83ef17
...
...
@@ -88,7 +88,7 @@ class PinchEvent(GestureEvent):
_name
=
'pinch'
def
__init__
(
self
,
cx
,
cy
,
amount
,
n
):
super
(
Rotate
Event
,
self
).
__init__
(
cx
,
cy
)
super
(
Pinch
Event
,
self
).
__init__
(
cx
,
cy
)
self
.
amount
=
amount
self
.
n
=
n
...
...
src/touch.py
View file @
cd83ef17
...
...
@@ -270,9 +270,19 @@ class MultiTouchListener(Logger):
p
.
update
(
x
,
y
)
self
.
update_centroid
(
moving
=
p
)
self
.
trigger
(
MoveEvent
(
p
))
self
.
detect_pinch
(
p
)
# TODO: Detect pan
def
detect_pinch
(
self
,
moved
):
cx
,
cy
=
self
.
centroid
dist
=
moved
.
distance_to
(
cx
,
cy
)
old_dist
=
distance
((
moved
.
px
,
moved
.
py
),
self
.
centroid
)
if
abs
(
dist
-
old_dist
)
>
DIST_THRESHOLD
:
self
.
trigger
(
PinchEvent
(
cx
,
cy
,
dist
/
old_dist
,
len
(
self
.
points
)))
def
stop
(
self
):
self
.
log
(
'Stopping event loop'
)
...
...
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