forked from hugosaintemarie/Silhouettes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunified.pde
More file actions
179 lines (144 loc) · 3.32 KB
/
Copy pathunified.pde
File metadata and controls
179 lines (144 loc) · 3.32 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import codeanticode.syphon.*;
SyphonServer server;
Onde onde;
Barrage barrage;
Bordel bordel;
Chute chute;
Nuee nuee;
Pluie pluie;
Discours discours;
SubSketch[] subs;
int activeSub = -1;
PGraphics p;
float blackFactor;
float blackTarget;
float blackSpeed;
void settings() {
size(1440, 900, P3D);
PJOGL.profile=1;
}
void setup() {
//size(300,300,P3D);
server = new SyphonServer(this, "Processing Syphon");
p = createGraphics(width,height,P3D);
barrage = new Barrage(this, 400, 600);
bordel = new Bordel(this, 400, 600);
chute = new Chute(this, 400, 600);
nuee = new Nuee(this, 400, 600);
pluie = new Pluie(this, 400, 600);
onde = new Onde(this, 250, 600);
discours = new Discours(this, 400, 600);
subs = new SubSketch[5];
subs[0] = pluie;
subs[1] = barrage;
subs[2] = chute;
subs[3] = nuee;
subs[4] = bordel;
println("Ready");
discours.active = true;
onde.active = true;
blackFactor = 0;
blackTarget = 0;
blackSpeed = .03;
}
void setSubActive(int sub)
{
if(activeSub >= 0)
{
subs[activeSub].active = false;
}
activeSub = sub;
if(activeSub >= 0)
{
subs[activeSub].active = true;
}
}
void draw() {
background(180);
p.beginDraw();
p.background(255);
for (SubSketch ss : subs) ss.drawBase();
for (SubSketch ss : subs)
{
if (ss.active) p.image(ss, 0, 0);
}
if(discours.active)
{
discours.drawBase();
p.image(discours, 700,0);
}
if(onde.active)
{
onde.drawBase();
p.image(onde, 1150,0);
}
blackFactor = blackFactor+(blackTarget-blackFactor)*blackSpeed;
p.fill(0,blackFactor*255);
p.rect(0,0,p.width,p.height);
p.endDraw();
image(p,0,0);
noFill();
stroke(0);
strokeWeight(1);
rect(0,0,400,600);
int index = 0;
for (SubSketch ss : subs)
{
fill(activeSub == index?color(255,0,0):color(0));
if(activeSub >= 0) text((index+1)+" : "+ss.name,550,30+index*30);
index++;
}
fill(0);
if(discours.active) text("Discours",550,500);
if(onde.active) text("Onde",550,550);
server.sendImage(p);
};
void keyPressed() {
switch(key)
{
case 'a':
setSubActive(0);
break;
case 'z':
setSubActive(1);
break;
case 'e':
setSubActive(2);
break;
case 'r':
setSubActive(3);
break;
case 't':
setSubActive(4);
break;
//case ',':
//discours.active = !discours.active;
//break;
case 'k':
blackTarget = 1-blackTarget;
break;
case ';':
onde.active = !onde.active;
break;
}
for (SubSketch ss : subs) ss.keyPressedBase();
if(discours.active) discours.keyPressedBase();
if(onde.active) onde.keyPressedBase();
}
void mouseReleased() {
for (SubSketch ss : subs) ss.mouseReleasedBase();
if(discours.active) discours.mouseReleasedBase();
if(onde.active) onde.mouseReleasedBase();
}
void mousePressed()
{
for (SubSketch ss : subs) ss.mousePressedBase();
if(discours.active) discours.mousePressedBase();
if(onde.active) onde.mousePressedBase();
}
void mouseDragged()
{
for (SubSketch ss : subs) ss.mouseDraggedBase();
if(discours.active) discours.mouseDraggedBase();
if(onde.active) onde.mouseDraggedBase();
}