-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathGraphics.pde
70 lines (58 loc) · 1.56 KB
/
Graphics.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
int particleCount = 17000;
Particle[] particles = new Particle[particleCount+1];
void setup()
{
size(800,600);
colorMode(RGB, 255);
stroke(123, 104, 238);
frameRate(20);
for (int x = particleCount; x >= 0; x--) {
particles[x] = new Particle();
}
}
void draw()
{
translate(width/2, height/2);
background(0);
float turn = 0;
if (mousePressed)
turn = (mouseX - pmouseX) * 0.00001;
for (int i = particleCount; i >= 0; i--) {
Particle particle = (Particle) particles[i];
particle.update(turn);
}
}
class Particle {
float angle;
float radius;
PVector previous = new PVector();
float dec;
float tilt;
float turnVelocity;
Particle() {
fill(255,255,255,2);
angle = random(50,1000) * 0.03;
radius = random(2,200);
tilt = random(0,50);
dec = (200 - radius) * 0.00004;
}
void update (float turn) {
PVector current = new PVector(radius * cos(angle)*1.2, tilt + 5 * cos(angle + 3.5), radius * sin(angle)*1.2);
if (turn != 0)
turnVelocity = turn * (501-radius);
angle -= dec + turnVelocity;
turnVelocity *= 0.90;
if (previous.x == 0) {
previous.set(current);
}
isoLine(current,previous,angle);
previous.set(current);
}
}
void isoLine(PVector begin, PVector end, float angle) {
PVector newBegin = new PVector(int(begin.x - begin.z), int((begin.x + begin.z)/2 - begin.y));
PVector newEnd = new PVector(int(end.x - end.z), int((end.x + end.z)/2 - end.y));
stroke(106, 90, 205,100);
strokeWeight(1.3);
line (newBegin.x, newBegin.y, newEnd.x, newEnd.y);
}