-
Notifications
You must be signed in to change notification settings - Fork 1
/
timeMosaic.pde
67 lines (46 loc) · 1.17 KB
/
timeMosaic.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
// timeMozaic
// big up to Ben Fry for the grid
int column;
int columnCount;
int row;
int rowCount;
int lastRow;
int imgWidth = 64;
int imgHeight = 48;
int[] scoot;
File[] myFiles;
int curFileIndex=0;
PImage curImg;
void setup() {
size(640, 480, P2D);
column = 0;
columnCount = width / imgWidth;
row = 0;
rowCount = height / imgHeight;
lastRow = rowCount - 1;
scoot = new int[lastRow*imgHeight * width];
background(0);
String data = dataPath("");
myFiles = listFiles(data);
}
void draw() {
if (curFileIndex == myFiles.length){
curFileIndex=0;
}
println(myFiles[curFileIndex].getName());
curImg = loadImage(myFiles[curFileIndex].getName());
curImg.resize(imgWidth, imgHeight);
set(curImg.width*column, curImg.height*lastRow, curImg);
column++;
if (column == columnCount) {
loadPixels();
arraycopy(pixels, curImg.height*width, scoot, 0, scoot.length);
arraycopy(scoot, 0, pixels, 0, scoot.length);
for (int i = scoot.length; i < width*height; i++) {
pixels[i] = #000000;
}
column = 0;
updatePixels();
}
curFileIndex++;
}