-
Notifications
You must be signed in to change notification settings - Fork 0
/
genie_2_manyStyles.pde
176 lines (167 loc) · 6 KB
/
genie_2_manyStyles.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
int pics = 1; // how many pics fo you want to save? //<>// //<>//
//int num = 6; // what kind of shapes? 1: vertex polygon, 2: arcs, 3: polygon + arc
int num = int(random(1, 7));
//these arent being used.. doing random
int divsLow = 2; // how many divison lines? this number minus 1 is the total number of divisons
int divsHigh = 20; // max
int vertexesLow = 3; // how many vertexes for each shape? min
int vertexesHigh = 3; // max
int shapesLow = 2; // how many shapes? min
int shapesHigh = 50; // max
int fadeVar = int(random(1, 8)); // how quickly the shapes fade away
int divs;
int vertexes;
int shapes;
int xyArraySize = vertexes*shapes;
int[] colarray = new int[divs];
int[] colArray2 = new int[shapes];
int[] randomArray = new int[divs];
int[] xArray = new int[xyArraySize];
int[] yArray = new int[xyArraySize];
void setup() {
size(1024, 512);
//background(0); // no background needed
noStroke();
//noLoop(); // only run the code once
}
public void draw () {
//for (int k=0; k<pics; k++) { // save each time through
// create a random array with pixel numbers in the x direction we are slicing
// create random color array
divs = int(random(divsLow, divsHigh)); // create random number of divs between x and y...
vertexes = int(random(vertexesLow, vertexesHigh)); // ^
shapes = int(random(shapesLow, shapesHigh));
int xyArraySize = vertexes*shapes;
int[] colarray = new int[divs];
int[] colArray2 = new int[shapes];
int[] randomArray = new int[divs];
int[] xArray = new int[xyArraySize];
int[] yArray = new int[xyArraySize];
for (int i = 0; i < divs; i++) {
colarray[i] = color(random(255), random(255), random(255));
randomArray[i] = int(random(width));
}
for (int i =0; i<xyArraySize; i++) {
xArray[i] = int(random(width));
yArray[i] = int(random(height));
}
for (int i=0; i<shapes; i++) {
colArray2[i] = color(random(255), random(255), random(255));
}
randomArray[0] = 0; // make first x value 0, this is the starting point (0,0);
randomArray[divs-1] = width; // last value needs to be the final pixel so the div 'background' covers the whole screen.
randomArray = sort(randomArray); // sort from lowest to highest so we can cycle through and make boxes
// BACKGROUND - create random rectangles with random colors
for (int i = 0; i < divs-1; i++) {
fill(colarray[i]);
rect(randomArray[i], 0, randomArray[i+1], height); // Draw rectangle
}
//SHAPES
switch(num) {
//Vertx polygons
case 1:
for (int i=0; i<shapes; i++) { //draw the shapes
fill(colArray2[i], 255-(i*fadeVar));
beginShape();
for (int j = 0; j<vertexes; j++) { // vertex of each shape drawing
int arrayIndex = j+(vertexes*i); //TODO FIGURE THIS INDEX THING OUT
//if (i>0 && j==0) {
//arrayIndex = (j+1)*(i+1);
//}
vertex(xArray[arrayIndex], yArray[arrayIndex]);
}
endShape();
}
break;
// Arcs
case 2:
for (int i=0; i<shapes; i++) { //draw the shapes
fill(colArray2[i], 255-(fadeVar*i));
//for (int j = 0; j<4; j++) {
int arrayIndex = (i*2);
arc(xArray[arrayIndex], yArray[arrayIndex], int(random(100, 900)), int(random(300.900)), random(0, 2*PI), random(0, 2*PI), OPEN);
//}
}
break;
//Vertex Polygons + Arcs
case 3:
for (int i=0; i<shapes; i++) { //draw the shapes
fill(colArray2[i], 255-(i*fadeVar));
beginShape();
for (int j = 0; j<vertexes; j++) { // vertex of each shape drawing
int arrayIndex = j+(vertexes*i); //TODO FIGURE THIS INDEX THING OUT
//if (i>0 && j==0) {
//arrayIndex = (j+1)*(i+1);
//}
vertex(xArray[arrayIndex], yArray[arrayIndex]);
}
endShape();
}
for (int i=0; i<shapes; i++) { //draw the shapes
fill(colArray2[i], 255-(fadeVar*i));
//for (int j = 0; j<4; j++) {
int arrayIndex = (i*2);
arc(xArray[arrayIndex], yArray[arrayIndex], int(random(100, 900)), int(random(300.900)), random(0, 2*PI), random(0, 2*PI), OPEN);
//}
}
break;
// Squares
case 4:
for (int i=0; i<shapes; i++) { //draw the shapes
fill(colArray2[i], 255-(fadeVar*i));
//for (int j = 0; j<4; j++) {
int arrayIndex = (i*2);
square(xArray[arrayIndex], yArray[arrayIndex], xArray[arrayIndex+1]/fadeVar);
}
break;
//Squares + Arcs
case 5:
for (int i=0; i<shapes; i++) { //draw the shapes
fill(colArray2[i], 255-(fadeVar*i));
//for (int j = 0; j<4; j++) {
int arrayIndex = (i*2);
square(xArray[arrayIndex], yArray[arrayIndex], xArray[arrayIndex+1]/fadeVar);
}
for (int i=0; i<shapes; i++) { //draw the shapes
fill(colArray2[i], 255-(fadeVar*i));
//for (int j = 0; j<4; j++) {
int arrayIndex = (i*2);
arc(xArray[arrayIndex], yArray[arrayIndex], int(random(100, 900)), int(random(300.900)), random(0, 2*PI), random(0, 2*PI), OPEN);
//}
}
break;
case 6:
//squares + arcs + polygons
for (int i=0; i<shapes/2; i++) { //draw the shapes
fill(colArray2[i], 255-(i*fadeVar));
beginShape();
for (int j = 0; j<vertexes; j++) { // vertex of each shape drawing
int arrayIndex = j+(vertexes*i); //TODO FIGURE THIS INDEX THING OUT
//if (i>0 && j==0) {
//arrayIndex = (j+1)*(i+1);
//}
vertex(xArray[arrayIndex], yArray[arrayIndex]);
}
endShape();
}
for (int i=0; i<shapes; i++) { //draw the shapes
fill(colArray2[i], 255-(fadeVar*i));
//for (int j = 0; j<4; j++) {
int arrayIndex = (i*2);
square(xArray[arrayIndex], yArray[arrayIndex], xArray[arrayIndex+1]/fadeVar);
}
for (int i=0; i<shapes; i++) { //draw the shapes
fill(colArray2[i], 255-(fadeVar*i));
//for (int j = 0; j<4; j++) {
int arrayIndex = (i*2);
arc(xArray[arrayIndex], yArray[arrayIndex], int(random(100, 900)), int(random(300.900)), random(0, 2*PI), random(0, 2*PI), OPEN);
//}
}
break;
}
if (frameCount == pics) {
noLoop();
}
saveFrame("output.png");
exit();
}