-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSacredCircle.pde
56 lines (45 loc) · 1.28 KB
/
SacredCircle.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
class SacredCircle {
SacredPoint center;
float diameter;
SacredCircle(SacredPoint _center, float _diameter) {
center = _center;
diameter = _diameter;
}
// vibrance: 0.0 - 1.0
void drawCircleVibrance(color c, float vibrance) {
stroke(colorWithAlpha(c, vibranceEightBit(vibrance)));
ellipse(center.x, center.y, diameter, diameter);
}
void drawCircle(color c) {
stroke(c);
ellipse(center.x, center.y, diameter, diameter);
}
void drawCircle() {
stroke(255, 80);
ellipse(center.x, center.y, diameter, diameter);
}
void drawCircleRandom() {
stroke(randomColor());
ellipse(center.x, center.y, diameter, diameter);
}
float radius() {
return diameter / 2.0;
}
color randomColor() {
return color(random(255), random(255), random(255));
}
int vibranceEightBit(float vibrance) {
float mappedVibrance = map(vibrance, 0.0, 1.0, 0.0, 255.0);
float containedVibrance = min(max(mappedVibrance, 0.0), 255.0);
return int(containedVibrance);
}
color colorWithAlpha(color c, int a) {
int r = (c >> 16) & 0xFF;
int g = (c >> 8) & 0xFF;
int b = c & 0xFF;
return color(r, g, b, a);
}
float distanceFrom(SacredCircle cir) {
return dist(center.x, center.y, cir.center.x, cir.center.y);
}
}