-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrawingBoard.pde
84 lines (74 loc) · 1.68 KB
/
DrawingBoard.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
class DrawingBoard {
ArrayList<Integer> xPos;
ArrayList<Integer> yPos;
float alpha;
int target;
int count;
boolean fadeInFlag, fadeOutFlag,matchFlag;
String[] targets={"Mountain", "House", "Wind", "Tree", "Moon","Star"};
DrawingBoard(int _target) {
alpha=0;
target=_target;
fadeInFlag=true;
fadeOutFlag=false;
matchFlag=false;
count=0;
xPos=new ArrayList<Integer>();
yPos=new ArrayList<Integer>();
textAlign(CENTER);
}
void fadeIn() {
alpha+=2;
if (alpha>=150) {
alpha=150;
fadeInFlag=false;
}
}
boolean fadeOut() {
alpha-=2;
if (alpha<=0) {
alpha=0;
fadeOutFlag=false;
return true;
}
return false;
}
void drawOn() {
// for drawboard fade in fade o
if (fadeInFlag)
fadeIn();
if (fadeOutFlag)
fadeOut();
if(matchFlag) count++;
fill(0, alpha);
noStroke();
rect(0, 0, width, height);
fill(255, 200);
text("Draw "+targets[target], width/2, 50);
// save user mouse drawing information
if (mousePressed) {
xPos.add(mouseX);
yPos.add(mouseY);
//Send the OSC message
sendOsc();
}
// user drawing
stroke(255, 200);
strokeWeight(5);
for (int i=0; i<xPos.size(); i++) {
point(xPos.get(i), yPos.get(i));
}
}
void checkRightDrawing(int input) {
if (input==target) {
matchFlag=true;
fadeOutFlag=true;
}
}
void sendOsc() {
OscMessage msg = new OscMessage("/wek/inputs");
msg.add((float)mouseX);
msg.add((float)mouseY);
oscP5.send(msg, dest);
}
}