-
Notifications
You must be signed in to change notification settings - Fork 2
/
prototyp2.pde
161 lines (153 loc) · 3.29 KB
/
prototyp2.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//luther poster
PImage bgr,p1,p2,p3,p4;
int time;
int currMode=0;
PShape zacken;
boolean showText=false;
int yPosTextbox=1920-250;
//headtracking
HeadTrackingCam myCam;
void setup(){
//init
size(1080, 1920, P3D);
myCam = new HeadTrackingCam(this);
myCam.safePrepareHeadTracking();
prepareImages();
prepareShape();
}
void prepareShape(){
zacken= createShape();
zacken.beginShape();
zacken.fill(255, 196);
zacken.noStroke();
zacken.vertex(0, 0);
zacken.vertex(100, 0);
zacken.vertex(50, -50);
zacken.endShape();
}
void prepareImages(){
//bgr image
bgr = loadImage("bgr_fullhd.jpg");
tint(255, 128);
image(bgr, 0, 0);
//peeps
tint(255, 255);
p1 = loadImage("person1_fullhd_240offset.png");
image(p1, 0, 240);
p2 = loadImage("person2_fullhd_240offset.png");
image(p2, 0, 240);
p3 = loadImage("person3_fullhd_240offset.png");
image(p3, 0, 240);
p4 = loadImage("person4_fullhd_240offset.png");
image(p4, 1080-p4.width, 240); //right aligned
}
void draw(){
float pos = mouseX;
if( myCam.headTrackingEnabled )
{
myCam.processHeadTracking();
myCam.showVideo(0,0);
pos= (1.0-myCam.percentages.x) * width;
}
highlightImages(int(pos));
}
int determineMode(int xpos)
{
if(xpos < 320)
{
return 1;
}
else if(xpos > 320 && xpos < 600)
{
return 2;
}
else if(xpos > 600 && xpos < 800)
{
return 3;
}
else if(xpos > 800)
{
return 4;
}
return 0;
}
void highlightImages(int xpos)
{
int newMode = determineMode(xpos);
if(millis() - time >= 5000)
{
tint(255, 255);//show 100%
image(bgr, 0, 0);
}
if( newMode != currMode) // change!
{
time=millis();
currMode=newMode;
background(255);
if(currMode==1)
{
tint(255, 128); //show half transparent
image(bgr, 0, 0);
tint(255, 255);//show 100%
image(p1, 0, 240);
}
else if(currMode==2)
{
tint(255, 128); //show half transparent
image(bgr, 0, 0);
tint(255, 255);//show 100%
image(p2, 0, 240);
}
else if(currMode==3)
{
tint(255, 128); //show half transparent
image(bgr, 0, 0);
tint(255, 255);//show 100%
image(p3, 0, 240);
}
else if(currMode==4)
{
tint(255, 128); //show half transparent
image(bgr, 0, 0);
tint(255, 255);//show 100%
image(p4, 1085-p4.width, 240);
}
drawTextbox();
}
}
void keyPressed() {
if (key == 'T' || key == 't') {
showText=!showText;
}
else
{
myCam.keyboardInput(key);
}
}
void drawTextbox()
{
fill(255, 196);
noStroke();
rect(0, yPosTextbox, width, 250);
int xpos = 40;
if( currMode==2)
xpos = 450;
else if( currMode==3)
xpos = 700;
else if( currMode==4)
xpos = 900;
shape(zacken, xpos, yPosTextbox);
if( showText )
{
fill(0,255);
textSize(80);
text("Lorem ipsum", 50, yPosTextbox+75);
textSize(32);
String s = "dolor sit amet, consectetur adipiscing elit. Pellentesque porttitor tortor urna. Maecenas vitae ligula sed lectus ultricies ullamcorper ut sed nisi. Pellentesque eget nisl consectetur.";
text(s, 55, yPosTextbox+105, width-100, 200);
}
}
void captureEvent(Capture c) {
//Propagate Capture Event
myCam.captureEvent(c);
}