-
Notifications
You must be signed in to change notification settings - Fork 6
/
Century_021.pde
223 lines (177 loc) · 4.09 KB
/
Century_021.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/**
*
* Century
*
*/
import java.awt.Robot;
import java.awt.AWTException;
Robot robot;
Composition[] comps;
int[] order;
int[] randomOrder;
int newTimer = 0;
int nextTimer = 0;
int nextComposition = 1000;
int doubleTimer = 500;
int numClicks = 0;
int nextMicroTimer = 0;
int nextMicro = 100;
int current = 0;
int lastCurrent = 0;
int compositionCounter = 0;
int numCompositions = 20;
boolean introHidden = true; //SM
boolean debug = false;
int movedTimer = 0;
void setup() {
//size(1280, 720);
//size(320, 480);
//size(480, 320);
size(1024, 768);
//size(640, 960);
//size(1024, 768);
//size(screenWidth, screenHeight);
try {
robot = new Robot();
}
catch (AWTException e) {
e.printStackTrace();
}
smooth();
comps = new Composition[9];
order = new int[comps.length];
randomOrder = new int[comps.length];
for (int i = 0; i < order.length; i++) {
order[i] = i;
}
for (int r = 0; r < randomOrder.length; r++) {
int nextRand = 1;
if (r == 0) {
nextRand = int(random(1, order.length));
}
else {
nextRand = int(random(0, order.length));
}
randomOrder[r] = order[nextRand];
for (int i = 0; i < order.length; i++) {
if (i == nextRand) {
for (int j = nextRand; j < order.length-1; j++) {
order[j] = order[j+1];
}
}
}
order = shorten(order);
}
//println(randomOrder);
comps[randomOrder[0]] = new Molnar55();
comps[randomOrder[1]] = new Morellet60();
comps[randomOrder[2]] = new Martin();
comps[randomOrder[3]] = new MetaMetaMalevich();
comps[randomOrder[4]] = new Riley61();
comps[randomOrder[5]] = new Molnar();
comps[randomOrder[6]] = new LeWitt();
comps[randomOrder[7]] = new Kelly50();
comps[randomOrder[8]] = new Kelly50_2();
//comps[9] = new GG();
current = 0; //comps.length-1;
nextTimer = millis();
strokeCap(SQUARE);
}
void draw() {
if (frameCount == 1) {
robot.mouseMove(-width, -height);
} else if (frameCount == 2) {
robot.mouseMove(width/2, height/2);
//noCursor();
}
// Watch the clock and change to the next Composition
if ((millis() > nextTimer+nextComposition) && (movedTimer + 1000 < millis())) {
//println(movedTimer + "-" + (millis() + 1000));
if (compositionCounter >= numCompositions) {
current++;
if (current >= comps.length) {
current = 0;
}
compositionCounter = 0;
// ADD SOMETHING THERE TO SET A FIRST VARIABLE FOR A NEW COMPOSITION!!!
}
// Iterate to the next version of the current Composition
comps[current].compose();
comps[current].manage();
nextTimer = millis();
compositionCounter++;
}
// Update and display the current composition
//if (mousePressed == true) {
comps[current].manage();
//}
if (debug) {
console();
}
/*
strokeWeight(2);
noFill();
stroke(255);
ellipse(mouseX, mouseY, 12, 12);
stroke(0);
ellipse(mouseX, mouseY, 8, 8);
noStroke();
*/
}
void console() {
noStroke();
fill(0);
rect(0, 0, 100, 25);
fill(255);
text(int(frameRate), 5, 16);
}
void rawUpdate() {
comps[current].compose();
comps[current].manage();
}
void mousePressed() {
comps[current].pressEvent();
}
void mouseMoved() {
comps[current].dragEvent();
numClicks = 0;
movedTimer = millis();
//println("I moved!" + millis());
}
void mouseReleased() {
comps[current].releaseEvent();
nextTimer = millis();
}
void keyPressed() {
if (key == ' ') {
saveFrame();
}
if (key == CODED) {
if (keyCode == LEFT) {
goToPreviousComposition();
}
else if (keyCode == RIGHT) {
goToNextComposition();
}
}
}
void goToPreviousComposition() { //SM
current--;
if (current < 0) {
current = comps.length - 1;
}
compositionCounter = 0;
comps[current].compose();
nextTimer = 0; //millis();
//println("went to previous composition");
}
void goToNextComposition() { //SM
current++;
if (current >= comps.length) {
current = 0;
}
compositionCounter = 0;
comps[current].compose();
nextTimer = 0; //millis();
//println("went to next composition");
}