@luceosports/play-rendering 1.9.25 → 1.9.29
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/assets/wood_bg.png +0 -0
- package/src/layers/CourtLayer.js +35 -27
- package/src/layers/PlayerLayer.js +16 -1
- package/src/layers/base/BaseLayer.js +0 -1
- package/src/layers/court/base/InternalCourtLayer.js +6 -1
- package/src/layers/court/constants/FOOTBALL.js +7 -0
- package/src/{constants.js → layers/court/constants/NBA.js} +0 -0
- package/src/layers/court/constants/index.js +11 -0
- package/src/layers/court/index.js +6 -2
- package/src/layers/court/layers/FOOTBALL/BorderRectLayer.js +13 -0
- package/src/layers/court/layers/FOOTBALL/CenterLineLayer.js +17 -0
- package/src/layers/court/layers/FOOTBALL/EndZoneLayer.js +21 -0
- package/src/layers/court/layers/FOOTBALL/FieldNumberLayer.js +36 -0
- package/src/layers/court/layers/FOOTBALL/HashMarkLayer.js +42 -0
- package/src/layers/court/layers/FOOTBALL/YardLineLayer.js +23 -0
- package/src/layers/court/layers/{BaseLineMarkingLayer.js → NBA/BaseLineMarkingLayer.js} +1 -1
- package/src/layers/court/layers/{BenchAreaLayer.js → NBA/BenchAreaLayer.js} +1 -1
- package/src/layers/court/layers/{Big3Layer.js → NBA/Big3Layer.js} +3 -3
- package/src/layers/court/layers/NBA/BorderRectLayer.js +13 -0
- package/src/layers/court/layers/{CenterCircleLayer.js → NBA/CenterCircleLayer.js} +3 -2
- package/src/layers/court/layers/NBA/CenterLineLayer.js +17 -0
- package/src/layers/court/layers/{FreeThrowLayer.js → NBA/FreeThrowLayer.js} +1 -1
- package/src/layers/court/layers/{HoopLayer.js → NBA/HoopLayer.js} +1 -1
- package/src/layers/court/layers/{InnerOuterRectLayer.js → NBA/InnerOuterRectLayer.js} +1 -1
- package/src/layers/court/layers/{LaneMarkingLayer.js → NBA/LaneMarkingLayer.js} +1 -1
- package/src/layers/court/layers/{RestrictedAreaLayer.js → NBA/RestrictedAreaLayer.js} +1 -1
- package/src/layers/court/layers/{ThreePointLineLayer.js → NBA/ThreePointLineLayer.js} +1 -1
- package/src/layers/line/base/InternalLineLayer.js +1 -0
- package/src/layers/line/layers/CutLineLayer.js +1 -1
- package/src/layers/line/layers/DribbleLineLayer.js +1 -1
- package/src/layers/line/layers/ScreenLineLayer.js +1 -1
- package/src/models/Animation.js +4 -1
- package/src/models/Frame.js +2 -1
- package/src/models/Line.js +4 -0
- package/src/models/Play.js +11 -7
- package/src/assets/cristmas_hat.svg +0 -8
- package/src/layers/court/layers/BorderRectLayer.js +0 -12
- package/src/layers/court/layers/CenterLineLayer.js +0 -16
package/package.json
CHANGED
|
Binary file
|
package/src/assets/wood_bg.png
CHANGED
|
Binary file
|
package/src/layers/CourtLayer.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
const courtLayers = require('./court');
|
|
2
|
-
const constants = require('
|
|
2
|
+
const constants = require('./court/constants');
|
|
3
3
|
|
|
4
4
|
class CourtLayer {
|
|
5
5
|
constructor(ctx, { court, options }) {
|
|
6
6
|
this.ctx = ctx;
|
|
7
7
|
this.options = {
|
|
8
|
-
|
|
9
|
-
...options
|
|
10
|
-
courtLineWidth: constants.COURT_LINE_WIDTH,
|
|
11
|
-
courtRectWidth: constants.COURT_RECT_WIDTH,
|
|
12
|
-
courtRectHeight: constants.COURT_RECT_HEIGHT
|
|
8
|
+
court: JSON.parse(JSON.stringify(court)),
|
|
9
|
+
...options
|
|
13
10
|
};
|
|
14
11
|
}
|
|
15
12
|
|
|
@@ -25,16 +22,32 @@ class CourtLayer {
|
|
|
25
22
|
return this.options.staticData;
|
|
26
23
|
}
|
|
27
24
|
|
|
25
|
+
get courtTypeLayers() {
|
|
26
|
+
if (!courtLayers[this.options.court.type]) throw new Error('unknown court type');
|
|
27
|
+
return courtLayers[this.options.court.type];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get courtTypeConstants() {
|
|
31
|
+
return constants[this.options.court.type];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get background() {
|
|
35
|
+
return this.options.background || this.options.court.type;
|
|
36
|
+
}
|
|
37
|
+
|
|
28
38
|
apply() {
|
|
29
39
|
this.init();
|
|
30
40
|
|
|
31
41
|
this.ctx.save();
|
|
32
42
|
|
|
33
|
-
this.ctx.lineWidth = this.
|
|
43
|
+
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH;
|
|
34
44
|
|
|
35
45
|
this.setColor();
|
|
36
46
|
|
|
37
|
-
|
|
47
|
+
console.log('courtTypeLayers', this.courtTypeLayers);
|
|
48
|
+
console.log('courtLayers', courtLayers);
|
|
49
|
+
|
|
50
|
+
Object.values(this.courtTypeLayers).forEach(LayerClass => {
|
|
38
51
|
new LayerClass(this).apply();
|
|
39
52
|
});
|
|
40
53
|
|
|
@@ -42,6 +55,7 @@ class CourtLayer {
|
|
|
42
55
|
}
|
|
43
56
|
|
|
44
57
|
init() {
|
|
58
|
+
console.log('this.options.court.courtRect.origin', this.options.court.courtRect.origin);
|
|
45
59
|
this.ctx.save();
|
|
46
60
|
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
47
61
|
this.setBackground();
|
|
@@ -55,21 +69,15 @@ class CourtLayer {
|
|
|
55
69
|
}
|
|
56
70
|
|
|
57
71
|
setBackground() {
|
|
58
|
-
if (this.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} else if (this.options.background.indexOf('#') === 0) {
|
|
68
|
-
this.ctx.save();
|
|
69
|
-
this.ctx.fillStyle = this.options.background;
|
|
70
|
-
this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
|
|
71
|
-
this.ctx.restore();
|
|
72
|
-
}
|
|
72
|
+
if (this.staticData.backgroundOptions && this.staticData.backgroundOptions[this.background]) {
|
|
73
|
+
const ptrn = this.ctx.createPattern(this.staticData.backgroundOptions[this.background], 'repeat');
|
|
74
|
+
this.ctx.fillStyle = ptrn;
|
|
75
|
+
this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
|
|
76
|
+
} else if (this.background.indexOf('#') === 0) {
|
|
77
|
+
this.ctx.save();
|
|
78
|
+
this.ctx.fillStyle = this.background;
|
|
79
|
+
this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
|
|
80
|
+
this.ctx.restore();
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
|
|
@@ -88,12 +96,12 @@ class CourtLayer {
|
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
const fullCourtIndentY =
|
|
91
|
-
this.options.courtRect.size.height >
|
|
92
|
-
? Math.abs(this.options.courtRect.origin.y)
|
|
99
|
+
this.options.court.courtRect.size.height > this.courtTypeConstants.COURT_RECT_HEIGHT
|
|
100
|
+
? Math.abs(this.options.court.courtRect.origin.y)
|
|
93
101
|
: 0;
|
|
94
102
|
|
|
95
|
-
const dx = (1 + Math.abs(this.options.courtRect.origin.x)) * this.scale;
|
|
96
|
-
const dy = (this.options.courtRect.size.height - fullCourtIndentY - 1) * this.scale - destination.height;
|
|
103
|
+
const dx = (1 + Math.abs(this.options.court.courtRect.origin.x)) * this.scale;
|
|
104
|
+
const dy = (this.options.court.courtRect.size.height - fullCourtIndentY - 1) * this.scale - destination.height;
|
|
97
105
|
|
|
98
106
|
this.ctx.drawImage(
|
|
99
107
|
this.staticData.watermark[this.options.watermark],
|
|
@@ -36,13 +36,28 @@ class PlayerLayer {
|
|
|
36
36
|
this.ctx.fillStyle = '#ffffff';
|
|
37
37
|
this.ctx.textAlign = 'center';
|
|
38
38
|
|
|
39
|
+
let px = x;
|
|
40
|
+
let py = y;
|
|
41
|
+
|
|
39
42
|
if (this.options.mirror === true) {
|
|
40
43
|
this.ctx.save();
|
|
41
44
|
this.ctx.translate(x * 2, 0);
|
|
42
45
|
this.ctx.scale(-1, 1);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
this.
|
|
48
|
+
if (this.options.flipPlayerLabels === true) {
|
|
49
|
+
px = 0;
|
|
50
|
+
py = 0;
|
|
51
|
+
this.ctx.save();
|
|
52
|
+
this.ctx.translate(x, y);
|
|
53
|
+
this.ctx.rotate(Math.PI); // 180
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.ctx.fillText(player.textLabel, px, py + textVerticalOffset);
|
|
57
|
+
|
|
58
|
+
if (this.options.flipPlayerLabels === true) {
|
|
59
|
+
this.ctx.restore();
|
|
60
|
+
}
|
|
46
61
|
|
|
47
62
|
if (this.options.mirror === true) {
|
|
48
63
|
this.ctx.restore();
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const BaseLayer = require('../../base/BaseLayer');
|
|
2
2
|
|
|
3
3
|
class InternalCourtLayer extends BaseLayer {
|
|
4
|
+
constructor(parentLayer) {
|
|
5
|
+
super(parentLayer);
|
|
6
|
+
this.courtTypeConstants = parentLayer.courtTypeConstants;
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
apply() {
|
|
5
10
|
super.apply();
|
|
6
11
|
|
|
@@ -17,7 +22,7 @@ class InternalCourtLayer extends BaseLayer {
|
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
verticalFlipAndRotation() {
|
|
20
|
-
const verticalTranslationDist = this.
|
|
25
|
+
const verticalTranslationDist = this.courtTypeConstants.COURT_RECT_HEIGHT;
|
|
21
26
|
this.ctx.scale(1, -1);
|
|
22
27
|
this.ctx.translate(0, -Math.abs(verticalTranslationDist));
|
|
23
28
|
}
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// require all modules on the path and with the pattern defined
|
|
2
|
+
const req = require.context('./', true, /.js$/);
|
|
3
|
+
|
|
4
|
+
const modules = {};
|
|
5
|
+
|
|
6
|
+
req.keys().forEach(key => {
|
|
7
|
+
const mName = key.replace('./', '').replace('.js', '');
|
|
8
|
+
modules[mName] = req(key);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
module.exports = modules;
|
|
@@ -4,8 +4,12 @@ const req = require.context('./layers/', true, /.js$/);
|
|
|
4
4
|
const modules = {};
|
|
5
5
|
|
|
6
6
|
req.keys().forEach(key => {
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const mPath = key.replace('./', '').replace('.js', '');
|
|
8
|
+
const [mType, mName] = mPath.split('/');
|
|
9
|
+
if (!modules[mType]) modules[mType] = {};
|
|
10
|
+
modules[mType][mName] = req(key);
|
|
9
11
|
});
|
|
10
12
|
|
|
13
|
+
console.log('modules', modules);
|
|
14
|
+
|
|
11
15
|
module.exports = modules;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { COURT_RECT_WIDTH, COURT_RECT_HEIGHT, COURT_LINE_WIDTH } = require('../../constants/FOOTBALL');
|
|
3
|
+
|
|
4
|
+
class BorderRectLayer extends InternalCourtLayer {
|
|
5
|
+
drawLogic() {
|
|
6
|
+
this.ctx.beginPath();
|
|
7
|
+
this.ctx.lineWidth = COURT_LINE_WIDTH * 2;
|
|
8
|
+
this.ctx.rect(0, 0, COURT_RECT_WIDTH, COURT_RECT_HEIGHT);
|
|
9
|
+
this.ctx.stroke();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = BorderRectLayer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { COURT_RECT_WIDTH, COURT_RECT_HEIGHT, COURT_LINE_WIDTH } = require('../../constants/FOOTBALL');
|
|
3
|
+
|
|
4
|
+
class CenterLineLayer extends InternalCourtLayer {
|
|
5
|
+
drawLogic() {
|
|
6
|
+
const courtOrigin = { x: 0.0, y: COURT_RECT_HEIGHT / 2 };
|
|
7
|
+
const courtTerminus = { x: COURT_RECT_WIDTH, y: COURT_RECT_HEIGHT / 2 };
|
|
8
|
+
|
|
9
|
+
this.ctx.beginPath();
|
|
10
|
+
this.ctx.lineWidth = COURT_LINE_WIDTH * 2;
|
|
11
|
+
this.ctx.moveTo(courtOrigin.x, courtOrigin.y);
|
|
12
|
+
this.ctx.lineTo(courtTerminus.x, courtTerminus.y);
|
|
13
|
+
this.ctx.stroke();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = CenterLineLayer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { COURT_RECT_WIDTH, COURT_LINE_WIDTH } = require('../../constants/FOOTBALL');
|
|
3
|
+
|
|
4
|
+
class EndZoneLayer extends InternalCourtLayer {
|
|
5
|
+
reflection() {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
drawLogic() {
|
|
10
|
+
const courtOrigin = { x: 0.0, y: 30 };
|
|
11
|
+
const courtTerminus = { x: COURT_RECT_WIDTH, y: 30 };
|
|
12
|
+
|
|
13
|
+
this.ctx.beginPath();
|
|
14
|
+
this.ctx.lineWidth = COURT_LINE_WIDTH * 2;
|
|
15
|
+
this.ctx.moveTo(courtOrigin.x, courtOrigin.y);
|
|
16
|
+
this.ctx.lineTo(courtTerminus.x, courtTerminus.y);
|
|
17
|
+
this.ctx.stroke();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = EndZoneLayer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { END_ZONE_HEIGHT, COURT_RECT_WIDTH } = require('../../constants/FOOTBALL');
|
|
3
|
+
|
|
4
|
+
const NUMBER_VERTICAL_OFFSET = -6;
|
|
5
|
+
|
|
6
|
+
class FieldNumberLayer extends InternalCourtLayer {
|
|
7
|
+
drawLogic() {
|
|
8
|
+
const x = 20;
|
|
9
|
+
const y = END_ZONE_HEIGHT;
|
|
10
|
+
|
|
11
|
+
const thinSpaceChar = String.fromCharCode(8202);
|
|
12
|
+
|
|
13
|
+
this.ctx.fillStyle = '#ffffff';
|
|
14
|
+
this.ctx.translate(x, y);
|
|
15
|
+
|
|
16
|
+
for (let i = 1; i < 10; i++) {
|
|
17
|
+
const number = i <= 5 ? i : 10 - i;
|
|
18
|
+
const yardMarkLabel = `${number}${thinSpaceChar}0`;
|
|
19
|
+
|
|
20
|
+
this.ctx.translate(0, END_ZONE_HEIGHT);
|
|
21
|
+
|
|
22
|
+
this.ctx.save();
|
|
23
|
+
|
|
24
|
+
this.ctx.rotate(Math.PI / 2); // 90
|
|
25
|
+
this.ctx.fillText(yardMarkLabel, NUMBER_VERTICAL_OFFSET, 0);
|
|
26
|
+
|
|
27
|
+
this.ctx.translate(0, 20 * 2 - COURT_RECT_WIDTH);
|
|
28
|
+
this.ctx.rotate(Math.PI); // 180
|
|
29
|
+
this.ctx.fillText(yardMarkLabel, NUMBER_VERTICAL_OFFSET, 0);
|
|
30
|
+
|
|
31
|
+
this.ctx.restore();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = FieldNumberLayer;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { COURT_RECT_HEIGHT, COURT_LINE_WIDTH, END_ZONE_HEIGHT, COURT_RECT_WIDTH } = require('../../constants/FOOTBALL');
|
|
3
|
+
|
|
4
|
+
const HASH_MARK_OFFSET_X = 3;
|
|
5
|
+
const HASH_MARK_LENGTH = 3;
|
|
6
|
+
const HASH_MARK_X_POSITIONS = [
|
|
7
|
+
HASH_MARK_OFFSET_X,
|
|
8
|
+
53,
|
|
9
|
+
COURT_RECT_WIDTH - 53 - HASH_MARK_LENGTH,
|
|
10
|
+
COURT_RECT_WIDTH - HASH_MARK_OFFSET_X - HASH_MARK_LENGTH
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
class HashMarkLayer extends InternalCourtLayer {
|
|
14
|
+
reflection() {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
drawLogic() {
|
|
19
|
+
this.ctx.save();
|
|
20
|
+
|
|
21
|
+
this.ctx.lineWidth = COURT_LINE_WIDTH;
|
|
22
|
+
|
|
23
|
+
for (let y = END_ZONE_HEIGHT + 15; y <= COURT_RECT_HEIGHT / 2; y += 15) {
|
|
24
|
+
HASH_MARK_X_POSITIONS.forEach(px => {
|
|
25
|
+
for (let i = 0; i < 4; i++) {
|
|
26
|
+
const hashMarkVerticalStep = 3 + i * 3;
|
|
27
|
+
const courtOrigin = { x: px, y: y - hashMarkVerticalStep };
|
|
28
|
+
const courtTerminus = { x: px + HASH_MARK_LENGTH, y: y - hashMarkVerticalStep };
|
|
29
|
+
|
|
30
|
+
this.ctx.beginPath();
|
|
31
|
+
this.ctx.moveTo(courtOrigin.x, courtOrigin.y);
|
|
32
|
+
this.ctx.lineTo(courtTerminus.x, courtTerminus.y);
|
|
33
|
+
this.ctx.stroke();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
this.ctx.restore();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = HashMarkLayer;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { COURT_RECT_WIDTH, COURT_RECT_HEIGHT, COURT_LINE_WIDTH, END_ZONE_HEIGHT } = require('../../constants/FOOTBALL');
|
|
3
|
+
|
|
4
|
+
class YardLineLayer extends InternalCourtLayer {
|
|
5
|
+
reflection() {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
drawLogic() {
|
|
10
|
+
for (let y = END_ZONE_HEIGHT; y <= COURT_RECT_HEIGHT / 2; y += 15) {
|
|
11
|
+
const courtOrigin = { x: 0.0, y };
|
|
12
|
+
const courtTerminus = { x: COURT_RECT_WIDTH, y };
|
|
13
|
+
|
|
14
|
+
this.ctx.beginPath();
|
|
15
|
+
this.ctx.lineWidth = y % 30 === 0 ? COURT_LINE_WIDTH * 2 : COURT_LINE_WIDTH;
|
|
16
|
+
this.ctx.moveTo(courtOrigin.x, courtOrigin.y);
|
|
17
|
+
this.ctx.lineTo(courtTerminus.x, courtTerminus.y);
|
|
18
|
+
this.ctx.stroke();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = YardLineLayer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const InternalCourtLayer = require('
|
|
2
|
-
const { COURT_LINE_WIDTH } = require('
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { COURT_LINE_WIDTH, COURT_RECT_WIDTH } = require('../../constants/NBA');
|
|
3
3
|
|
|
4
4
|
class Big3Layer extends InternalCourtLayer {
|
|
5
5
|
drawLogic() {
|
|
@@ -14,7 +14,7 @@ class Big3Layer extends InternalCourtLayer {
|
|
|
14
14
|
const theta = 40;
|
|
15
15
|
const radius = 2;
|
|
16
16
|
|
|
17
|
-
const centerPoint = { x:
|
|
17
|
+
const centerPoint = { x: COURT_RECT_WIDTH / 2, y: courtHoopCenter.y + distance };
|
|
18
18
|
const leftPoint = {
|
|
19
19
|
x: courtHoopCenter.x - distance * Math.cos((Math.PI * (90 - theta)) / 180.0),
|
|
20
20
|
y: courtHoopCenter.y + distance * Math.sin((Math.PI * (90 - theta)) / 180.0)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { COURT_RECT_WIDTH, COURT_RECT_HEIGHT, COURT_LINE_WIDTH } = require('../../constants/NBA');
|
|
3
|
+
|
|
4
|
+
class BorderRectLayer extends InternalCourtLayer {
|
|
5
|
+
drawLogic() {
|
|
6
|
+
this.ctx.beginPath();
|
|
7
|
+
this.ctx.lineWidth = COURT_LINE_WIDTH * 2;
|
|
8
|
+
this.ctx.rect(0, 0, COURT_RECT_WIDTH, COURT_RECT_HEIGHT);
|
|
9
|
+
this.ctx.stroke();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = BorderRectLayer;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
const InternalCourtLayer = require('
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { COURT_RECT_WIDTH, COURT_RECT_HEIGHT } = require('../../constants/NBA');
|
|
2
3
|
|
|
3
4
|
class CenterCircleLayer extends InternalCourtLayer {
|
|
4
5
|
drawLogic() {
|
|
5
6
|
const outerCenterRadius = 6.0;
|
|
6
7
|
const innerCenterRadius = 2.0;
|
|
7
|
-
const centerCourtPoint = { x:
|
|
8
|
+
const centerCourtPoint = { x: COURT_RECT_WIDTH / 2, y: COURT_RECT_HEIGHT / 2 };
|
|
8
9
|
|
|
9
10
|
this.ctx.beginPath();
|
|
10
11
|
this.ctx.arc(centerCourtPoint.x, centerCourtPoint.y, outerCenterRadius, 0, Math.PI * 2, true);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const InternalCourtLayer = require('../../base/InternalCourtLayer');
|
|
2
|
+
const { COURT_RECT_WIDTH, COURT_RECT_HEIGHT, COURT_LINE_WIDTH } = require('../../constants/NBA');
|
|
3
|
+
|
|
4
|
+
class CenterLineLayer extends InternalCourtLayer {
|
|
5
|
+
drawLogic() {
|
|
6
|
+
const courtOrigin = { x: 0.0, y: COURT_RECT_HEIGHT / 2 };
|
|
7
|
+
const courtTerminus = { x: COURT_RECT_WIDTH, y: COURT_RECT_HEIGHT / 2 };
|
|
8
|
+
|
|
9
|
+
this.ctx.beginPath();
|
|
10
|
+
this.ctx.lineWidth = COURT_LINE_WIDTH * 2;
|
|
11
|
+
this.ctx.moveTo(courtOrigin.x, courtOrigin.y);
|
|
12
|
+
this.ctx.lineTo(courtTerminus.x, courtTerminus.y);
|
|
13
|
+
this.ctx.stroke();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = CenterLineLayer;
|
|
@@ -2,7 +2,7 @@ const InternalLineLayer = require('../base/InternalLineLayer');
|
|
|
2
2
|
|
|
3
3
|
class CutLineLayer extends InternalLineLayer {
|
|
4
4
|
drawLineCap() {
|
|
5
|
-
if (this.
|
|
5
|
+
if (this.line.hideLineTip) return;
|
|
6
6
|
this.drawArrowLineCap();
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -2,7 +2,7 @@ const InternalLineLayer = require('../base/InternalLineLayer');
|
|
|
2
2
|
|
|
3
3
|
class ScreenLineLayer extends InternalLineLayer {
|
|
4
4
|
drawLineCap() {
|
|
5
|
-
if (this.
|
|
5
|
+
if (this.line.hideLineTip) return;
|
|
6
6
|
this.drawPerpendicularLineCap();
|
|
7
7
|
}
|
|
8
8
|
}
|
package/src/models/Animation.js
CHANGED
|
@@ -109,7 +109,10 @@ class Animation {
|
|
|
109
109
|
if (this.globalProgress >= this.linePhaseIntervalMaxRounded) {
|
|
110
110
|
this.reset();
|
|
111
111
|
cancelAnimationFrame(this.loopId);
|
|
112
|
-
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
finishCallback();
|
|
114
|
+
}, 1000);
|
|
115
|
+
return;
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
progressCallback(this.globalProgress);
|
package/src/models/Frame.js
CHANGED
|
@@ -214,7 +214,8 @@ class Frame {
|
|
|
214
214
|
this.ctx.canvas.height = this.frameHeight;
|
|
215
215
|
|
|
216
216
|
this.ctx.scale(this.play.scale, this.play.scale);
|
|
217
|
-
this.ctx.translate(Math.abs(this.court.courtRect.origin.x), Math.abs(this.court.courtRect.origin.y));
|
|
217
|
+
// this.ctx.translate(Math.abs(this.court.courtRect.origin.x), Math.abs(this.court.courtRect.origin.y));
|
|
218
|
+
this.ctx.translate(-this.court.courtRect.origin.x, -this.court.courtRect.origin.y);
|
|
218
219
|
if (this.play.options.mirror) {
|
|
219
220
|
this.ctx.scale(-1, 1);
|
|
220
221
|
this.ctx.translate(Math.abs(this.court.courtRect.origin.x) * 2 - this.court.courtRect.size.width, 0);
|
package/src/models/Line.js
CHANGED
package/src/models/Play.js
CHANGED
|
@@ -15,7 +15,6 @@ class Play {
|
|
|
15
15
|
linesDisplayOnMoveOnly = true,
|
|
16
16
|
linesHiddenIds = [],
|
|
17
17
|
linesSelectedIds = [],
|
|
18
|
-
linesHiddenTipIds = [],
|
|
19
18
|
playersHiddenPositions = [],
|
|
20
19
|
background = '',
|
|
21
20
|
watermark = null,
|
|
@@ -23,7 +22,8 @@ class Play {
|
|
|
23
22
|
speed = 1,
|
|
24
23
|
position = null,
|
|
25
24
|
big3 = false,
|
|
26
|
-
huddleMode = false
|
|
25
|
+
huddleMode = false,
|
|
26
|
+
flipPlayerLabels = false
|
|
27
27
|
} = {}
|
|
28
28
|
) {
|
|
29
29
|
this.name = data.name;
|
|
@@ -34,7 +34,6 @@ class Play {
|
|
|
34
34
|
linesDisplayOnMoveOnly,
|
|
35
35
|
linesHiddenIds,
|
|
36
36
|
linesSelectedIds,
|
|
37
|
-
linesHiddenTipIds,
|
|
38
37
|
playersHiddenPositions,
|
|
39
38
|
background,
|
|
40
39
|
watermark,
|
|
@@ -42,7 +41,8 @@ class Play {
|
|
|
42
41
|
speed,
|
|
43
42
|
position,
|
|
44
43
|
big3,
|
|
45
|
-
huddleMode
|
|
44
|
+
huddleMode,
|
|
45
|
+
flipPlayerLabels
|
|
46
46
|
};
|
|
47
47
|
this.setPlayData(data.playData);
|
|
48
48
|
}
|
|
@@ -52,8 +52,12 @@ class Play {
|
|
|
52
52
|
|
|
53
53
|
const hardwoodImageData = require('../assets/wood_bg.png');
|
|
54
54
|
const hardwoodImage = await loadImage(hardwoodImageData);
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const grassImageData = require('../assets/grass_bg.png');
|
|
56
|
+
const grassImage = await loadImage(grassImageData);
|
|
57
|
+
Play.backgroundOptions = {
|
|
58
|
+
NBA: hardwoodImage,
|
|
59
|
+
NCAA: hardwoodImage,
|
|
60
|
+
FOOTBALL: grassImage
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
const luceoSportsWatermark = await loadImage(`${STORAGE_URL}/${LUCEOSPORTS_WATERMARK_PATH}`);
|
|
@@ -83,7 +87,7 @@ class Play {
|
|
|
83
87
|
|
|
84
88
|
get staticData() {
|
|
85
89
|
return {
|
|
86
|
-
|
|
90
|
+
backgroundOptions: Play.backgroundOptions,
|
|
87
91
|
watermark: Play.watermark,
|
|
88
92
|
playerHats: Play.playerHats
|
|
89
93
|
};
|