-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticleBGimage.pde
executable file
·59 lines (51 loc) · 1.58 KB
/
ParticleBGimage.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
class ParticleBGimage
{
PVector loc;
float life, lifeRate;
float particleSize;
ParticleBGimage()
{
getPosition();
//life = random(0.75, 1.25);
life = random(6, 9);
lifeRate = random(0.005, 0.75);
particleSize = random(7,12);
}
void updateBG()
{
float angle = noise(loc.x * 0.01, loc.y*0.01) * TWO_PI;
PVector vel = PVector.fromAngle(angle + globalRotation);
loc.add(vel);
life -= lifeRate;
}
void displayBG()
{
boolean special = random(1) < 0.001;
//strokeWeight(special ? random(0.75, 3) : 0.75);
noStroke();
fill (255, special ? random(175, 255) : 65);
//point (loc.x, loc.y);
ellipse(loc.x,loc.y,particleSize,particleSize);
}
//get a random position from w/in the text
void getPosition()
{
while (loc == null || !isInText(loc)) loc = new PVector (random(width), random(height));
}
//return if point is inside the text
boolean isInText(PVector v)
{
//boolean test;
//int x = (int)map(v.x,0,width,0,sourceImage.width);
//int y = (int)map(v.y,0,height,0,sourceImage.height);
int camX = (int)map(v.x,0,width,0,cam.width);
int camY = (int)map(v.y,0,height,0,cam.height);
/* sourceImage.loadPixels();
test = brightness(sourceImage.pixels[x+y*sourceImage.width]) > 100;
sourceImage.updatePixels();2*/
// return test;
//return (sourceImage.get(x, y) == PGRAPHICS_COLOR) || (brightness(cam.get(camX, camY)) < 5) ;
//return (brightness(cam.get(camX, camY)) < 20) ; //original
return (brightness(cam.get(camX, camY)) < 50) ; //changed to 50 for brighter environment, otherwise scene lags severely when drawing particles.
}
}