-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLayout.pde
More file actions
64 lines (51 loc) · 1.56 KB
/
Copy pathLayout.pde
File metadata and controls
64 lines (51 loc) · 1.56 KB
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
class LayoutGenerator {
float centerX;
float centerY;
public LayoutGenerator(float centerX, float centerY) {
this.centerX = centerX;
this.centerY = centerY;
}
public PVector pos(int n) {
if (n == 0) {
return new PVector(width/2, height/2);
} else {
final float x = (n % 20) * ((width - 50) / 20) + 25;
final float y = floor(n / 20) * ((height - 50) / 10) + 25;
return new PVector(x, y);
}
}
}
class Spiral extends LayoutGenerator {
float radius;
public Spiral(float radius, float centerX, float centerY) {
super(centerX, centerY);
this.radius = radius;
}
@Override
public PVector pos(int n) {
if (n > 0) {
n += 1;
}
final float a = 2.4 * n;
final float r = this.radius * sqrt(n);
final float x = r * cos(a) + this.centerX;
final float y = r * sin(a) + this.centerY;
return new PVector(x, y);
}
}
class PackedSpiral extends Spiral {
float power = 0.07;
float baseCoeff = 0.3;
float fanoutOffsetMult = 1.001;
float r;
public PackedSpiral(float radius, float centerX, float centerY) {
super(radius, centerX, centerY);
}
@Override
public PVector pos(int n) {
this.r = -1 * pow(this.radius, pow(this.baseCoeff * n, this.power));
final float x = width/2 + this.r * cos(n * this.fanoutOffsetMult);
final float y = height/2 + this.r * sin(n * this.fanoutOffsetMult);
return new PVector(x, y);
}
}