-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch14.js
51 lines (43 loc) · 1.3 KB
/
sketch14.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
'use strict';
class Sketch14 extends Sketch {
constructor() {
super();
this.scale = 1;
this.width = Math.floor(this.canvas.width / this.scale);
this.height = this.width;
}
load() {
super.load();
this.p = [];
for (let i = 0; i < 2000; i++) {
const theta = Math.random() * 2 * Math.PI;
const r = 50 * (Math.random() + Math.random());
this.p.push({
theta,
r,
i
});
}
}
update() {
}
draw(ctx, width, height, t, mousePoint) {
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, width, height);
ctx.translate(width / 2, height / 2);
ctx.fillStyle = 'blue';
this.p.forEach( p => {
ctx.fillStyle = `hsl(${this.lmap(p.i, 0, this.p.length, 180, 280 )}, 100%, 50%)`;
const theta = p.theta + t * 0.2 + 0.00 * Math.sin(t * 200 + 17 * this.rnd(p.i * 17) ) ;
const r = this.lmap(t, 0, 10, p.r, -25) + 25 * Math.sin(t * t + 7 * this.rnd(p.i * 7));
const x = r * Math.cos(theta);
const y = r * Math.sin(theta);
ctx.fillRect(x, y, 3, 3);
});
if (t > 100) {
this.load();
}
}
}
app.sketches[14] = new Sketch14();
app.sketches[14].desc = `Sometimes we must look deep within ourselves to understand what is going on around us.`;