-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
39 lines (28 loc) · 917 Bytes
/
app.js
File metadata and controls
39 lines (28 loc) · 917 Bytes
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
import { WaveGroup } from "./wavegroup.js";
class App {
constructor() {
this.canvas = document.createElement('canvas');
this.ctx = this.canvas.getContext('2d');
document.body.appendChild(this.canvas);
this.WaveGroup = new WaveGroup();
window.addEventListener('resize', this.resize.bind(this), false);
this.resize();
requestAnimationFrame(this.animate.bind(this));
}
resize() {
this.stageWidth = document.body.clientWidth;
this.stageHeight = document.body.clientHeight;
this.canvas.width = this.stageWidth * 2;
this.canvas.height = this.stageHeight * 2;
this.ctx.scale(2, 2);
this.WaveGroup.resize(this.stageWidth, this.stageHeight);
}
animate(t) {
this.ctx.clearRect(0, 0, this.stageWidth, this.stageHeight);
this.WaveGroup.draw(this.ctx);
requestAnimationFrame(this.animate.bind(this));
}
}
window.onload = () => {
new App();
}