-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBox.js
32 lines (25 loc) · 987 Bytes
/
Box.js
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
class Box {
constructor(xLeft, xRight, yUp, yDown, r) {
let horizLength = xRight - xLeft;
let vertLength = yDown - yUp;
if (horizLength <= 0 || vertLength <= 0) {
throw "Invalid box locations, check the parameters";
}
this.borders = {
up: new HorizontalBorder((xLeft + xRight) / 2, yUp, horizLength, r, false),
down: new HorizontalBorder((xLeft + xRight) / 2, yDown, horizLength, r, false),
left: new VerticalBorder(xLeft, (yUp + yDown) / 2, vertLength, r, false),
right: new VerticalBorder(xRight, (yUp + yDown) / 2, vertLength, r, false),
};
this.borders.up.extendTo(Way.up);
this.borders.down.extendTo(Way.down);
this.borders.left.extendTo(Way.left);
this.borders.right.extendTo(Way.right);
}
draw() {
for (let borderKey in this.borders) {
this.borders[borderKey].draw();
}
}
update() {}
}