-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriEvolution.pde
More file actions
81 lines (65 loc) · 1.68 KB
/
TriEvolution.pde
File metadata and controls
81 lines (65 loc) · 1.68 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
PImage target;
float mutateFactor = 0.01;
int numElements = 500;
Tri[] tris;
Tri[] tris_old;
long compare_old = 2147483640;
long compare_new = 0;
int iterations = 0;
int improvements = 0;
float ratio = 1.0;
int divisor = 1;
void setup() {
target = loadImage("test.jpg");
size(target.width, target.height);
noStroke(); //comment out to see outlines
tris = new Tri[numElements];
tris_old = new Tri[numElements];
//println("Hello");
for (int ii = 0; ii < numElements; ii++) {
tris[ii] = new Tri();
//println(ii);
}
}
void draw() {
//println("In loop... ");
iterations++;
background(0);
//arrayCopy(tris,tris_old);
for (int ii = 0; ii < numElements; ii++) {
tris[ii].store();
tris[ii].mutate();
tris[ii].draws();
}
compare_old = compare_new;
compare_new = compare();
ratio = float(improvements)/float(iterations);
if (compare_new < compare_old) {
improvements++;
println("Diff: " + compare_new + "\tIterations: " + iterations +"\tImprovements: " + improvements + "\tRatio: " + ratio);
}
else {
for (int ii = 0; ii < numElements; ii++) {
tris[ii].recall();
//compare_new = compare_old;
}
}
/*
//compare_old = compare_new;
compare_new = compare();
ratio = float(improvements)/float(iterations);
if(compare_new < compare_old) {
println("Diff: " + compare_old + "\tIterations: " + iterations +"\tImprovements: " + improvements + "\tRatio: " + ratio);
improvements++;
compare_old = compare_new;
}
else {
//println("else");
for (int ii = 0; ii < numElements; ii++) {
tris[ii] = tris_old[ii];
}
compare_new = compare_old;
}
//delay(1000);
*/
}