-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtargeting_web.pde
97 lines (77 loc) · 2.55 KB
/
targeting_web.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Sketch based on *@*http://www.openprocessing.org/sketch/81905*@* */
import java.awt.event.KeyEvent;
PointCloud pc;
PImage [] imglist;
PImage testImg;
boolean doPause = false;
static final int FPS = 30, MORPH_DURATION = 131, POINTCOUNT = 16000, RND_MODE = 1, MORPH_MODE = 0, OPACITY_MAX = 30;
int currentImageIndex = 0;
void setup ()
{
size (720, 480, P3D);
frameRate (FPS);
imglist = new PImage [0];
imglist = (PImage []) append (imglist, loadImage ("1flower.jpg"));
imglist = (PImage []) append (imglist, loadImage ("bamboo.jpg"));
imglist = (PImage []) append (imglist, loadImage ("hierogl.jpg"));
imglist = (PImage []) append (imglist, loadImage ("fuji.jpg"));
imglist = (PImage []) append (imglist, loadImage ("chasen.jpg"));
imglist = (PImage []) append (imglist, loadImage ("profile.jpg"));
imglist = (PImage []) append (imglist, loadImage ("buttf.jpg"));
imglist = (PImage []) append (imglist, loadImage ("tatahier.jpg"));
imglist = (PImage []) append (imglist, loadImage ("fish.jpg"));
imglist = (PImage []) append (imglist, loadImage ("ho.jpg"));
imglist = (PImage []) append (imglist, loadImage ("close.jpg"));
imglist = (PImage []) append (imglist, loadImage ("hbtu.jpg"));
testImg = imglist [currentImageIndex];
pc = new PointCloud (POINTCOUNT);
float cx, cy;
while (pc.p.length <= pc.length)
{
float [] [] target = (float[] []) findTargets (1, testImg);
cx = random (width);
cy = random (height);
pc.addPatricel (new Particle(cx, cy, target[0][0], target[0][1]));
}
background (225, 232, 191);
stroke (71, 121, 79, 80);
}
void FadeIn (PImage img)
{
final int fc = frameCount % MORPH_DURATION;
final float opacity = map(fc, 0, MORPH_DURATION, 0, OPACITY_MAX);
tint(-1, opacity);
image(img, 0, 0);
//surface.setTitle("Alpha: " + fc + "\t\tTime: " + fc/FPS);
}
void draw ()
{
FadeIn(testImg);
noStroke();
fill (236, 255, 213, 80);
rect (0, 0, width, height);
stroke (71, 121, 79, 80);
pc.draw();
if (pc.paused)
{
testImg = imglist [currentImageIndex];
updatePointCloud (testImg, MORPH_MODE);
}
saveFrame("frames\\line-######.png");
}
void updatePointCloud (PImage img, int mode)
{
currentImageIndex++;
if (currentImageIndex == imglist.length) currentImageIndex = 0;
float [] [] target = (float[] []) findTargets (pc.p.length, img);
if (mode == 0) pc.update (target);
else pc.updateSimple (target);
}
void keyPressed ()
{
if (keyCode == KeyEvent.VK_P) {
doPause = !doPause;
if (doPause) noLoop();
else loop();
}
}