-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompressArray.pde
52 lines (51 loc) · 1.28 KB
/
CompressArray.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
class CompressArray{
int oldSize;
int newSize;
int factor;
float period;
int count;
int changed;
CompressArray(int oldSize, int newSize){
this.oldSize = oldSize;
this.newSize = newSize;
factor = newSize-oldSize;
period = (newSize/abs(float(factor)))-1;
count = 0;
changed = 0;
}
void cMain(){
if (factor < 0){ //<>//
for (int i = 0; i < oldSize; i++){
if (count > ceil(period)){
compArray.remove(i-changed);
if (debug){
println(compArray);
}
changed++;
count = -1;
}
count++;
}
}
if (factor > 0){
int perNewCel = (int)((float)newSize / (float)oldSize);
println(newSize +" / "+ oldSize +" = "+ perNewCel);
int celCount = 0;
compArray = new ArrayList<Integer>();
for (int i = 0; i < newSize; i++) {
compArray.add(celCount);
//println(i - celCount*perNewCel +", "+ perNewCel);
if (i - celCount*perNewCel >= perNewCel) {
celCount++;
}
}
int x = 0;
for (int i = 0; i < compArray.size(); i++) {
if (x == compArray.get(i)) {
x++;
println(x + ", " + str((x*perNewCel)));
}
}
}
}
}