@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luceosports/play-rendering",
3
- "version": "1.11.14",
3
+ "version": "1.11.17",
4
4
  "description": "",
5
5
  "main": "dist/play-rendering.js",
6
6
  "scripts": {
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.2,
8
- LINE_SCALE: 1,
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.4,
18
- LINE_SCALE: 1.65,
17
+ PLAYER_TOKEN_SCALE: 2,
18
+ LINE_WIDTH: 0.55,
19
19
  LINE_MASKING: false
20
20
  }
21
21
  });
@@ -4,7 +4,7 @@ const lineLayers = require('./line');
4
4
 
5
5
  class LineLayer extends BaseLayer {
6
6
  get lineWidth() {
7
- return 0.33 * this.courtTypeConstants.LINE_SCALE;
7
+ return this.courtTypeConstants.LINE_WIDTH;
8
8
  }
9
9
 
10
10
  apply() {
@@ -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.courtTypeConstants.PLAYER_TOKEN_SCALE;
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.setPlayerColor(player);
26
+ this.setPlayerPuckStyle(player);
27
27
 
28
- this.ctx.beginPath();
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
- setPlayerColor(player) {
63
+ setPlayerPuckStyle(player) {
68
64
  const { red, green, blue, alpha } = player.color;
69
65
 
70
- const defaultInputColor = red === 0 && green === 0 && blue === 0 && alpha === 1;
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 && defaultInputColor) {
75
+ if (player.isDefender && !payerInPosition && isDefaultInputColor) {
80
76
  color = '#bb271b';
81
77
  }
82
- if (player.possession && defaultInputColor) color = '#ff8000';
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
 
@@ -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;
@@ -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