-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRootsClass.pde
executable file
·48 lines (40 loc) · 1.52 KB
/
RootsClass.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
class RootsClass {
PVector p, pOld;
boolean isOutside = false;
float stepSize, angle, noiseScale, noiseStrength;
RootsClass() {
p = new PVector(random(width), random(height));
pOld = new PVector(p.x, p.y);
stepSize = random(3,6.5);
noiseScale = 480;
noiseStrength = random(84,87);
}
void update() {
angle = noise(p.x/noiseScale, p.y/noiseScale) * noiseStrength; //was random(84,87)
p.x += cos(angle) * stepSize;
p.y += sin(angle) * stepSize;
if (p.x < -10) isOutside = true;
else if (p.x > width+10) isOutside = true;
else if (p.y < -10) isOutside = true;
else if (p.y > height + 10) isOutside = true;
if (isOutside) {
p.x = random(width);
p.y = random(height);
pOld.set(p);
}
strokeWeight(0.6 * stepSize);
//stroke(random(255), random(255), random(155,250),50); //rainbowish
//stroke(random(50, 150), random(75, 150), 25, 100); //green
//stroke(random(40), random(50), random(50), 100);
float strokeTransition = map(elapsedTime - toMillisecond(currentScene*2, 00), 0, sceneLength, 0, 1);
stroke(lerpColor(color(random(40), random(60), random(50)), color(random(50,255),random(50,255),random(35,250)), strokeTransition), 100); //test
line(pOld.x, pOld.y, p.x, p.y);
pOld.set(p);
isOutside = false;
}
void modulateNoiseStrength() {
noiseStrength = noiseStrength + 0.05; //+0.1 for no P3D renderer
noiseStrength = noiseStrength - random(0.0065, 0.009); //-0.05 no P3D renderer
if (noiseStrength > 85) noiseStrength = 78;
}
}