-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoad.js
More file actions
59 lines (48 loc) · 1.51 KB
/
Road.js
File metadata and controls
59 lines (48 loc) · 1.51 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class Road {
constructor(ctx, cvs) {
this.ctx = ctx;
this.cvs = cvs;
this.outerlines = []
this.innerLines = []
this.makeLines();
}
makeLines() {
this.outerlines.push([30, 50]);
this.outerlines.push([260, 100]);
this.outerlines.push([560, 40]);
this.outerlines.push([580, 390]);
this.outerlines.push([400, 320]);
this.outerlines.push([300, 310]);
this.outerlines.push([100, 390]);
this.outerlines.push([20, 350]);
this.outerlines.push([10, 300]);
this.outerlines.push([40, 240]);
this.innerLines.push([100, 120]);
this.innerLines.push([250, 150]);
this.innerLines.push([500, 120]);
this.innerLines.push([490, 270]);
this.innerLines.push([300, 250]);
this.innerLines.push([110, 320]);
this.innerLines.push([80, 300]);
this.innerLines.push([100, 220]);
}
drawLines(lines, inner) {
if (!inner) {
this.ctx.fillStyle = "#878787";
} else {
this.ctx.fillStyle = "#737475";
}
this.ctx.beginPath();
this.ctx.moveTo(lines[0][0], lines[0][1]);
for (var i = 1; i < lines.length; i++) {
this.ctx.lineTo(lines[i][0], lines[i][1]);
}
this.ctx.lineTo(lines[0][0], lines[0][1]);
this.ctx.stroke();
this.ctx.fill();
}
draw() {
this.drawLines(this.outerlines, false);
this.drawLines(this.innerLines, true);
}
}