-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtime.pde
44 lines (36 loc) · 1.04 KB
/
time.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
PImage[] manyFrames = new PImage[frameNom];
void timeTravel(PImage input) {
//if first frame empty, create new and copy from input
if (manyFrames[0] == null) {
manyFrames[0] = new PImage();
}
// get a new frame
manyFrames[0] = input.copy();
// copy every frame to next frame in array, backwards
for (int i = manyFrames.length-2; i>=0; i--) {
if (manyFrames[i]!=null) {
manyFrames[i+1] = manyFrames[i].copy();
}
}
}
////////
void showTimeTravel2() {
int passDownStep = 100;
if (millis() - passDownTemp > passDownStep) {
if (iFrame > manyFrames.length - 1) {
iFrame = 0;
} else {
float resizeScale = map(iFrame, 0, frameNom - 1, 1, 0.1);
pushMatrix();
translate(width / 2.0 * (1 - resizeScale), height / 2.0 * (1 - resizeScale));
scale(resizeScale);
if (manyFrames[iFrame] != null) {
image(manyFrames[iFrame], 0, 0);
//println("frame" + iFrame + "just showed");
}
popMatrix();
iFrame = iFrame + 1;
passDownTemp = millis();
}
}
}