@luceosports/play-rendering 1.11.14 → 1.11.17
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 +14 -14
- package/dist/play-rendering.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.js +4 -4
- package/src/layers/LineLayer.js +1 -1
- package/src/layers/PlayerLayer.js +26 -13
- package/src/layers/line/index.js +11 -11
- package/src/models/Play.js +8 -2
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -4,8 +4,8 @@ module.exports = Object.freeze({
|
|
|
4
4
|
COURT_RECT_WIDTH: 50.0,
|
|
5
5
|
COURT_RECT_HEIGHT: 94.0,
|
|
6
6
|
PLAYER_TOKEN_RADIUS: 1.5,
|
|
7
|
-
PLAYER_TOKEN_SCALE: 1
|
|
8
|
-
|
|
7
|
+
PLAYER_TOKEN_SCALE: 1,
|
|
8
|
+
LINE_WIDTH: 0.33,
|
|
9
9
|
LINE_MASKING: true
|
|
10
10
|
},
|
|
11
11
|
FOOTBALL: {
|
|
@@ -14,8 +14,8 @@ module.exports = Object.freeze({
|
|
|
14
14
|
COURT_RECT_HEIGHT: 360.0,
|
|
15
15
|
END_ZONE_HEIGHT: 30,
|
|
16
16
|
PLAYER_TOKEN_RADIUS: 1.5,
|
|
17
|
-
PLAYER_TOKEN_SCALE: 2
|
|
18
|
-
|
|
17
|
+
PLAYER_TOKEN_SCALE: 2,
|
|
18
|
+
LINE_WIDTH: 0.55,
|
|
19
19
|
LINE_MASKING: false
|
|
20
20
|
}
|
|
21
21
|
});
|
package/src/layers/LineLayer.js
CHANGED
|
@@ -6,11 +6,11 @@ class PlayerLayer extends BaseLayer {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
get playerScale() {
|
|
9
|
-
return this.courtTypeConstants.PLAYER_TOKEN_SCALE;
|
|
9
|
+
return this.courtTypeConstants.PLAYER_TOKEN_SCALE * this.options.playerTokenScale;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
get radius() {
|
|
13
|
-
return this.courtTypeConstants.PLAYER_TOKEN_RADIUS * this.
|
|
13
|
+
return this.courtTypeConstants.PLAYER_TOKEN_RADIUS * this.playerScale;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
apply() {
|
|
@@ -23,13 +23,9 @@ class PlayerLayer extends BaseLayer {
|
|
|
23
23
|
|
|
24
24
|
const { x, y } = player.location;
|
|
25
25
|
|
|
26
|
-
this.
|
|
26
|
+
this.setPlayerPuckStyle(player);
|
|
27
27
|
|
|
28
|
-
this.
|
|
29
|
-
this.ctx.moveTo(x, y);
|
|
30
|
-
|
|
31
|
-
this.ctx.arc(x, y, this.radius, 0, Math.PI * 2, true);
|
|
32
|
-
this.ctx.fill();
|
|
28
|
+
this.drawPlayerPuck(player);
|
|
33
29
|
|
|
34
30
|
this.setPlayerLabel(player);
|
|
35
31
|
|
|
@@ -64,10 +60,10 @@ class PlayerLayer extends BaseLayer {
|
|
|
64
60
|
this.ctx.restore();
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
|
|
63
|
+
setPlayerPuckStyle(player) {
|
|
68
64
|
const { red, green, blue, alpha } = player.color;
|
|
69
65
|
|
|
70
|
-
const
|
|
66
|
+
const isDefaultInputColor = red === 0 && green === 0 && blue === 0 && alpha === 1;
|
|
71
67
|
|
|
72
68
|
const payerInPosition = this.options.position && player.position === this.options.position;
|
|
73
69
|
const r = payerInPosition ? 0 : Math.ceil(red * 255);
|
|
@@ -76,12 +72,29 @@ class PlayerLayer extends BaseLayer {
|
|
|
76
72
|
|
|
77
73
|
let color = `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
78
74
|
|
|
79
|
-
if (player.isDefender && !payerInPosition &&
|
|
75
|
+
if (player.isDefender && !payerInPosition && isDefaultInputColor) {
|
|
80
76
|
color = '#bb271b';
|
|
81
77
|
}
|
|
82
|
-
if (player.possession &&
|
|
78
|
+
if (player.possession && isDefaultInputColor) color = '#ff8000';
|
|
79
|
+
|
|
80
|
+
if (this.options.legacyPrintStyle) {
|
|
81
|
+
color = '#000000';
|
|
82
|
+
this.ctx.lineWidth = this.courtTypeConstants.LINE_WIDTH;
|
|
83
|
+
}
|
|
83
84
|
|
|
84
85
|
this.ctx.fillStyle = color;
|
|
86
|
+
this.ctx.strokeStyle = color;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
drawPlayerPuck(player) {
|
|
90
|
+
const { x, y } = player.location;
|
|
91
|
+
this.ctx.beginPath();
|
|
92
|
+
this.ctx.arc(x, y, this.radius, 0, Math.PI * 2, true);
|
|
93
|
+
if (this.options.legacyPrintStyle) {
|
|
94
|
+
if (player.possession) this.ctx.stroke();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.ctx.fill();
|
|
85
98
|
}
|
|
86
99
|
|
|
87
100
|
setPlayerLabel(player) {
|
|
@@ -92,7 +105,7 @@ class PlayerLayer extends BaseLayer {
|
|
|
92
105
|
|
|
93
106
|
if (!alpha) return;
|
|
94
107
|
|
|
95
|
-
this.ctx.fillStyle = '#ffffff';
|
|
108
|
+
this.ctx.fillStyle = this.options.legacyPrintStyle ? '#000000' : '#ffffff';
|
|
96
109
|
this.ctx.textAlign = 'center';
|
|
97
110
|
this.ctx.font = `${fontSize}px Helvetica`;
|
|
98
111
|
|
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;
|
package/src/models/Play.js
CHANGED
|
@@ -27,7 +27,9 @@ class Play {
|
|
|
27
27
|
big3 = false,
|
|
28
28
|
huddleMode = false,
|
|
29
29
|
magnetMode = false,
|
|
30
|
-
flipPlayerLabels = false
|
|
30
|
+
flipPlayerLabels = false,
|
|
31
|
+
legacyPrintStyle = false,
|
|
32
|
+
playerTokenScale = 1
|
|
31
33
|
} = {}
|
|
32
34
|
) {
|
|
33
35
|
this.name = data.name;
|
|
@@ -49,7 +51,9 @@ class Play {
|
|
|
49
51
|
big3,
|
|
50
52
|
huddleMode,
|
|
51
53
|
magnetMode,
|
|
52
|
-
flipPlayerLabels
|
|
54
|
+
flipPlayerLabels,
|
|
55
|
+
legacyPrintStyle,
|
|
56
|
+
playerTokenScale
|
|
53
57
|
};
|
|
54
58
|
this.setPlayData(data.playData);
|
|
55
59
|
}
|
|
@@ -62,7 +66,9 @@ class Play {
|
|
|
62
66
|
const hardwoodImage = await loadImage(hardwoodImageData);
|
|
63
67
|
const grassImageData = require('../assets/grass_bg.png');
|
|
64
68
|
const grassImage = await loadImage(grassImageData);
|
|
69
|
+
|
|
65
70
|
Play.backgroundOptions = {
|
|
71
|
+
Hardwood: hardwoodImage,
|
|
66
72
|
NBA: hardwoodImage,
|
|
67
73
|
NCAA: hardwoodImage,
|
|
68
74
|
FOOTBALL: grassImage
|