@luceosports/play-rendering 2.0.6 → 2.0.8
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/.babelrc +1 -1
- package/dist/play-rendering.js +2 -2
- package/dist/play-rendering.js.map +1 -1
- package/package.json +2 -3
- package/src/layers/court/layers/BASEBALL/constants.ts +1 -1
- package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/constants.ts +5 -4
- package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/BaseLineLayer.ts +36 -10
- package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/HomePlateLayer.ts +23 -7
- package/src/models/FrameModel.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luceosports/play-rendering",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"main": "dist/play-rendering.js",
|
|
5
5
|
"types": "dist/play-rendering.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -21,14 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@babel/core": "^7.18.6",
|
|
24
|
-
"@babel/plugin-
|
|
24
|
+
"@babel/plugin-transform-class-properties": "^7.24.7",
|
|
25
25
|
"@babel/plugin-transform-runtime": "^7.9.0",
|
|
26
26
|
"@babel/preset-env": "^7.9.0",
|
|
27
27
|
"@babel/preset-typescript": "^7.24.6",
|
|
28
28
|
"@commitlint/cli": "^13.2.0",
|
|
29
29
|
"@commitlint/config-angular": "^13.2.0",
|
|
30
30
|
"@types/lodash": "^4.17.4",
|
|
31
|
-
"@types/mathjs": "^9.4.2",
|
|
32
31
|
"@types/node": "^20.12.12",
|
|
33
32
|
"@typescript-eslint/eslint-plugin": "^7.11.0",
|
|
34
33
|
"@typescript-eslint/parser": "^7.11.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const COURT_RECT_WIDTH =
|
|
2
|
-
export const COURT_RECT_HEIGHT =
|
|
1
|
+
export const COURT_RECT_WIDTH = 480;
|
|
2
|
+
export const COURT_RECT_HEIGHT = 460;
|
|
3
3
|
export const COURT_DIRT_COLOR = '#C49463';
|
|
4
4
|
|
|
5
5
|
export const HOME_PLATE_APEX_TO_PITCHERS_PLATE_FRONT = 60.5;
|
|
@@ -28,7 +28,8 @@ export const PITCHING_MOUND_DIA = 18;
|
|
|
28
28
|
|
|
29
29
|
export const PITCHERS_PLATE_GRASS_LINE_RAD = 95;
|
|
30
30
|
|
|
31
|
-
export const
|
|
31
|
+
export const HOME_RUN_FENCE_CENTER_DISTANCE = 390;
|
|
32
|
+
export const FOUL_LINE_LENGTH = 330;
|
|
32
33
|
export const BASE_LINE_LENGTH = 90;
|
|
33
|
-
export const BASE_SQUARE_SIDE_LENGTH =
|
|
34
|
+
export const BASE_SQUARE_SIDE_LENGTH = 2.5;
|
|
34
35
|
export const BASE_DIRT_RAD = 13;
|
package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/BaseLineLayer.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import InternalCourtLayer from '../../../../../base/InternalCourtLayer';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BASE_LINE_LENGTH,
|
|
5
|
+
BASE_SQUARE_SIDE_LENGTH,
|
|
6
|
+
FOUL_LINE_LENGTH,
|
|
7
|
+
HOME_PLATE_APEX_TO_BACKSTOP,
|
|
8
|
+
HOME_RUN_FENCE_CENTER_DISTANCE,
|
|
9
|
+
PITCHERS_PLATE_GRASS_LINE_RAD
|
|
10
|
+
} from '../constants';
|
|
4
11
|
|
|
5
12
|
export default class BaseLineLayer extends InternalCourtLayer {
|
|
6
13
|
original() {
|
|
@@ -14,7 +21,7 @@ export default class BaseLineLayer extends InternalCourtLayer {
|
|
|
14
21
|
drawLogic() {
|
|
15
22
|
const homePlateApex = { x: this.courtCenter.x, y: HOME_PLATE_APEX_TO_BACKSTOP };
|
|
16
23
|
|
|
17
|
-
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH *
|
|
24
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 3;
|
|
18
25
|
|
|
19
26
|
this.ctx.save();
|
|
20
27
|
this.ctx.translate(homePlateApex.x, homePlateApex.y);
|
|
@@ -26,16 +33,18 @@ export default class BaseLineLayer extends InternalCourtLayer {
|
|
|
26
33
|
this.ctx.stroke();
|
|
27
34
|
this.drawBaseSquare(BASE_LINE_LENGTH, 0);
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
this.ctx.
|
|
31
|
-
this.ctx.
|
|
32
|
-
this.ctx.
|
|
36
|
+
// line between 1st & 2nd bases
|
|
37
|
+
// this.ctx.beginPath();
|
|
38
|
+
// this.ctx.moveTo(BASE_LINE_LENGTH, 0);
|
|
39
|
+
// this.ctx.lineTo(BASE_LINE_LENGTH, BASE_LINE_LENGTH);
|
|
40
|
+
// this.ctx.stroke();
|
|
33
41
|
this.drawBaseSquare(BASE_LINE_LENGTH + BASE_SQUARE_SIDE_LENGTH / 2, BASE_LINE_LENGTH - BASE_SQUARE_SIDE_LENGTH / 2);
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
this.ctx.
|
|
37
|
-
this.ctx.
|
|
38
|
-
this.ctx.
|
|
43
|
+
// line between 2st & 3nd bases
|
|
44
|
+
// this.ctx.beginPath();
|
|
45
|
+
// this.ctx.moveTo(BASE_LINE_LENGTH, BASE_LINE_LENGTH);
|
|
46
|
+
// this.ctx.lineTo(0, BASE_LINE_LENGTH);
|
|
47
|
+
// this.ctx.stroke();
|
|
39
48
|
this.drawBaseSquare(BASE_SQUARE_SIDE_LENGTH, BASE_LINE_LENGTH - BASE_SQUARE_SIDE_LENGTH);
|
|
40
49
|
|
|
41
50
|
this.ctx.beginPath();
|
|
@@ -54,6 +63,23 @@ export default class BaseLineLayer extends InternalCourtLayer {
|
|
|
54
63
|
this.ctx.stroke();
|
|
55
64
|
this.ctx.restore();
|
|
56
65
|
});
|
|
66
|
+
|
|
67
|
+
// Home run arc
|
|
68
|
+
const homeRunArcCenterOffsetY = 138;
|
|
69
|
+
const homeRunArcStartAngle = Math.PI / 8.1;
|
|
70
|
+
const homeRunArcEndAngle = Math.PI - Math.PI / 8.1;
|
|
71
|
+
this.ctx.save();
|
|
72
|
+
this.ctx.beginPath();
|
|
73
|
+
this.ctx.arc(
|
|
74
|
+
homePlateApex.x,
|
|
75
|
+
homePlateApex.y + homeRunArcCenterOffsetY,
|
|
76
|
+
HOME_RUN_FENCE_CENTER_DISTANCE - homeRunArcCenterOffsetY,
|
|
77
|
+
homeRunArcStartAngle,
|
|
78
|
+
homeRunArcEndAngle,
|
|
79
|
+
false
|
|
80
|
+
);
|
|
81
|
+
this.ctx.stroke();
|
|
82
|
+
this.ctx.restore();
|
|
57
83
|
}
|
|
58
84
|
|
|
59
85
|
drawBaseSquare(x: number, y: number) {
|
package/src/layers/court/layers/BASEBALL/courtTypes/BASEBALL_HIGH_SCHOOL/layers/HomePlateLayer.ts
CHANGED
|
@@ -43,26 +43,42 @@ export default class HomePlateLayer extends InternalCourtLayer {
|
|
|
43
43
|
this.ctx.stroke();
|
|
44
44
|
this.ctx.fill();
|
|
45
45
|
|
|
46
|
+
// // 2. Batters Box
|
|
47
|
+
// [-1, 1].forEach(sideIndex => {
|
|
48
|
+
// this.ctx.save();
|
|
49
|
+
// this.ctx.translate(homePlateApex.x, homePlateApex.y + HOME_PLATE_SIDE / 2);
|
|
50
|
+
// this.ctx.beginPath();
|
|
51
|
+
// const battersBoxClosestX = HOME_PLATE_SIDE / 2 + HOME_PLATE_SIDE_TO_BATTERS_BOX;
|
|
52
|
+
// this.ctx.moveTo(sideIndex * battersBoxClosestX, 0);
|
|
53
|
+
// this.ctx.lineTo(sideIndex * battersBoxClosestX, BATTERS_BOX_HEIGHT / 2);
|
|
54
|
+
// this.ctx.lineTo(sideIndex * (battersBoxClosestX + BATTERS_BOX_WIDTH), 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_HEIGHT / 2);
|
|
57
|
+
// this.ctx.lineTo(sideIndex * battersBoxClosestX, 0);
|
|
58
|
+
// this.ctx.stroke();
|
|
59
|
+
// this.ctx.restore();
|
|
60
|
+
// });
|
|
61
|
+
|
|
46
62
|
// 2. Batters Box
|
|
47
63
|
[-1, 1].forEach(sideIndex => {
|
|
48
64
|
this.ctx.save();
|
|
49
65
|
this.ctx.translate(homePlateApex.x, homePlateApex.y + HOME_PLATE_SIDE / 2);
|
|
50
66
|
this.ctx.beginPath();
|
|
51
|
-
|
|
52
67
|
const battersBoxClosestX = HOME_PLATE_SIDE / 2 + HOME_PLATE_SIDE_TO_BATTERS_BOX;
|
|
53
|
-
|
|
54
68
|
this.ctx.moveTo(sideIndex * battersBoxClosestX, 0);
|
|
55
|
-
this.ctx.lineTo(sideIndex * battersBoxClosestX,
|
|
56
|
-
this.ctx.lineTo(sideIndex * (battersBoxClosestX + BATTERS_BOX_WIDTH),
|
|
57
|
-
this.ctx.lineTo(sideIndex * (battersBoxClosestX + BATTERS_BOX_WIDTH),
|
|
58
|
-
this.ctx.lineTo(sideIndex * battersBoxClosestX,
|
|
69
|
+
this.ctx.lineTo(sideIndex * battersBoxClosestX, HOME_PLATE_SIDE / 2);
|
|
70
|
+
this.ctx.lineTo(sideIndex * (battersBoxClosestX + BATTERS_BOX_WIDTH), HOME_PLATE_SIDE / 2);
|
|
71
|
+
this.ctx.lineTo(sideIndex * (battersBoxClosestX + BATTERS_BOX_WIDTH), HOME_PLATE_SIDE / 2 - BATTERS_BOX_HEIGHT);
|
|
72
|
+
this.ctx.lineTo(sideIndex * battersBoxClosestX, HOME_PLATE_SIDE / 2 - BATTERS_BOX_HEIGHT);
|
|
73
|
+
this.ctx.lineTo(sideIndex * battersBoxClosestX, 0);
|
|
59
74
|
this.ctx.lineTo(sideIndex * battersBoxClosestX, 0);
|
|
60
75
|
this.ctx.stroke();
|
|
61
76
|
this.ctx.restore();
|
|
62
77
|
});
|
|
63
78
|
|
|
64
79
|
// 3. Catchers box
|
|
65
|
-
const battersBoxNearestY = homePlateApex.y + HOME_PLATE_SIDE / 2 - BATTERS_BOX_HEIGHT / 2;
|
|
80
|
+
// const battersBoxNearestY = homePlateApex.y + HOME_PLATE_SIDE / 2 - BATTERS_BOX_HEIGHT / 2;
|
|
81
|
+
const battersBoxNearestY = homePlateApex.y + HOME_PLATE_SIDE / 2 - BATTERS_BOX_HEIGHT + HOME_PLATE_SIDE / 2;
|
|
66
82
|
[-1, 1].forEach(sideIndex => {
|
|
67
83
|
this.ctx.save();
|
|
68
84
|
this.ctx.translate(this.courtCenter.x, battersBoxNearestY - BATTERS_BOX_TO_CATCHERS_BACK_LINE);
|
package/src/models/FrameModel.ts
CHANGED
|
@@ -489,8 +489,9 @@ export default class FrameModel {
|
|
|
489
489
|
prepareCourtPoint(courtPoint: CourtPoint) {
|
|
490
490
|
const { mirror } = this.play.options;
|
|
491
491
|
const { width } = this.play.playData.court.courtRect.size;
|
|
492
|
+
const { origin } = this.play.playData.court.courtRect;
|
|
492
493
|
return {
|
|
493
|
-
x: mirror ? width - courtPoint.x : courtPoint.x,
|
|
494
|
+
x: mirror ? width + origin.x - (courtPoint.x - origin.x) : courtPoint.x,
|
|
494
495
|
y: courtPoint.y
|
|
495
496
|
};
|
|
496
497
|
}
|