forked from nok/leap-motion-processing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2_gestures.pde
101 lines (80 loc) · 2.5 KB
/
e2_gestures.pde
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(800, 500, OPENGL);
background(255);
// ...
leap = new LeapMotion(this).withGestures();
// leap = new LeapMotion(this).withGestures("circle, swipe, screen_tap, key_tap");
// leap = new LeapMotion(this).withGestures("swipe"); // Leap detects only swipe gestures.
}
void draw(){
background(255);
// ...
}
// ----- SWIPE GESTURE -----
void leapOnSwipeGesture(SwipeGesture g, int state){
int id = g.getId();
Finger finger = g.getFinger();
PVector position = g.getPosition();
PVector position_start = g.getStartPosition();
PVector direction = g.getDirection();
float speed = g.getSpeed();
long duration = g.getDuration();
float duration_seconds = g.getDurationInSeconds();
switch(state){
case 1: // Start
break;
case 2: // Update
break;
case 3: // Stop
println("SwipeGesture: "+id);
break;
}
}
// ----- CIRCLE GESTURE -----
void leapOnCircleGesture(CircleGesture g, int state){
int id = g.getId();
Finger finger = g.getFinger();
PVector position_center = g.getCenter();
float radius = g.getRadius();
float progress = g.getProgress();
long duration = g.getDuration();
float duration_seconds = g.getDurationInSeconds();
int direction = g.getDirection();
switch(state){
case 1: // Start
break;
case 2: // Update
break;
case 3: // Stop
println("CircleGesture: "+id);
break;
}
switch(direction){
case 0: // Anticlockwise/Left gesture
break;
case 1: // Clockwise/Right gesture
break;
}
}
// ----- SCREEN TAP GESTURE -----
void leapOnScreenTapGesture(ScreenTapGesture g){
int id = g.getId();
Finger finger = g.getFinger();
PVector position = g.getPosition();
PVector direction = g.getDirection();
long duration = g.getDuration();
float duration_seconds = g.getDurationInSeconds();
println("ScreenTapGesture: "+id);
}
// ----- KEY TAP GESTURE -----
void leapOnKeyTapGesture(KeyTapGesture g){
int id = g.getId();
Finger finger = g.getFinger();
PVector position = g.getPosition();
PVector direction = g.getDirection();
long duration = g.getDuration();
float duration_seconds = g.getDurationInSeconds();
println("KeyTapGesture: "+id);
}