-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcordiais_animation.pde
67 lines (51 loc) · 1.75 KB
/
cordiais_animation.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
PImage lindaImg;
PImage[] squareImgs;
int NUM_SQS = 3;
String SQ_FILE = "sq_y_16px.png";
float DELTA_MAG;
PVector facePos = new PVector(0.22, 0.225);
float resizeFactor;
float maxPeriod = 8;
float[] nextUpdate;
PVector[] sqPos;
void setup() {
size(1080, 1920);
frameRate(30);
lindaImg = loadImage("aladino-divani_retrato-de-linda-divani_fill-2.jpg");
resizeFactor = float(width) / lindaImg.width;
lindaImg.resize(width, 0);
squareImgs = new PImage[NUM_SQS];
for (int i = 0; i < squareImgs.length; i++) {
squareImgs[i] = loadImage(SQ_FILE);
squareImgs[i].resize(int(resizeFactor * squareImgs[i].width + 0.0155 * width), 0);
}
nextUpdate = new float[squareImgs.length];
for (int i = 0; i < nextUpdate.length; i++) {
nextUpdate[i] = 2 * i;
}
sqPos = new PVector[squareImgs.length];
for (int i = 0; i < sqPos.length; i++) {
sqPos[i] = new PVector(facePos.x * width, facePos.y * height);
}
DELTA_MAG = float(width) / 32.0;
}
void draw() {
image(lindaImg, 0, 0);
for (int i = 0; i < squareImgs.length; i++) {
image(squareImgs[i], sqPos[i].x, sqPos[i].y);
}
for (int i = 0; i < squareImgs.length; i++) {
if (frameCount > nextUpdate[i]) {
float deltaX = 2.0 * noise(frameCount / 18.0, 2.0*i, PI) - 1.0;
float deltaY = 2.0 * noise(frameCount / 18.0, 2.0*i, PI/2) - 1.0;
//float newX = facePos.x * width + deltaX * 2.0 * DELTA_MAG;
//float newY = facePos.y * height + deltaY * 2.0 * DELTA_MAG;
float newX = facePos.x * width + random(-DELTA_MAG, DELTA_MAG);
float newY = facePos.y * height + random(-DELTA_MAG, DELTA_MAG);
sqPos[i].set(newX, newY);
nextUpdate[i] = frameCount + random(maxPeriod);
}
}
saveFrame("data/out/linda-####.png");
if (frameCount > 900) exit();
}