-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathharmonic.js
More file actions
41 lines (38 loc) · 955 Bytes
/
harmonic.js
File metadata and controls
41 lines (38 loc) · 955 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
40
41
class Harmonic {
constructor(id, wheel) {
this.id = id;
this.wheel = wheel;
this.width = width / (harmonicCount-1);
this.height = height - horiSplit;
this.x = id * this.width;
this.y = horiSplit;
this.amp = wheel.radius / wheelSize;
this.selected = false;
}
update() {
if (this.selected) {
this.amp = (height-mouseY) / this.height;
this.amp = limit(this.amp, 0, 1);
this.wheel.updateAmp(this.amp);
}
}
draw() {
stroke(200, 230, 255);
noFill();
rect(this.x,
this.y + this.height - (this.height * this.amp),
this.width,
height);
let textRow = this.y + 20;
noStroke();
fill(200, 230, 255);
textAlign(CENTER);
textSize(15);
text('1',
this.x + this.width/2, textRow);
text('_',
this.x + this.width/2, textRow + 5);
text((this.id+1),
this.x + this.width/2, textRow + 24);
}
}