-
Notifications
You must be signed in to change notification settings - Fork 6
/
C.pde
98 lines (78 loc) · 2.03 KB
/
C.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class Riley61 extends Composition {
float gap;
float pinchX;
float baseGap;
float spacer;
float divide = 10;
float grayOff1, grayOff2, grayOff3, grayOff4;
Riley61 () {
compose();
}
void compose() {
pinchX = random(width*0.25, width*0.75);
divide = random(10, 30);
setGap(divide);
grayOff1 = random(0, TWO_PI);
grayOff2 = random(0, TWO_PI);
grayOff3 = random(0, TWO_PI);
grayOff4 = random(0, TWO_PI);
}
void setGap(float divide) {
if (width >= height) {
baseGap = width / divide;
}
else {
baseGap = height / divide;
}
spacer = baseGap;
}
void display() {
if (dragging) {
pinchX = float(x);
divide = map(mouseY, 0, height, 10, 40);
setGap( divide );
}
background(0);
noStroke();
fill(0);
float gap = 0;
float angle = 0;
int counter = 0;
float offset = 0;
float secondX = 0;
int xCounter = 0;
for (float y = 0; y < height + baseGap; y+= baseGap) {
if (counter % 2 != 0) {
offset = abs(pinchX - secondX)/2;
}
else {
offset = 0;
}
xCounter = 0;
// Before the pinch
for (float x = pinchX-offset; x > 0-baseGap*3; x-= gap+spacer) {
if (xCounter == 1) {
secondX = x;
}
angle = map(x, 0, pinchX, 0, HALF_PI);
gap = cos(angle) * (baseGap-5);
float startVal = map(y, 0, height+baseGap, grayOff1, grayOff2);
fill(255 - (abs(cos(startVal)) * cos(angle) * 255));
ellipse(x, y, gap + 5, baseGap);
xCounter++;
}
// After the pinch
for (float x = pinchX+offset; x < width+baseGap+baseGap; x+= gap+spacer) {
angle = map(x, pinchX, width, HALF_PI, 0);
gap = cos(angle) * (baseGap-5);
float startVal = map(y, 0, height+baseGap, grayOff3, grayOff4);
fill(255 - (abs(cos(startVal)) * cos(angle) * 255));
ellipse(x, y, gap + 5, baseGap);
}
counter++;
}
counter = 0;
}
}
class Reily94 {
}