-
Notifications
You must be signed in to change notification settings - Fork 1
/
gestureRecognition.pde
41 lines (32 loc) · 1.15 KB
/
gestureRecognition.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
// Search for gestures
void gestureRecognition() {
// Display the gesuture at the bottom
if (time - gesture.time < 800) {
textAlign(CENTER);
textSize(40);
float alpha = map (time - gesture.time, 0, 800, 0, 255);
fill(alpha);
text(gesture.gesture, width/2, height - 60);
} else {
gesture.gesture = "none";
}
// Check for swipes
if (movementXHistory.size() > 3) {
int size = movementXHistory.size();
if (movementXHistory.get(size-3).movement == "right" && movementXHistory.get(size-2).movement == "left" && movementXHistory.get(size-1).movement == "noX") {
gestureCounter++;
gesture.gesture = "Swipe Right";
gesture.id = gestureCounter;
gesture.time = time;
gestureHistory.add(gesture);
movementXHistory.add(right);
} else if (movementXHistory.get(size-3).movement == "left" && movementXHistory.get(size-2).movement == "right" && movementXHistory.get(size-1).movement == "noX") {
gestureCounter++;
gesture.gesture = "Swipe Left";
gesture.id = gestureCounter;
gesture.time = time;
gestureHistory.add(gesture);
movementXHistory.add(left);
}
}
}