@luceosports/play-rendering 1.9.34 → 1.9.37
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 +1 -1
- package/dist/play-rendering.js.map +1 -1
- package/package.json +1 -1
- package/src/layers/PlayerLayer.js +51 -39
- package/src/layers/court/layers/FOOTBALL/FieldNumberLayer.js +1 -1
- package/src/layers/court/layers/NBA/Big3Layer.js +5 -3
- package/src/layers/line/base/InternalLineLayer.js +8 -8
- package/src/layers/line/index.js +11 -11
package/package.json
CHANGED
|
@@ -5,61 +5,33 @@ class PlayerLayer extends BaseLayer {
|
|
|
5
5
|
return this.options.staticData;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
get playerScale() {
|
|
9
|
+
return this.courtTypeConstants.PLAYER_TOKEN_SCALE;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get radius() {
|
|
13
|
+
return 1.5 * this.playerScale;
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
apply() {
|
|
9
17
|
if (!this.playData.players.length) return;
|
|
10
18
|
|
|
11
|
-
const playerScale = this.courtTypeConstants.PLAYER_TOKEN_SCALE;
|
|
12
|
-
const radius = 1.5 * playerScale;
|
|
13
|
-
|
|
14
19
|
this.ctx.save();
|
|
15
20
|
|
|
16
21
|
this.playData.players.forEach(player => {
|
|
17
22
|
if (this.options.playersHiddenPositions.findIndex(p => parseInt(p) === parseInt(player.position)) >= 0) return;
|
|
18
23
|
|
|
19
|
-
const fontSize = (player.textLabel.length > 1 ? 2.0 : 2.5) * playerScale;
|
|
20
|
-
const textVerticalOffset = (player.textLabel.length > 1 ? 0.7 : 0.85) * playerScale;
|
|
21
|
-
|
|
22
24
|
const { x, y } = player.location;
|
|
23
25
|
|
|
24
|
-
this.ctx.font = `${fontSize}px Helvetica`;
|
|
25
|
-
|
|
26
26
|
this.setPlayerColor(player);
|
|
27
27
|
|
|
28
28
|
this.ctx.beginPath();
|
|
29
29
|
this.ctx.moveTo(x, y);
|
|
30
30
|
|
|
31
|
-
this.ctx.arc(x, y, radius, 0, Math.PI * 2, true);
|
|
31
|
+
this.ctx.arc(x, y, this.radius, 0, Math.PI * 2, true);
|
|
32
32
|
this.ctx.fill();
|
|
33
33
|
|
|
34
|
-
this.
|
|
35
|
-
this.ctx.textAlign = 'center';
|
|
36
|
-
|
|
37
|
-
let px = x;
|
|
38
|
-
let py = y;
|
|
39
|
-
|
|
40
|
-
if (this.options.mirror === true) {
|
|
41
|
-
this.ctx.save();
|
|
42
|
-
this.ctx.translate(x * 2, 0);
|
|
43
|
-
this.ctx.scale(-1, 1);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (this.options.flipPlayerLabels === true) {
|
|
47
|
-
px = 0;
|
|
48
|
-
py = 0;
|
|
49
|
-
this.ctx.save();
|
|
50
|
-
this.ctx.translate(x, y);
|
|
51
|
-
this.ctx.rotate(Math.PI); // 180
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.ctx.fillText(player.textLabel, px, py + textVerticalOffset);
|
|
55
|
-
|
|
56
|
-
if (this.options.flipPlayerLabels === true) {
|
|
57
|
-
this.ctx.restore();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (this.options.mirror === true) {
|
|
61
|
-
this.ctx.restore();
|
|
62
|
-
}
|
|
34
|
+
this.setPlayerLabel(player);
|
|
63
35
|
|
|
64
36
|
if (this.staticData.playerHats && this.staticData.playerHats.length) {
|
|
65
37
|
const playerHat = this.staticData.playerHats.find(hat => {
|
|
@@ -78,7 +50,7 @@ class PlayerLayer extends BaseLayer {
|
|
|
78
50
|
this.ctx.drawImage(
|
|
79
51
|
playerHat.image,
|
|
80
52
|
x - (hatWidth / 2 - hatWidth * hatDX),
|
|
81
|
-
y - (hatHeight / 2 + radius * 2 + hatHeight * hatDY),
|
|
53
|
+
y - (hatHeight / 2 + this.radius * 2 + hatHeight * hatDY),
|
|
82
54
|
hatWidth,
|
|
83
55
|
hatHeight
|
|
84
56
|
);
|
|
@@ -111,6 +83,46 @@ class PlayerLayer extends BaseLayer {
|
|
|
111
83
|
|
|
112
84
|
this.ctx.fillStyle = color;
|
|
113
85
|
}
|
|
86
|
+
|
|
87
|
+
setPlayerLabel(player) {
|
|
88
|
+
const { x, y } = player.location;
|
|
89
|
+
const { alpha } = player.color;
|
|
90
|
+
const fontSize = (player.textLabel.length > 1 ? 2.0 : 2.5) * this.playerScale;
|
|
91
|
+
const textVerticalOffset = (player.textLabel.length > 1 ? 0.7 : 0.85) * this.playerScale;
|
|
92
|
+
|
|
93
|
+
if (!alpha) return;
|
|
94
|
+
|
|
95
|
+
this.ctx.fillStyle = '#ffffff';
|
|
96
|
+
this.ctx.textAlign = 'center';
|
|
97
|
+
this.ctx.font = `${fontSize}px Helvetica`;
|
|
98
|
+
|
|
99
|
+
if (this.options.mirror === true) {
|
|
100
|
+
this.ctx.save();
|
|
101
|
+
this.ctx.translate(x * 2, 0);
|
|
102
|
+
this.ctx.scale(-1, 1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let px = x;
|
|
106
|
+
let py = y;
|
|
107
|
+
|
|
108
|
+
if (this.options.flipPlayerLabels === true) {
|
|
109
|
+
px = 0;
|
|
110
|
+
py = 0;
|
|
111
|
+
this.ctx.save();
|
|
112
|
+
this.ctx.translate(x, y);
|
|
113
|
+
this.ctx.rotate(Math.PI); // 180
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.ctx.fillText(player.textLabel, px, py + textVerticalOffset);
|
|
117
|
+
|
|
118
|
+
if (this.options.flipPlayerLabels === true) {
|
|
119
|
+
this.ctx.restore();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (this.options.mirror === true) {
|
|
123
|
+
this.ctx.restore();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
114
126
|
}
|
|
115
127
|
|
|
116
128
|
module.exports = PlayerLayer;
|
|
@@ -36,10 +36,12 @@ class Big3Layer extends InternalCourtLayer {
|
|
|
36
36
|
this.ctx.arc(point.x, point.y, radius, 0, Math.PI * 2, true);
|
|
37
37
|
this.ctx.stroke();
|
|
38
38
|
|
|
39
|
-
this.
|
|
40
|
-
|
|
39
|
+
if (this.options.lineColor !== 'transparent') {
|
|
40
|
+
this.ctx.fillStyle = '#001c4f';
|
|
41
|
+
this.ctx.fill();
|
|
42
|
+
}
|
|
41
43
|
|
|
42
|
-
this.ctx.fillStyle =
|
|
44
|
+
this.ctx.fillStyle = this.options.lineColor;
|
|
43
45
|
this.ctx.fillText('4', point.x - textHorizontalOffset, point.y + textVerticalOffset);
|
|
44
46
|
});
|
|
45
47
|
}
|
|
@@ -205,17 +205,17 @@ class InternalLineLayer extends InternalBaseLayer {
|
|
|
205
205
|
if (this.line.playerPositionOrigin) {
|
|
206
206
|
const positionOrigin = this.line.playerPositionOrigin;
|
|
207
207
|
const lineSequence = this.line.playerLineSequence;
|
|
208
|
-
const player = this.playData.players.find(p => p.position === positionOrigin);
|
|
209
|
-
if (!player) return;
|
|
210
|
-
// console.log('player: ', player);
|
|
211
208
|
|
|
212
209
|
if (lineSequence === 0) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
radius = 0
|
|
210
|
+
const player = this.playData.players.find(p => p.position === positionOrigin);
|
|
211
|
+
if (player) {
|
|
212
|
+
// For simple lines without sequence we use player.location for startMaskSettings
|
|
213
|
+
let radius = player.possession ? 1.5 : 1.0;
|
|
214
|
+
if (this.line.type === 'HANDOFF' && !player.possession) {
|
|
215
|
+
radius = 0.7;
|
|
216
|
+
}
|
|
217
|
+
this.startMaskSettings = { centerPoint: player.location, radius: radius };
|
|
217
218
|
}
|
|
218
|
-
this.startMaskSettings = { centerPoint: player.location, radius: radius };
|
|
219
219
|
} else if (positionOrigin) {
|
|
220
220
|
// Find prev line in line sequence for player
|
|
221
221
|
// and get last cp of last line part
|
package/src/layers/line/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// require all modules on the path and with the pattern defined
|
|
2
|
-
const req = require.context('./layers/', 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;
|
|
1
|
+
// require all modules on the path and with the pattern defined
|
|
2
|
+
const req = require.context('./layers/', 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;
|