-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
220 lines (188 loc) · 5.02 KB
/
sketch.js
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
let canvasSize = 700
let zoff = 0;
let slider;
let r = 0;
let noiseMax = 1.8;
let Hr = 0, Min = 0, Sec = 0;
let prev_second = 0;
let sec_rad = 240;
let min_rad = 200;
let hour_rad = 160;
let amp = 30;
let outer_radii = 275;
let outer_amp = 75;
let i = 0;
function drawRahoboam() {
stroke(0);
strokeWeight(1);
noFill();
push();
strokeWeight(12);
push();
translate(-70, 0)
rotate(radians(-20))
line(0, 70, 0, -50)
line(20, 50, 20, -40)
pop();
push();
translate(70, 0)
rotate(radians(20))
line(0, 70, 0, -50)
line(-20, 50, -20, -40)
pop();
push();
line(0, -20, -33, 42)
line(0, -20, 33, 42)
pop();
pop();
noiseSeed(0)
for (let a = 0; a < TWO_PI; a += radians(0.65)) {
let xoff = map(cos(a), -1, 1, 0, 15);
let yoff = map(sin(a), -1, 1, 0, 15);
r = map(noise(xoff, yoff, zoff), 0, 1, 110, 150);
let x = r * cos(a);
let y = r * sin(a);
line(125 * cos(a), 125 * sin(a), x, y)
}
noiseSeed(1)
for (let a = 0; a < TWO_PI; a += radians(0.65)) {
let xoff = map(cos(a), -1, 1, 0, noiseMax);
let yoff = map(sin(a), -1, 1, 0, noiseMax);
r = map(noise(xoff, yoff, zoff), 0, 1, 70, 170);
let x = r * cos(a);
let y = r * sin(a);
line(125 * cos(a), 125 * sin(a), x, y)
}
noiseSeed(2)
for (let a = 0; a < TWO_PI; a += radians(0.65)) {
let xoff = map(cos(a), -1, 1, 0, noiseMax);
let yoff = map(sin(a), -1, 1, 0, noiseMax);
r = map(noise(xoff, yoff, zoff), 0, 1, 80, 160);
let x = r * cos(a);
let y = r * sin(a);
line(125 * cos(a), 125 * sin(a), x, y)
}
noiseSeed(3)
for (let a = 0; a < TWO_PI; a += radians(0.65)) {
let xoff = map(cos(a), -1, 1, 0, noiseMax);
let yoff = map(sin(a), -1, 1, 0, noiseMax);
r = map(noise(xoff, yoff, zoff), 0, 1, 90, 150);
let x = r * cos(a);
let y = r * sin(a);
line(125 * cos(a), 125 * sin(a), x, y)
}
noiseSeed(4)
for (let a = 0; a < TWO_PI; a += radians(0.65)) {
let xoff = map(cos(a), -1, 1, 0, noiseMax);
let yoff = map(sin(a), -1, 1, 0, noiseMax);
r = map(noise(xoff, yoff, zoff), 0, 1, 100, 140);
let x = r * cos(a);
let y = r * sin(a);
line(125 * cos(a), 125 * sin(a), x, y)
}
noiseSeed(5)
for (let a = 0; a < TWO_PI; a += radians(0.65)) {
let xoff = map(cos(a), -1, 1, 0, 1.8*a);
let yoff = map(sin(a), -1, 1, 0, 1.8*a);
r = map(noise(xoff, yoff, zoff), 0, 1, 110, 130);
let x = r * cos(a);
let y = r * sin(a);
line(125 * cos(a), 125 * sin(a), x, y)
}
noiseSeed(6)
for (let a = 0; a < TWO_PI; a += radians(0.55)) {
let xoff = map(cos(a), -1, 1, 0, 1.8*a);
let yoff = map(sin(a), -1, 1, 0, 1.8*a);
r = map(noise(xoff, yoff, zoff), 0, 1, hour_rad - amp, hour_rad + amp);
let x = r * cos(a);
let y = r * sin(a);
line(hour_rad * cos(a), hour_rad * sin(a), x, y)
}
noiseSeed(7)
for (let a = 0; a < TWO_PI; a += radians(0.45)) {
let xoff = map(cos(a), -1, 1, 0, 1.8*a);
let yoff = map(sin(a), -1, 1, 0, 1.8*a);
r = map(noise(xoff, yoff, zoff), 0, 1, min_rad - amp, min_rad + amp);
let x = r * cos(a);
let y = r * sin(a);
line(min_rad * cos(a), min_rad * sin(a), x, y)
}
noiseSeed(8)
for (let a = 0; a < TWO_PI; a += radians(0.35)) {
let xoff = map(cos(a), -1, 1, 0, 1.8*a);
let yoff = map(sin(a), -1, 1, 0, 1.8*a);
r = map(noise(xoff, yoff, zoff), 0, 1, sec_rad - amp, sec_rad + amp);
let x = r * cos(a);
let y = r * sin(a);
line(sec_rad * cos(a), sec_rad * sin(a), x, y)
}
noiseSeed(9)
stroke(255)
for (let a = 0; a < TWO_PI; a += radians(0.35)) {
let xoff = map(cos(a), -1, 1, 0, 1.8*a);
let yoff = map(sin(a), -1, 1, 0, 1.8*a);
r = map(noise(xoff, yoff, zoff), 0, 1, outer_radii, outer_radii + outer_amp);
let x = r * cos(a);
let y = r * sin(a);
line(outer_radii * cos(a), outer_radii * sin(a), x, y)
}
zoff += 0.01;
}
function drawHand(r) {
let x1 = 0, y1 = 0, x2 = 0, y2 = 0;
for(let a = radians(-20); a < radians(20); a += radians(0.65)) {
x1 = r * cos(a);
y1 = r * sin(a);
y2 = abs(35/a * sin(a))
x2 = (r+y2) * cos(a)
line(x1, y1, x2, y2)
}
}
function drawClock() {
stroke(0);
strokeWeight(1);
noFill();
push();
rotate(-HALF_PI-radians(8.5))
// Seconds display
let secAngle = map(Sec, 0, 60, 0, TWO_PI);
push();
rotate(secAngle + radians(1.5) + i);
drawHand(sec_rad);
pop();
// Minute display
let minAngle = map(Min, 0, 60, 0, TWO_PI) + secAngle/60;
push();
rotate(minAngle);
drawHand(min_rad);
pop();
// Hours display
let hourAngle = map(Hr % 12, 0, 12, 0, TWO_PI) + minAngle/12;
push();
rotate(hourAngle - radians(1.5));
drawHand(hour_rad);
pop();
pop();
}
function setup() {
createCanvas(canvasSize, canvasSize);
}
function draw() {
clear()
translate(width / 2, height / 2);
push()
noStroke();
fill(255);
ellipse(0, 0, 555, 555);
pop()
Hr = hour()
Min = minute()
Sec = second()
if(prev_second != Sec) {
i = 0;
prev_second = Sec;
}
drawRahoboam();
drawClock();
i += radians(0.383);
}