-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainer.js
More file actions
39 lines (36 loc) · 1.24 KB
/
container.js
File metadata and controls
39 lines (36 loc) · 1.24 KB
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
class Container extends Tooltip {
constructor({position, width, height, label, style, tooltips}) {
super({tooltips, position})
this.position = position;
this.width = width;
this.height = height;
this.label = label;
this.isOverlayed = true
this.style = {
backgroundColor: '#E5F2FC',
strokeColor: '#1D63ED',
...style
};
drawables.add(this);
}
draw() {
ctx.globalAlpha = 0.6;
ctx.fillStyle = this.style.backgroundColor;
ctx.beginPath();
ctx.roundRect(this.position.x, this.position.y, this.width, this.height, [10]);
ctx.fill();
ctx.globalAlpha = 1;
ctx.strokeStyle = this.style.strokeColor;
ctx.beginPath();
ctx.roundRect(this.position.x, this.position.y, this.width, this.height, [10]);
ctx.stroke();
ctx.fillStyle = '#00084D';
ctx.beginPath();
ctx.roundRect(this.position.x, this.position.y - 15, ctx.measureText(this.label).width + 20, 25, [10]);
ctx.fill();
this.drawTooltip()
ctx.font = "16px Roboto";
ctx.fillStyle = 'white';
ctx.fillText(this.label, this.position.x + 10, this.position.y + 2);
}
}