-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminiMap.js
More file actions
33 lines (27 loc) · 901 Bytes
/
Copy pathminiMap.js
File metadata and controls
33 lines (27 loc) · 901 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
class MiniMap{
constructor(canvas, graph, size){
this.canvas = canvas;
this.graph = graph;
this.size = size;
this.angle = 0;
canvas.width = size;
canvas.height = size;
this.ctx = canvas.getContext('2d');
}
update(viewPoint){
this.ctx.clearRect(0,0, this.size, this.size);
const scaler = 0.05;
const scaledViewPoint = scale(viewPoint, -scaler);
this.ctx.save();
this.ctx.translate(
scaledViewPoint.x + this.size / 2,
scaledViewPoint.y + this.size / 2
);
this.ctx.scale(scaler, scaler);
for(const seg of this.graph.segments){
seg.draw(this.ctx, { width : 3 / scaler, color : "white"});
}
this.ctx.restore();
new Point(this.size / 2, this.size / 2).draw(this.ctx, {color: "blue", outline: true});
}
}