@luceosports/play-rendering 2.4.1 → 2.4.3
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 +4 -4
- package/dist/play-rendering.js.map +1 -1
- package/dist/static/img/concrete_bg.png +0 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/assets/concrete_bg.png +0 -0
- package/src/constants.ts +1 -0
- package/src/layers/CourtLayer.ts +7 -2
- package/src/layers/PlayerLayer.ts +2 -2
- package/src/layers/court/index.ts +10 -3
- package/src/layers/court/layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/constants.ts +6 -0
- package/src/layers/court/layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/layers/CenterCircleLayer.ts +26 -0
- package/src/layers/court/layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/layers/FanLineLayer.ts +72 -0
- package/src/layers/court/layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/layers/RefereeCreaseLayer.ts +24 -0
- package/src/layers/court/layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/layers/RestrainingLineLayer.ts +66 -0
- package/src/layers/court/layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/layers/index.ts +6 -0
- package/src/layers/court/layers/LACROSSE_BOX/{layers → courtTypes/LACROSSE_BOX_US/layers}/CenterCircleLayer.ts +1 -1
- package/src/layers/court/layers/LACROSSE_BOX/{layers → courtTypes/LACROSSE_BOX_US/layers}/CenterLineLayer.ts +1 -1
- package/src/layers/court/layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_US/layers/index.ts +3 -1
- package/src/layers/court/layers/LACROSSE_BOX/layers/index.ts +1 -3
- package/src/models/PlayModel.ts +8 -1
- package/src/type-guards.ts +7 -0
- package/src/types/index.ts +1 -1
|
Binary file
|
|
@@ -21,6 +21,7 @@ export declare const COURT_TYPE_VOLLEYBALL_INDOOR = "VOLLEYBALL_INDOOR";
|
|
|
21
21
|
export declare const COURT_TYPE_LACROSSE_US_M = "LACROSSE_US_M";
|
|
22
22
|
export declare const COURT_TYPE_LACROSSE_US_W = "LACROSSE_US_W";
|
|
23
23
|
export declare const COURT_TYPE_LACROSSE_BOX_US = 'LACROSSE_BOX_US';
|
|
24
|
+
export declare const COURT_TYPE_LACROSSE_BOX_CLA = 'LACROSSE_BOX_CLA';
|
|
24
25
|
export declare const COURT_TYPE_SOCCER_FIFA = "SOCCER_FIFA";
|
|
25
26
|
export declare const COURT_TYPE_SOCCER_NCAA = "SOCCER_NCAA";
|
|
26
27
|
export declare const COURT_TYPE_SOCCER_NFHS = "SOCCER_NFHS";
|
|
@@ -12,7 +12,7 @@ export type CourtTypeSportSoccer = 'SOCCER_FIFA' | 'SOCCER_NCAA' | 'SOCCER_NFHS'
|
|
|
12
12
|
export type CourtTypeSportHockey = 'HOCKEY_NHL' | 'HOCKEY_INTERNATIONAL';
|
|
13
13
|
export type CourtTypeSportBaseball = 'BASEBALL_HIGH_SCHOOL';
|
|
14
14
|
export type CourtTypeSportLacrosse = 'LACROSSE_US_M' | 'LACROSSE_US_W';
|
|
15
|
-
export type CourtTypeSportLacrosseBox = 'LACROSSE_BOX_US';
|
|
15
|
+
export type CourtTypeSportLacrosseBox = 'LACROSSE_BOX_US' | 'LACROSSE_BOX_CLA';
|
|
16
16
|
export type CourtTypeSportSoftball = 'SOFTBALL_FP_COLLEGE' | 'SOFTBALL_FP_HS';
|
|
17
17
|
export type CourtTypeSportFootball = 'FOOTBALL_HIGH_SCHOOL';
|
|
18
18
|
export type CourtTypeSportFootballLegacy = 'FOOTBALL';
|
package/package.json
CHANGED
|
Binary file
|
package/src/constants.ts
CHANGED
|
@@ -26,6 +26,7 @@ export const COURT_TYPE_LACROSSE_US_M = 'LACROSSE_US_M';
|
|
|
26
26
|
export const COURT_TYPE_LACROSSE_US_W = 'LACROSSE_US_W';
|
|
27
27
|
|
|
28
28
|
export const COURT_TYPE_LACROSSE_BOX_US = 'LACROSSE_BOX_US';
|
|
29
|
+
export const COURT_TYPE_LACROSSE_BOX_CLA = 'LACROSSE_BOX_CLA';
|
|
29
30
|
|
|
30
31
|
export const COURT_TYPE_SOCCER_FIFA = 'SOCCER_FIFA';
|
|
31
32
|
export const COURT_TYPE_SOCCER_NCAA = 'SOCCER_NCAA';
|
package/src/layers/CourtLayer.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BaseLayer from './base/BaseLayer';
|
|
2
2
|
import { courtTypeLayers, sportLayers } from './court';
|
|
3
|
+
import { isBackgroundOption } from '../type-guards';
|
|
3
4
|
|
|
4
5
|
export default class CourtLayer extends BaseLayer {
|
|
5
6
|
get frameWidth() {
|
|
@@ -23,7 +24,7 @@ export default class CourtLayer extends BaseLayer {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
get background() {
|
|
26
|
-
return
|
|
27
|
+
return this.options.background || this.courtTypeConstants.BACKGROUND || this.playData.sport;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
apply() {
|
|
@@ -57,7 +58,11 @@ export default class CourtLayer extends BaseLayer {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
setBackground() {
|
|
60
|
-
if (
|
|
61
|
+
if (
|
|
62
|
+
isBackgroundOption(this.background) &&
|
|
63
|
+
this.staticData.backgroundOptions &&
|
|
64
|
+
this.staticData.backgroundOptions[this.background]
|
|
65
|
+
) {
|
|
61
66
|
this.ctx.fillStyle = this.ctx.createPattern(this.staticData.backgroundOptions[this.background], 'repeat')!;
|
|
62
67
|
this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
|
|
63
68
|
} else if (this.background.indexOf('#') === 0) {
|
|
@@ -147,11 +147,11 @@ export default class PlayerLayer extends BaseLayer {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
let playerTextLabel = player.textLabel;
|
|
150
|
-
if (playerMapItem
|
|
150
|
+
if (playerMapItem) {
|
|
151
151
|
if (playerMapItem.textOverride) {
|
|
152
152
|
playerTextLabel = playerMapItem.textOverride;
|
|
153
153
|
}
|
|
154
|
-
if (playerMapItem.teamPlayerId) {
|
|
154
|
+
if (playerMapItem.teamPlayerId && this.options.labelsOverrideType) {
|
|
155
155
|
const teamPlayer = this.staticData.teamPlayers.find(p => p.id === playerMapItem.teamPlayerId);
|
|
156
156
|
if (teamPlayer) {
|
|
157
157
|
const fallbackLabel = teamPlayer.User_Name.split(' ')
|
|
@@ -33,7 +33,8 @@ import {
|
|
|
33
33
|
SPORT_TYPE_LACROSSE_BOX,
|
|
34
34
|
SPORT_TYPE_SOFTBALL,
|
|
35
35
|
COURT_TYPE_SOFTBALL_FP_COLLEGE,
|
|
36
|
-
COURT_TYPE_SOFTBALL_FP_HIGH_SCHOOL
|
|
36
|
+
COURT_TYPE_SOFTBALL_FP_HIGH_SCHOOL,
|
|
37
|
+
COURT_TYPE_LACROSSE_BOX_CLA
|
|
37
38
|
} from '../../constants';
|
|
38
39
|
|
|
39
40
|
export type SportConstants = {
|
|
@@ -47,6 +48,7 @@ export type SportConstants = {
|
|
|
47
48
|
export type CourtTypeConstants = {
|
|
48
49
|
COURT_RECT_WIDTH: number;
|
|
49
50
|
COURT_RECT_HEIGHT: number;
|
|
51
|
+
BACKGROUND?: keyof typeof PlayModel.backgroundOptions | string;
|
|
50
52
|
} & Record<string, any>;
|
|
51
53
|
|
|
52
54
|
import InternalCourtLayer from './base/InternalCourtLayer';
|
|
@@ -104,6 +106,8 @@ import * as LacrosseBoxLayers from './layers/LACROSSE_BOX/layers';
|
|
|
104
106
|
import * as LacrosseBoxConstants from './layers/LACROSSE_BOX/constants';
|
|
105
107
|
import * as LacrosseBoxUsLayers from './layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_US/layers';
|
|
106
108
|
import * as LacrosseBoxUsConstants from './layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_US/constants';
|
|
109
|
+
import * as LacrosseBoxClaLayers from './layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/layers';
|
|
110
|
+
import * as LacrosseBoxClaConstants from './layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/constants';
|
|
107
111
|
|
|
108
112
|
import * as SoccerLayers from './layers/SOCCER/layers';
|
|
109
113
|
import * as SoccerConstants from './layers/SOCCER/constants';
|
|
@@ -121,6 +125,7 @@ import * as SoccerU12Constants from './layers/SOCCER/courtTypes/SOCCER_U12/const
|
|
|
121
125
|
import * as VolleyballLayers from './layers/VOLLEYBALL/layers';
|
|
122
126
|
import * as VolleyballConstants from './layers/VOLLEYBALL/constants';
|
|
123
127
|
import * as VolleyballIndoorConstants from './layers/VOLLEYBALL/courtTypes/VOLLEYBALL_INDOOR/constants';
|
|
128
|
+
import PlayModel from '../../models/PlayModel';
|
|
124
129
|
|
|
125
130
|
const sportLayers: Record<SportType, Record<string, typeof InternalCourtLayer>> = {
|
|
126
131
|
[SPORT_TYPE_BASEBALL]: BaseballLayers,
|
|
@@ -162,7 +167,8 @@ const courtTypeLayers: Record<SportType, Partial<Record<CourtType, Record<string
|
|
|
162
167
|
[COURT_TYPE_LACROSSE_US_W]: LacrosseUsWLayers
|
|
163
168
|
},
|
|
164
169
|
[SPORT_TYPE_LACROSSE_BOX]: {
|
|
165
|
-
[COURT_TYPE_LACROSSE_BOX_US]: LacrosseBoxUsLayers
|
|
170
|
+
[COURT_TYPE_LACROSSE_BOX_US]: LacrosseBoxUsLayers,
|
|
171
|
+
[COURT_TYPE_LACROSSE_BOX_CLA]: LacrosseBoxClaLayers
|
|
166
172
|
},
|
|
167
173
|
[SPORT_TYPE_SOCCER]: {
|
|
168
174
|
[COURT_TYPE_SOCCER_NCAA]: SoccerNcaaLayers,
|
|
@@ -203,6 +209,7 @@ const courtTypeConstants: Record<CourtType, CourtTypeConstants> = {
|
|
|
203
209
|
[COURT_TYPE_LACROSSE_US_M]: LacrosseUsMConstants,
|
|
204
210
|
[COURT_TYPE_LACROSSE_US_W]: LacrosseUsWConstants,
|
|
205
211
|
[COURT_TYPE_LACROSSE_BOX_US]: LacrosseBoxUsConstants,
|
|
212
|
+
[COURT_TYPE_LACROSSE_BOX_CLA]: LacrosseBoxClaConstants,
|
|
206
213
|
[COURT_TYPE_SOCCER_FIFA]: SoccerFifaConstants,
|
|
207
214
|
[COURT_TYPE_SOCCER_NCAA]: SoccerNcaaConstants,
|
|
208
215
|
[COURT_TYPE_SOCCER_NFHS]: SoccerNfhsConstants,
|
|
@@ -229,7 +236,7 @@ const sportCourtTypeMap: Record<SportType, { courtTypes: CourtType[] }> = {
|
|
|
229
236
|
[SPORT_TYPE_FOOTBALL]: { courtTypes: [COURT_TYPE_FOOTBALL_HIGH_SCHOOL] },
|
|
230
237
|
[SPORT_TYPE_HOCKEY]: { courtTypes: [COURT_TYPE_HOCKEY_NHL, COURT_TYPE_HOCKEY_INTERNATIONAL] },
|
|
231
238
|
[SPORT_TYPE_LACROSSE]: { courtTypes: [COURT_TYPE_LACROSSE_US_M, COURT_TYPE_LACROSSE_US_W] },
|
|
232
|
-
[SPORT_TYPE_LACROSSE_BOX]: { courtTypes: [COURT_TYPE_LACROSSE_BOX_US] },
|
|
239
|
+
[SPORT_TYPE_LACROSSE_BOX]: { courtTypes: [COURT_TYPE_LACROSSE_BOX_US, COURT_TYPE_LACROSSE_BOX_CLA] },
|
|
233
240
|
[SPORT_TYPE_SOCCER]: {
|
|
234
241
|
courtTypes: [
|
|
235
242
|
COURT_TYPE_SOCCER_FIFA,
|
package/src/layers/court/layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/layers/CenterCircleLayer.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import InternalCourtLayer from '../../../../../base/InternalCourtLayer';
|
|
2
|
+
|
|
3
|
+
const CENTER_DOT_RADIUS = 0.5;
|
|
4
|
+
const CENTER_CIRCLE_RADIUS = 2;
|
|
5
|
+
const CENTER_CIRCLE_LINE_LENGTH = 6;
|
|
6
|
+
|
|
7
|
+
export default class CenterCircleLayer extends InternalCourtLayer {
|
|
8
|
+
drawLogic() {
|
|
9
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
10
|
+
|
|
11
|
+
this.ctx.beginPath();
|
|
12
|
+
this.ctx.arc(this.courtCenter.x, this.courtCenter.y, CENTER_DOT_RADIUS, 0, Math.PI * 2, true);
|
|
13
|
+
this.ctx.fill();
|
|
14
|
+
|
|
15
|
+
this.ctx.beginPath();
|
|
16
|
+
this.ctx.arc(this.courtCenter.x, this.courtCenter.y, CENTER_CIRCLE_RADIUS, 0, Math.PI * 2, true);
|
|
17
|
+
this.ctx.stroke();
|
|
18
|
+
|
|
19
|
+
[CENTER_CIRCLE_RADIUS, -CENTER_CIRCLE_RADIUS].forEach(offset => {
|
|
20
|
+
this.ctx.beginPath();
|
|
21
|
+
this.ctx.moveTo(this.courtCenter.x + offset, this.courtCenter.y - CENTER_CIRCLE_LINE_LENGTH / 2);
|
|
22
|
+
this.ctx.lineTo(this.courtCenter.x + offset, this.courtCenter.y + CENTER_CIRCLE_LINE_LENGTH / 2);
|
|
23
|
+
this.ctx.stroke();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/layers/court/layers/LACROSSE_BOX/courtTypes/LACROSSE_BOX_CLA/layers/FanLineLayer.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import InternalCourtLayer from '../../../../../base/InternalCourtLayer';
|
|
2
|
+
|
|
3
|
+
const GOAL_ARC_RADIUS = 9.25;
|
|
4
|
+
const GOAL_ARC_OUTER_RADIUS = 24;
|
|
5
|
+
const GOAL_LINE_CAGE_LENGTH = 4.75;
|
|
6
|
+
const GOAL_BACK_LINE_OFFSET_Y = 6;
|
|
7
|
+
|
|
8
|
+
export default class FanLineLayer extends InternalCourtLayer {
|
|
9
|
+
reflection() {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
drawLogic() {
|
|
14
|
+
const goalLineCenter = {
|
|
15
|
+
x: this.courtCenter.x,
|
|
16
|
+
y: this.courtTypeConstants.GOAL_LINE_Y
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
20
|
+
|
|
21
|
+
// 1. Draw goal line
|
|
22
|
+
this.ctx.beginPath();
|
|
23
|
+
this.ctx.moveTo(goalLineCenter.x - GOAL_ARC_RADIUS, goalLineCenter.y);
|
|
24
|
+
this.ctx.lineTo(goalLineCenter.x + GOAL_ARC_RADIUS, goalLineCenter.y);
|
|
25
|
+
this.ctx.stroke();
|
|
26
|
+
|
|
27
|
+
// 2.1 Draw arc
|
|
28
|
+
const angleOffset = Math.PI / 4.5;
|
|
29
|
+
this.ctx.beginPath();
|
|
30
|
+
this.ctx.arc(goalLineCenter.x, goalLineCenter.y, GOAL_ARC_RADIUS, -angleOffset, Math.PI + angleOffset, false);
|
|
31
|
+
this.ctx.stroke();
|
|
32
|
+
|
|
33
|
+
// 2.2 Draw outer dashed arc
|
|
34
|
+
this.ctx.save();
|
|
35
|
+
|
|
36
|
+
this.ctx.setLineDash([1.2, 0.4]);
|
|
37
|
+
this.ctx.beginPath();
|
|
38
|
+
this.ctx.arc(goalLineCenter.x, goalLineCenter.y, GOAL_ARC_OUTER_RADIUS, 0, Math.PI, false);
|
|
39
|
+
this.ctx.stroke();
|
|
40
|
+
|
|
41
|
+
this.ctx.beginPath();
|
|
42
|
+
this.ctx.moveTo(goalLineCenter.x - GOAL_ARC_RADIUS, goalLineCenter.y);
|
|
43
|
+
this.ctx.lineTo(goalLineCenter.x - GOAL_ARC_OUTER_RADIUS, goalLineCenter.y);
|
|
44
|
+
this.ctx.stroke();
|
|
45
|
+
|
|
46
|
+
this.ctx.beginPath();
|
|
47
|
+
this.ctx.moveTo(goalLineCenter.x + GOAL_ARC_RADIUS, goalLineCenter.y);
|
|
48
|
+
this.ctx.lineTo(goalLineCenter.x + GOAL_ARC_OUTER_RADIUS, goalLineCenter.y);
|
|
49
|
+
this.ctx.stroke();
|
|
50
|
+
|
|
51
|
+
this.ctx.restore();
|
|
52
|
+
|
|
53
|
+
// 3. Draw goal back line
|
|
54
|
+
const backLineOffsetX = 2;
|
|
55
|
+
this.ctx.beginPath();
|
|
56
|
+
this.ctx.moveTo(goalLineCenter.x - (GOAL_ARC_RADIUS - backLineOffsetX), goalLineCenter.y - GOAL_BACK_LINE_OFFSET_Y);
|
|
57
|
+
this.ctx.lineTo(goalLineCenter.x + (GOAL_ARC_RADIUS - backLineOffsetX), goalLineCenter.y - GOAL_BACK_LINE_OFFSET_Y);
|
|
58
|
+
this.ctx.stroke();
|
|
59
|
+
|
|
60
|
+
// 4. Draw goal line cage
|
|
61
|
+
const goalCageLeft = { x: goalLineCenter.x - GOAL_LINE_CAGE_LENGTH / 2, y: goalLineCenter.y };
|
|
62
|
+
const goalCageRight = { x: goalLineCenter.x + GOAL_LINE_CAGE_LENGTH / 2, y: goalLineCenter.y };
|
|
63
|
+
const goalCageTop = { x: goalLineCenter.x, y: goalLineCenter.y - GOAL_LINE_CAGE_LENGTH / 2 };
|
|
64
|
+
|
|
65
|
+
this.ctx.beginPath();
|
|
66
|
+
this.ctx.moveTo(goalCageLeft.x, goalCageLeft.y);
|
|
67
|
+
this.ctx.lineTo(goalCageRight.x, goalCageRight.y);
|
|
68
|
+
this.ctx.lineTo(goalCageTop.x, goalCageTop.y);
|
|
69
|
+
this.ctx.closePath();
|
|
70
|
+
this.ctx.stroke();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import InternalCourtLayer from '../../../../../base/InternalCourtLayer';
|
|
2
|
+
|
|
3
|
+
const REFEREE_CREASE_RADIUS = 10;
|
|
4
|
+
const REFEREE_CREASE_BOX_LENGTH = 24;
|
|
5
|
+
const REFEREE_CREASE_BOX_WIDTH = 5;
|
|
6
|
+
|
|
7
|
+
export default class RefereeCreaseLayer extends InternalCourtLayer {
|
|
8
|
+
drawLogic() {
|
|
9
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
10
|
+
|
|
11
|
+
// 1. Draw referee crease half arc
|
|
12
|
+
this.ctx.beginPath();
|
|
13
|
+
this.ctx.arc(0, this.courtCenter.y, REFEREE_CREASE_RADIUS, Math.PI / 2, -Math.PI / 2, true);
|
|
14
|
+
this.ctx.stroke();
|
|
15
|
+
|
|
16
|
+
// 2. Draw scorekeepers bench
|
|
17
|
+
this.ctx.beginPath();
|
|
18
|
+
this.ctx.moveTo(0, this.courtCenter.y - REFEREE_CREASE_RADIUS);
|
|
19
|
+
this.ctx.lineTo(-REFEREE_CREASE_BOX_WIDTH, this.courtCenter.y - REFEREE_CREASE_RADIUS);
|
|
20
|
+
this.ctx.lineTo(-REFEREE_CREASE_BOX_WIDTH, this.courtCenter.y + REFEREE_CREASE_RADIUS);
|
|
21
|
+
this.ctx.lineTo(0, this.courtCenter.y + REFEREE_CREASE_RADIUS);
|
|
22
|
+
this.ctx.stroke();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import InternalCourtLayer from '../../../../../base/InternalCourtLayer';
|
|
2
|
+
|
|
3
|
+
const PLAYERS_BENCH_COURT_CENTER_OFFSET_Y = 5;
|
|
4
|
+
const PLAYERS_BENCH_LENGTH = 30;
|
|
5
|
+
const PLAYERS_BENCH_WIDTH = 5;
|
|
6
|
+
const EXCHANGE_AREA_WIDTH = 4;
|
|
7
|
+
const EXCHANGE_AREA_OFFSET_Y = 0.5;
|
|
8
|
+
const PENALTY_BOX_WIDTH = 5;
|
|
9
|
+
const PENALTY_BOX_LENGTH = 12;
|
|
10
|
+
|
|
11
|
+
export default class RestrainingLineLayer extends InternalCourtLayer {
|
|
12
|
+
reflection() {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
drawLogic() {
|
|
17
|
+
const courtOrigin = { x: 0.0, y: this.courtCenter.y - this.courtTypeConstants.RESTRAINING_LINE_OFFSET_Y };
|
|
18
|
+
const courtTerminus = {
|
|
19
|
+
x: this.courtTypeConstants.COURT_RECT_WIDTH,
|
|
20
|
+
y: this.courtCenter.y - this.courtTypeConstants.RESTRAINING_LINE_OFFSET_Y
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// 1. Draw restraining line
|
|
24
|
+
this.ctx.beginPath();
|
|
25
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
26
|
+
this.ctx.moveTo(courtOrigin.x, courtOrigin.y);
|
|
27
|
+
this.ctx.lineTo(courtTerminus.x, courtTerminus.y);
|
|
28
|
+
this.ctx.stroke();
|
|
29
|
+
|
|
30
|
+
// 2. Draw players bench
|
|
31
|
+
const playersBenchStartY = this.courtCenter.y - PLAYERS_BENCH_COURT_CENTER_OFFSET_Y;
|
|
32
|
+
|
|
33
|
+
this.ctx.beginPath();
|
|
34
|
+
this.ctx.moveTo(this.courtTypeConstants.COURT_RECT_WIDTH, playersBenchStartY);
|
|
35
|
+
this.ctx.lineTo(this.courtTypeConstants.COURT_RECT_WIDTH + PLAYERS_BENCH_WIDTH, playersBenchStartY);
|
|
36
|
+
this.ctx.lineTo(
|
|
37
|
+
this.courtTypeConstants.COURT_RECT_WIDTH + PLAYERS_BENCH_WIDTH,
|
|
38
|
+
playersBenchStartY - PLAYERS_BENCH_LENGTH
|
|
39
|
+
);
|
|
40
|
+
this.ctx.lineTo(this.courtTypeConstants.COURT_RECT_WIDTH, playersBenchStartY - PLAYERS_BENCH_LENGTH);
|
|
41
|
+
this.ctx.stroke();
|
|
42
|
+
|
|
43
|
+
// 3. Draw exchange area
|
|
44
|
+
this.ctx.beginPath();
|
|
45
|
+
this.ctx.moveTo(this.courtTypeConstants.COURT_RECT_WIDTH - EXCHANGE_AREA_WIDTH, this.courtCenter.y);
|
|
46
|
+
this.ctx.lineTo(
|
|
47
|
+
this.courtTypeConstants.COURT_RECT_WIDTH - EXCHANGE_AREA_WIDTH,
|
|
48
|
+
this.courtCenter.y - PLAYERS_BENCH_LENGTH - PLAYERS_BENCH_COURT_CENTER_OFFSET_Y + EXCHANGE_AREA_OFFSET_Y
|
|
49
|
+
);
|
|
50
|
+
this.ctx.lineTo(
|
|
51
|
+
this.courtTypeConstants.COURT_RECT_WIDTH,
|
|
52
|
+
this.courtCenter.y - PLAYERS_BENCH_LENGTH - PLAYERS_BENCH_COURT_CENTER_OFFSET_Y + EXCHANGE_AREA_OFFSET_Y
|
|
53
|
+
);
|
|
54
|
+
this.ctx.stroke();
|
|
55
|
+
|
|
56
|
+
// 4. Draw penalty boxes
|
|
57
|
+
const penaltyBoxStartY = this.courtCenter.y - this.courtTypeConstants.RESTRAINING_LINE_OFFSET_Y;
|
|
58
|
+
|
|
59
|
+
this.ctx.beginPath();
|
|
60
|
+
this.ctx.moveTo(0, penaltyBoxStartY);
|
|
61
|
+
this.ctx.lineTo(0 - PENALTY_BOX_WIDTH, penaltyBoxStartY);
|
|
62
|
+
this.ctx.lineTo(0 - PENALTY_BOX_WIDTH, penaltyBoxStartY - PENALTY_BOX_LENGTH);
|
|
63
|
+
this.ctx.lineTo(0, penaltyBoxStartY - PENALTY_BOX_LENGTH);
|
|
64
|
+
this.ctx.stroke();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import CenterCircleLayer from './CenterCircleLayer';
|
|
2
|
+
import RestrainingLineLayer from './RestrainingLineLayer';
|
|
3
|
+
import FanLineLayer from './FanLineLayer';
|
|
4
|
+
import RefereeCreaseLayer from './RefereeCreaseLayer';
|
|
5
|
+
|
|
6
|
+
export { CenterCircleLayer, RestrainingLineLayer, FanLineLayer, RefereeCreaseLayer };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import CenterCircleLayer from './CenterCircleLayer';
|
|
2
|
+
import CenterLineLayer from './CenterLineLayer';
|
|
1
3
|
import RestrainingLineLayer from './RestrainingLineLayer';
|
|
2
4
|
import FanLineLayer from './FanLineLayer';
|
|
3
5
|
import RefereeCreaseLayer from './RefereeCreaseLayer';
|
|
4
6
|
|
|
5
|
-
export { RestrainingLineLayer, FanLineLayer, RefereeCreaseLayer };
|
|
7
|
+
export { CenterCircleLayer, CenterLineLayer, RestrainingLineLayer, FanLineLayer, RefereeCreaseLayer };
|
package/src/models/PlayModel.ts
CHANGED
|
@@ -20,7 +20,9 @@ import { PlayConstructData, PlayData, Position, SportType } from '../types';
|
|
|
20
20
|
import hardwoodImageData from '../assets/wood_bg.png';
|
|
21
21
|
import grassImageData from '../assets/grass_bg.png';
|
|
22
22
|
import iceImageData from '../assets/ice_bg.png';
|
|
23
|
+
import concreteImageData from '../assets/concrete_bg.png';
|
|
23
24
|
import { loadImage } from '../helpers/common';
|
|
25
|
+
import { im } from 'mathjs';
|
|
24
26
|
|
|
25
27
|
const STORAGE_URL = 'https://playbooksstore.blob.core.windows.net/public';
|
|
26
28
|
const LUCEOSPORTS_WATERMARK_PATH = 'partners/LuceoSports/luceo-sports-logo-powered-by-sm.png';
|
|
@@ -97,7 +99,10 @@ export default class PlayModel {
|
|
|
97
99
|
public static playerHats: readonly ImageConfigItem[];
|
|
98
100
|
public static shapes: readonly ImageConfigItem[];
|
|
99
101
|
public static watermark: { LuceoSports: HTMLImageElement; TeamLogo: HTMLImageElement | null };
|
|
100
|
-
public static backgroundOptions: Record<SportType, HTMLImageElement> & {
|
|
102
|
+
public static backgroundOptions: Record<SportType, HTMLImageElement> & {
|
|
103
|
+
Hardwood: HTMLImageElement;
|
|
104
|
+
Concrete: HTMLImageElement;
|
|
105
|
+
};
|
|
101
106
|
|
|
102
107
|
constructor(data: PlayConstructData, options?: Partial<PlayModelOptions>) {
|
|
103
108
|
this.name = data.name;
|
|
@@ -112,9 +117,11 @@ export default class PlayModel {
|
|
|
112
117
|
const hardwoodImage = await loadImage(hardwoodImageData);
|
|
113
118
|
const grassImage = await loadImage(grassImageData);
|
|
114
119
|
const iceImage = await loadImage(iceImageData);
|
|
120
|
+
const concreteImage = await loadImage(concreteImageData);
|
|
115
121
|
|
|
116
122
|
PlayModel.backgroundOptions = {
|
|
117
123
|
Hardwood: hardwoodImage,
|
|
124
|
+
Concrete: concreteImage,
|
|
118
125
|
[SPORT_TYPE_BASKETBALL]: hardwoodImage,
|
|
119
126
|
[SPORT_TYPE_VOLLEYBALL]: hardwoodImage,
|
|
120
127
|
[SPORT_TYPE_FOOTBALL]: grassImage,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import PlayModel from './models/PlayModel';
|
|
2
|
+
|
|
3
|
+
export function isBackgroundOption(
|
|
4
|
+
arg: keyof typeof PlayModel.backgroundOptions | string
|
|
5
|
+
): arg is keyof typeof PlayModel.backgroundOptions {
|
|
6
|
+
return (PlayModel.backgroundOptions as Record<string, any>)[arg] !== undefined;
|
|
7
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -51,7 +51,7 @@ export type CourtTypeSportSoftball = 'SOFTBALL_FP_COLLEGE' | 'SOFTBALL_FP_HS';
|
|
|
51
51
|
|
|
52
52
|
export type CourtTypeSportLacrosse = 'LACROSSE_US_M' | 'LACROSSE_US_W';
|
|
53
53
|
|
|
54
|
-
export type CourtTypeSportLacrosseBox = 'LACROSSE_BOX_US';
|
|
54
|
+
export type CourtTypeSportLacrosseBox = 'LACROSSE_BOX_US' | 'LACROSSE_BOX_CLA';
|
|
55
55
|
|
|
56
56
|
export type CourtTypeSportFootball = 'FOOTBALL_HIGH_SCHOOL';
|
|
57
57
|
|