@luceosports/play-rendering 1.18.7 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/play-rendering.js +3 -3
- package/dist/play-rendering.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/grass_bg.png +0 -0
- package/src/constants.js +3 -0
- package/src/layers/court/base/InternalCourtLayer.js +9 -2
- package/src/layers/court/layers/BASEBALL/constants.js +7 -0
- package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/constants.js +36 -0
- package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/ADirtLayer.js +124 -0
- package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/BaseLineLayer.js +79 -0
- package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/HomePlateLayer.js +104 -0
- package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/PitchingMoundLayer.js +40 -0
- package/src/layers/court/layers/BASEBALL/layers/BorderRectLayer.js +12 -0
- package/src/models/Play.js +4 -2
package/package.json
CHANGED
package/src/assets/grass_bg.png
CHANGED
|
Binary file
|
package/src/constants.js
CHANGED
|
@@ -5,6 +5,7 @@ module.exports = Object.freeze({
|
|
|
5
5
|
SPORT_TYPE_LACROSSE: 'LACROSSE',
|
|
6
6
|
SPORT_TYPE_SOCCER: 'SOCCER',
|
|
7
7
|
SPORT_TYPE_HOCKEY: 'HOCKEY',
|
|
8
|
+
SPORT_TYPE_BASEBALL: 'BASEBALL',
|
|
8
9
|
|
|
9
10
|
COURT_TYPE_BIG3: 'BIG3',
|
|
10
11
|
COURT_TYPE_FIBA: 'FIBA',
|
|
@@ -33,6 +34,8 @@ module.exports = Object.freeze({
|
|
|
33
34
|
COURT_TYPE_HOCKEY_NHL: 'HOCKEY_NHL',
|
|
34
35
|
COURT_TYPE_HOCKEY_INTERNATIONAL: 'HOCKEY_INTERNATIONAL',
|
|
35
36
|
|
|
37
|
+
COURT_TYPE_BASEBALL_HIGH_SCHOOL: 'BASEBALL_HIGH_SCHOOL',
|
|
38
|
+
|
|
36
39
|
SHAPE_TYPE_CIRCLE: 'CIRCLE',
|
|
37
40
|
SHAPE_TYPE_SQUARE: 'SQUARE',
|
|
38
41
|
SHAPE_TYPE_TRIANGLE: 'TRIANGLE',
|
|
@@ -9,8 +9,11 @@ class InternalCourtLayer extends InternalBaseLayer {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
apply() {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (this.original()) {
|
|
13
|
+
this.ctx.save();
|
|
14
|
+
this.drawLogic();
|
|
15
|
+
this.ctx.restore();
|
|
16
|
+
}
|
|
14
17
|
if (this.reflection()) {
|
|
15
18
|
this.ctx.save();
|
|
16
19
|
this.verticalFlipAndRotation();
|
|
@@ -19,6 +22,10 @@ class InternalCourtLayer extends InternalBaseLayer {
|
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
original() {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
reflection() {
|
|
23
30
|
return false;
|
|
24
31
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module.exports = Object.freeze({
|
|
2
|
+
COURT_RECT_WIDTH: 460,
|
|
3
|
+
COURT_RECT_HEIGHT: 290,
|
|
4
|
+
COURT_DIRT_COLOR: '#C49463',
|
|
5
|
+
|
|
6
|
+
HOME_PLATE_APEX_TO_PITCHERS_PLATE_FRONT: 60.5,
|
|
7
|
+
HOME_PLATE_APEX_TO_SECOND_BASE_APEX: 127.28125,
|
|
8
|
+
HOME_PLATE_APEX_TO_BACKSTOP: 60,
|
|
9
|
+
HOME_PLATE_SIDE: 1.41667,
|
|
10
|
+
HOME_PLATE_CIRCLE_DIA: 26,
|
|
11
|
+
|
|
12
|
+
HOME_PLATE_SIDE_TO_BATTERS_BOX: 0.5,
|
|
13
|
+
BATTERS_BOX_WIDTH: 4,
|
|
14
|
+
BATTERS_BOX_HEIGHT: 6,
|
|
15
|
+
BATTERS_BOX_TO_CATCHERS_BACK_LINE: 5,
|
|
16
|
+
|
|
17
|
+
CATCHERS_BACK_LINE_LENGTH: 3.58333,
|
|
18
|
+
ON_DECK_CIRCLE_DIA: 5,
|
|
19
|
+
ON_DECK_CIRCLE_DISTANCE_FROM_CENTER: 37,
|
|
20
|
+
|
|
21
|
+
COACH_BOX_TO_BASE_LINE: 15,
|
|
22
|
+
COACH_BOX_WIDTH: 20,
|
|
23
|
+
COACH_BOX_HEIGHT: 5,
|
|
24
|
+
|
|
25
|
+
PITCHERS_PLATE_WIDTH: 2,
|
|
26
|
+
PITCHERS_PLATE_HEIGHT: 0.5,
|
|
27
|
+
PITCHERS_PLATE_TO_PITCHING_MOUND_CENTER: 1.5,
|
|
28
|
+
PITCHING_MOUND_DIA: 18,
|
|
29
|
+
|
|
30
|
+
PITCHERS_PLATE_GRASS_LINE_RAD: 95,
|
|
31
|
+
|
|
32
|
+
FOUL_LINE_LENGTH: 325,
|
|
33
|
+
BASE_LINE_LENGTH: 90,
|
|
34
|
+
BASE_SQUARE_SIDE_LENGTH: 1.25,
|
|
35
|
+
BASE_DIRT_RAD: 13
|
|
36
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../../../../base/InternalCourtLayer');
|
|
2
|
+
const {
|
|
3
|
+
HOME_PLATE_APEX_TO_BACKSTOP,
|
|
4
|
+
HOME_PLATE_APEX_TO_PITCHERS_PLATE_FRONT,
|
|
5
|
+
COURT_DIRT_COLOR,
|
|
6
|
+
PITCHERS_PLATE_TO_PITCHING_MOUND_CENTER,
|
|
7
|
+
PITCHING_MOUND_DIA,
|
|
8
|
+
PITCHERS_PLATE_GRASS_LINE_RAD,
|
|
9
|
+
BASE_LINE_LENGTH,
|
|
10
|
+
HOME_PLATE_CIRCLE_DIA,
|
|
11
|
+
BASE_DIRT_RAD
|
|
12
|
+
} = require('../constants');
|
|
13
|
+
|
|
14
|
+
class ADirtLayer extends InternalCourtLayer {
|
|
15
|
+
original() {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
reflection() {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
drawLogic() {
|
|
24
|
+
const homePlateApex = { x: this.courtCenter.x, y: HOME_PLATE_APEX_TO_BACKSTOP };
|
|
25
|
+
const pitchersPlateFrontCenter = {
|
|
26
|
+
x: this.courtCenter.x,
|
|
27
|
+
y: HOME_PLATE_APEX_TO_BACKSTOP + HOME_PLATE_APEX_TO_PITCHERS_PLATE_FRONT
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
this.ctx.fillStyle = COURT_DIRT_COLOR;
|
|
31
|
+
this.ctx.strokeStyle = COURT_DIRT_COLOR;
|
|
32
|
+
|
|
33
|
+
// 1. Gras line
|
|
34
|
+
const arcStartAngle = Math.PI / 11;
|
|
35
|
+
const arcEndAngle = Math.PI - Math.PI / 11;
|
|
36
|
+
|
|
37
|
+
this.ctx.save();
|
|
38
|
+
this.ctx.beginPath();
|
|
39
|
+
this.ctx.arc(
|
|
40
|
+
pitchersPlateFrontCenter.x,
|
|
41
|
+
pitchersPlateFrontCenter.y,
|
|
42
|
+
PITCHERS_PLATE_GRASS_LINE_RAD,
|
|
43
|
+
arcStartAngle,
|
|
44
|
+
arcEndAngle,
|
|
45
|
+
false
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const arcEdgePointLeft = getArcPointForAngle(pitchersPlateFrontCenter, PITCHERS_PLATE_GRASS_LINE_RAD, arcEndAngle);
|
|
49
|
+
const arcEdgePointRight = getArcPointForAngle(
|
|
50
|
+
pitchersPlateFrontCenter,
|
|
51
|
+
PITCHERS_PLATE_GRASS_LINE_RAD,
|
|
52
|
+
arcStartAngle
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
this.ctx.moveTo(arcEdgePointLeft.x, arcEdgePointLeft.y);
|
|
56
|
+
this.ctx.lineTo(homePlateApex.x, homePlateApex.y - Math.sqrt(3 * 3 + 3 * 3));
|
|
57
|
+
this.ctx.lineTo(arcEdgePointRight.x, arcEdgePointRight.y);
|
|
58
|
+
this.ctx.lineTo(arcEdgePointLeft.x, arcEdgePointLeft.y);
|
|
59
|
+
|
|
60
|
+
// 1.1 Center hole (draw in reverse direction)
|
|
61
|
+
this.ctx.translate(homePlateApex.x, homePlateApex.y);
|
|
62
|
+
this.ctx.rotate(Math.PI / 4);
|
|
63
|
+
this.ctx.moveTo(3, 3);
|
|
64
|
+
this.ctx.lineTo(3, BASE_LINE_LENGTH - 3);
|
|
65
|
+
this.ctx.lineTo(BASE_LINE_LENGTH - 3, BASE_LINE_LENGTH - 3);
|
|
66
|
+
this.ctx.lineTo(BASE_LINE_LENGTH - 3, 3);
|
|
67
|
+
this.ctx.lineTo(3, 3);
|
|
68
|
+
|
|
69
|
+
this.ctx.fill();
|
|
70
|
+
this.ctx.restore();
|
|
71
|
+
|
|
72
|
+
// 2. Pitching mound
|
|
73
|
+
this.ctx.save();
|
|
74
|
+
this.ctx.beginPath();
|
|
75
|
+
this.ctx.arc(
|
|
76
|
+
pitchersPlateFrontCenter.x,
|
|
77
|
+
pitchersPlateFrontCenter.y - PITCHERS_PLATE_TO_PITCHING_MOUND_CENTER,
|
|
78
|
+
PITCHING_MOUND_DIA / 2,
|
|
79
|
+
0,
|
|
80
|
+
Math.PI * 2,
|
|
81
|
+
true
|
|
82
|
+
);
|
|
83
|
+
this.ctx.stroke();
|
|
84
|
+
this.ctx.fill();
|
|
85
|
+
this.ctx.restore();
|
|
86
|
+
|
|
87
|
+
// 3. Home plate circle
|
|
88
|
+
this.ctx.save();
|
|
89
|
+
this.ctx.beginPath();
|
|
90
|
+
this.ctx.arc(homePlateApex.x, homePlateApex.y, HOME_PLATE_CIRCLE_DIA / 2, 0, Math.PI * 2, true);
|
|
91
|
+
this.ctx.stroke();
|
|
92
|
+
this.ctx.fill();
|
|
93
|
+
this.ctx.restore();
|
|
94
|
+
|
|
95
|
+
// 4. Other Base circles
|
|
96
|
+
this.ctx.save();
|
|
97
|
+
|
|
98
|
+
this.ctx.translate(homePlateApex.x, homePlateApex.y);
|
|
99
|
+
this.ctx.rotate(Math.PI / 4);
|
|
100
|
+
|
|
101
|
+
this.ctx.beginPath();
|
|
102
|
+
this.ctx.arc(BASE_LINE_LENGTH, 0, BASE_DIRT_RAD, Math.PI / 4, Math.PI + Math.PI / 20, false);
|
|
103
|
+
this.ctx.stroke();
|
|
104
|
+
this.ctx.fill();
|
|
105
|
+
|
|
106
|
+
this.ctx.beginPath();
|
|
107
|
+
this.ctx.arc(BASE_LINE_LENGTH, BASE_LINE_LENGTH, BASE_DIRT_RAD, 0, Math.PI * 2, true);
|
|
108
|
+
this.ctx.stroke();
|
|
109
|
+
this.ctx.fill();
|
|
110
|
+
|
|
111
|
+
this.ctx.beginPath();
|
|
112
|
+
this.ctx.arc(0, BASE_LINE_LENGTH, BASE_DIRT_RAD, Math.PI / 4, Math.PI + Math.PI / 2.2, true);
|
|
113
|
+
this.ctx.stroke();
|
|
114
|
+
this.ctx.fill();
|
|
115
|
+
|
|
116
|
+
this.ctx.restore();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function getArcPointForAngle(c, radius, angle) {
|
|
121
|
+
return { x: c.x + Math.cos(angle) * radius, y: c.y + Math.sin(angle) * radius };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
module.exports = ADirtLayer;
|
package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/BaseLineLayer.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../../../../base/InternalCourtLayer');
|
|
2
|
+
const {
|
|
3
|
+
HOME_PLATE_APEX_TO_BACKSTOP,
|
|
4
|
+
BASE_LINE_LENGTH,
|
|
5
|
+
BASE_SQUARE_SIDE_LENGTH,
|
|
6
|
+
FOUL_LINE_LENGTH
|
|
7
|
+
} = require('../constants');
|
|
8
|
+
|
|
9
|
+
class BaseLineLayer extends InternalCourtLayer {
|
|
10
|
+
original() {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
reflection() {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
drawLogic() {
|
|
19
|
+
const homePlateApex = { x: this.courtCenter.x, y: HOME_PLATE_APEX_TO_BACKSTOP };
|
|
20
|
+
|
|
21
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
22
|
+
|
|
23
|
+
this.ctx.save();
|
|
24
|
+
this.ctx.translate(homePlateApex.x, homePlateApex.y);
|
|
25
|
+
this.ctx.rotate(Math.PI / 4);
|
|
26
|
+
|
|
27
|
+
this.ctx.beginPath();
|
|
28
|
+
this.ctx.moveTo(0, 0);
|
|
29
|
+
this.ctx.lineTo(BASE_LINE_LENGTH, 0);
|
|
30
|
+
this.ctx.stroke();
|
|
31
|
+
this.drawBaseSquare(BASE_LINE_LENGTH, 0);
|
|
32
|
+
|
|
33
|
+
this.ctx.beginPath();
|
|
34
|
+
this.ctx.moveTo(BASE_LINE_LENGTH, 0);
|
|
35
|
+
this.ctx.lineTo(BASE_LINE_LENGTH, BASE_LINE_LENGTH);
|
|
36
|
+
this.ctx.stroke();
|
|
37
|
+
this.drawBaseSquare(BASE_LINE_LENGTH + BASE_SQUARE_SIDE_LENGTH / 2, BASE_LINE_LENGTH - BASE_SQUARE_SIDE_LENGTH / 2);
|
|
38
|
+
|
|
39
|
+
this.ctx.beginPath();
|
|
40
|
+
this.ctx.moveTo(BASE_LINE_LENGTH, BASE_LINE_LENGTH);
|
|
41
|
+
this.ctx.lineTo(0, BASE_LINE_LENGTH);
|
|
42
|
+
this.ctx.stroke();
|
|
43
|
+
this.drawBaseSquare(BASE_SQUARE_SIDE_LENGTH, BASE_LINE_LENGTH - BASE_SQUARE_SIDE_LENGTH);
|
|
44
|
+
|
|
45
|
+
this.ctx.beginPath();
|
|
46
|
+
this.ctx.lineTo(0, 0);
|
|
47
|
+
this.ctx.stroke();
|
|
48
|
+
this.ctx.restore();
|
|
49
|
+
|
|
50
|
+
// Foul lines
|
|
51
|
+
[-1, 1].forEach(sideIndex => {
|
|
52
|
+
this.ctx.save();
|
|
53
|
+
this.ctx.translate(homePlateApex.x, homePlateApex.y);
|
|
54
|
+
this.ctx.rotate(sideIndex * (Math.PI / 4));
|
|
55
|
+
this.ctx.beginPath();
|
|
56
|
+
this.ctx.moveTo(0, 0);
|
|
57
|
+
this.ctx.lineTo(sideIndex * FOUL_LINE_LENGTH, 0);
|
|
58
|
+
this.ctx.stroke();
|
|
59
|
+
this.ctx.restore();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
drawBaseSquare(x, y) {
|
|
64
|
+
this.ctx.save();
|
|
65
|
+
this.ctx.lineCap = 'square';
|
|
66
|
+
this.ctx.beginPath();
|
|
67
|
+
this.ctx.translate(x, y);
|
|
68
|
+
this.ctx.moveTo(0, 0);
|
|
69
|
+
this.ctx.lineTo(0, BASE_SQUARE_SIDE_LENGTH);
|
|
70
|
+
this.ctx.lineTo(-BASE_SQUARE_SIDE_LENGTH, BASE_SQUARE_SIDE_LENGTH);
|
|
71
|
+
this.ctx.lineTo(-BASE_SQUARE_SIDE_LENGTH, 0);
|
|
72
|
+
this.ctx.lineTo(0, 0);
|
|
73
|
+
this.ctx.stroke();
|
|
74
|
+
this.ctx.fill();
|
|
75
|
+
this.ctx.restore();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = BaseLineLayer;
|
package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/HomePlateLayer.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../../../../base/InternalCourtLayer');
|
|
2
|
+
const {
|
|
3
|
+
HOME_PLATE_APEX_TO_BACKSTOP,
|
|
4
|
+
HOME_PLATE_SIDE,
|
|
5
|
+
HOME_PLATE_SIDE_TO_BATTERS_BOX,
|
|
6
|
+
BATTERS_BOX_HEIGHT,
|
|
7
|
+
BATTERS_BOX_WIDTH,
|
|
8
|
+
CATCHERS_BACK_LINE_LENGTH,
|
|
9
|
+
BATTERS_BOX_TO_CATCHERS_BACK_LINE,
|
|
10
|
+
HOME_PLATE_CIRCLE_DIA,
|
|
11
|
+
ON_DECK_CIRCLE_DIA,
|
|
12
|
+
ON_DECK_CIRCLE_DISTANCE_FROM_CENTER,
|
|
13
|
+
BASE_LINE_LENGTH,
|
|
14
|
+
COACH_BOX_TO_BASE_LINE,
|
|
15
|
+
COACH_BOX_HEIGHT,
|
|
16
|
+
COACH_BOX_WIDTH
|
|
17
|
+
} = require('../constants');
|
|
18
|
+
|
|
19
|
+
class HomePlateLayer extends InternalCourtLayer {
|
|
20
|
+
original() {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
reflection() {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
drawLogic() {
|
|
29
|
+
const homePlateApex = { x: this.courtCenter.x, y: HOME_PLATE_APEX_TO_BACKSTOP };
|
|
30
|
+
const homePlateTopLineOrigin = { x: homePlateApex.x - HOME_PLATE_SIDE / 2, y: homePlateApex.y + HOME_PLATE_SIDE };
|
|
31
|
+
const homePlateTopLineTerminus = { x: homePlateApex.x + HOME_PLATE_SIDE / 2, y: homePlateApex.y + HOME_PLATE_SIDE };
|
|
32
|
+
|
|
33
|
+
// 1. Home Plate
|
|
34
|
+
this.ctx.beginPath();
|
|
35
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
36
|
+
this.ctx.moveTo(homePlateTopLineOrigin.x, homePlateTopLineOrigin.y);
|
|
37
|
+
this.ctx.lineTo(homePlateTopLineTerminus.x, homePlateTopLineTerminus.y);
|
|
38
|
+
this.ctx.lineTo(homePlateTopLineTerminus.x, homePlateTopLineTerminus.y - HOME_PLATE_SIDE / 2);
|
|
39
|
+
this.ctx.lineTo(homePlateApex.x, homePlateApex.y);
|
|
40
|
+
this.ctx.lineTo(homePlateTopLineOrigin.x, homePlateTopLineOrigin.y - HOME_PLATE_SIDE / 2);
|
|
41
|
+
this.ctx.lineTo(homePlateTopLineOrigin.x, homePlateTopLineOrigin.y);
|
|
42
|
+
this.ctx.stroke();
|
|
43
|
+
this.ctx.fill();
|
|
44
|
+
|
|
45
|
+
// 2. Batters Box
|
|
46
|
+
[-1, 1].forEach(sideIndex => {
|
|
47
|
+
this.ctx.save();
|
|
48
|
+
this.ctx.translate(homePlateApex.x, homePlateApex.y + HOME_PLATE_SIDE / 2);
|
|
49
|
+
this.ctx.beginPath();
|
|
50
|
+
|
|
51
|
+
const battersBoxClosestX = HOME_PLATE_SIDE / 2 + HOME_PLATE_SIDE_TO_BATTERS_BOX;
|
|
52
|
+
|
|
53
|
+
this.ctx.moveTo(sideIndex * battersBoxClosestX, 0);
|
|
54
|
+
this.ctx.lineTo(sideIndex * battersBoxClosestX, BATTERS_BOX_HEIGHT / 2);
|
|
55
|
+
this.ctx.lineTo(sideIndex * (battersBoxClosestX + BATTERS_BOX_WIDTH), BATTERS_BOX_HEIGHT / 2);
|
|
56
|
+
this.ctx.lineTo(sideIndex * (battersBoxClosestX + BATTERS_BOX_WIDTH), -BATTERS_BOX_HEIGHT / 2);
|
|
57
|
+
this.ctx.lineTo(sideIndex * battersBoxClosestX, -BATTERS_BOX_HEIGHT / 2);
|
|
58
|
+
this.ctx.lineTo(sideIndex * battersBoxClosestX, 0);
|
|
59
|
+
this.ctx.stroke();
|
|
60
|
+
this.ctx.restore();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// 3. Catchers box
|
|
64
|
+
const battersBoxNearestY = homePlateApex.y + HOME_PLATE_SIDE / 2 - BATTERS_BOX_HEIGHT / 2;
|
|
65
|
+
[-1, 1].forEach(sideIndex => {
|
|
66
|
+
this.ctx.save();
|
|
67
|
+
this.ctx.translate(this.courtCenter.x, battersBoxNearestY - BATTERS_BOX_TO_CATCHERS_BACK_LINE);
|
|
68
|
+
this.ctx.beginPath();
|
|
69
|
+
this.ctx.moveTo(0, 0);
|
|
70
|
+
this.ctx.lineTo(sideIndex * (CATCHERS_BACK_LINE_LENGTH / 2), 0);
|
|
71
|
+
this.ctx.lineTo(sideIndex * (CATCHERS_BACK_LINE_LENGTH / 2), BATTERS_BOX_TO_CATCHERS_BACK_LINE);
|
|
72
|
+
this.ctx.stroke();
|
|
73
|
+
this.ctx.restore();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// 4. On Deck circles
|
|
77
|
+
[-1, 1].forEach(sideIndex => {
|
|
78
|
+
this.ctx.save();
|
|
79
|
+
this.ctx.translate(this.courtCenter.x, homePlateApex.y - HOME_PLATE_CIRCLE_DIA / 2);
|
|
80
|
+
this.ctx.beginPath();
|
|
81
|
+
this.ctx.arc(sideIndex * ON_DECK_CIRCLE_DISTANCE_FROM_CENTER, 0, ON_DECK_CIRCLE_DIA / 2, 0, Math.PI * 2, true);
|
|
82
|
+
this.ctx.stroke();
|
|
83
|
+
this.ctx.restore();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// 5. Coach boxes
|
|
87
|
+
[-1, 1].forEach(sideIndex => {
|
|
88
|
+
this.ctx.save();
|
|
89
|
+
this.ctx.translate(homePlateApex.x, homePlateApex.y);
|
|
90
|
+
this.ctx.rotate(sideIndex * (Math.PI / 4));
|
|
91
|
+
|
|
92
|
+
this.ctx.beginPath();
|
|
93
|
+
this.ctx.moveTo(sideIndex * BASE_LINE_LENGTH, -(COACH_BOX_TO_BASE_LINE + COACH_BOX_HEIGHT));
|
|
94
|
+
this.ctx.lineTo(sideIndex * BASE_LINE_LENGTH, -COACH_BOX_TO_BASE_LINE);
|
|
95
|
+
this.ctx.lineTo(sideIndex * (BASE_LINE_LENGTH - COACH_BOX_WIDTH), -COACH_BOX_TO_BASE_LINE);
|
|
96
|
+
this.ctx.lineTo(sideIndex * (BASE_LINE_LENGTH - COACH_BOX_WIDTH), -(COACH_BOX_TO_BASE_LINE + COACH_BOX_HEIGHT));
|
|
97
|
+
this.ctx.stroke();
|
|
98
|
+
|
|
99
|
+
this.ctx.restore();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = HomePlateLayer;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../../../../base/InternalCourtLayer');
|
|
2
|
+
const {
|
|
3
|
+
HOME_PLATE_APEX_TO_BACKSTOP,
|
|
4
|
+
HOME_PLATE_APEX_TO_PITCHERS_PLATE_FRONT,
|
|
5
|
+
PITCHERS_PLATE_WIDTH,
|
|
6
|
+
PITCHERS_PLATE_HEIGHT
|
|
7
|
+
} = require('../constants');
|
|
8
|
+
|
|
9
|
+
class PitchingMoundLayer extends InternalCourtLayer {
|
|
10
|
+
original() {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
reflection() {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
drawLogic() {
|
|
19
|
+
const pitchersPlateFrontCenter = {
|
|
20
|
+
x: this.courtCenter.x,
|
|
21
|
+
y: HOME_PLATE_APEX_TO_BACKSTOP + HOME_PLATE_APEX_TO_PITCHERS_PLATE_FRONT
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
this.ctx.save();
|
|
25
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
26
|
+
this.ctx.beginPath();
|
|
27
|
+
this.ctx.translate(pitchersPlateFrontCenter.x, pitchersPlateFrontCenter.y);
|
|
28
|
+
this.ctx.moveTo(0, 0);
|
|
29
|
+
this.ctx.lineTo(PITCHERS_PLATE_WIDTH / 2, 0);
|
|
30
|
+
this.ctx.lineTo(PITCHERS_PLATE_WIDTH / 2, PITCHERS_PLATE_HEIGHT);
|
|
31
|
+
this.ctx.lineTo(-PITCHERS_PLATE_WIDTH / 2, PITCHERS_PLATE_HEIGHT);
|
|
32
|
+
this.ctx.lineTo(-PITCHERS_PLATE_WIDTH / 2, 0);
|
|
33
|
+
this.ctx.lineTo(0, 0);
|
|
34
|
+
this.ctx.stroke();
|
|
35
|
+
this.ctx.fill();
|
|
36
|
+
this.ctx.restore();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = PitchingMoundLayer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../../base/InternalCourtLayer');
|
|
2
|
+
|
|
3
|
+
class BorderRectLayer extends InternalCourtLayer {
|
|
4
|
+
drawLogic() {
|
|
5
|
+
this.ctx.beginPath();
|
|
6
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
7
|
+
this.ctx.rect(0, 0, this.courtTypeConstants.COURT_RECT_WIDTH, this.courtTypeConstants.COURT_RECT_HEIGHT);
|
|
8
|
+
this.ctx.stroke();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = BorderRectLayer;
|
package/src/models/Play.js
CHANGED
|
@@ -9,7 +9,8 @@ const {
|
|
|
9
9
|
SPORT_TYPE_FOOTBALL,
|
|
10
10
|
SPORT_TYPE_LACROSSE,
|
|
11
11
|
SPORT_TYPE_SOCCER,
|
|
12
|
-
SPORT_TYPE_HOCKEY
|
|
12
|
+
SPORT_TYPE_HOCKEY,
|
|
13
|
+
SPORT_TYPE_BASEBALL
|
|
13
14
|
} = require('../constants');
|
|
14
15
|
|
|
15
16
|
const STORAGE_URL = 'https://playbooksstore.blob.core.windows.net/public';
|
|
@@ -40,7 +41,8 @@ class Play {
|
|
|
40
41
|
[SPORT_TYPE_FOOTBALL]: grassImage,
|
|
41
42
|
[SPORT_TYPE_LACROSSE]: grassImage,
|
|
42
43
|
[SPORT_TYPE_SOCCER]: grassImage,
|
|
43
|
-
[SPORT_TYPE_HOCKEY]: iceImage
|
|
44
|
+
[SPORT_TYPE_HOCKEY]: iceImage,
|
|
45
|
+
[SPORT_TYPE_BASEBALL]: grassImage
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
const luceoSportsWatermark = await loadImage(`${STORAGE_URL}/${LUCEOSPORTS_WATERMARK_PATH}`);
|