@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.
Files changed (42) hide show
  1. package/dist/play-rendering.js +3 -3
  2. package/dist/play-rendering.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/assets/grass_bg.png +0 -0
  5. package/src/assets/wood_bg.png +0 -0
  6. package/src/layers/CourtLayer.js +35 -27
  7. package/src/layers/PlayerLayer.js +16 -1
  8. package/src/layers/base/BaseLayer.js +0 -1
  9. package/src/layers/court/base/InternalCourtLayer.js +6 -1
  10. package/src/layers/court/constants/FOOTBALL.js +7 -0
  11. package/src/{constants.js → layers/court/constants/NBA.js} +0 -0
  12. package/src/layers/court/constants/index.js +11 -0
  13. package/src/layers/court/index.js +6 -2
  14. package/src/layers/court/layers/FOOTBALL/BorderRectLayer.js +13 -0
  15. package/src/layers/court/layers/FOOTBALL/CenterLineLayer.js +17 -0
  16. package/src/layers/court/layers/FOOTBALL/EndZoneLayer.js +21 -0
  17. package/src/layers/court/layers/FOOTBALL/FieldNumberLayer.js +36 -0
  18. package/src/layers/court/layers/FOOTBALL/HashMarkLayer.js +42 -0
  19. package/src/layers/court/layers/FOOTBALL/YardLineLayer.js +23 -0
  20. package/src/layers/court/layers/{BaseLineMarkingLayer.js → NBA/BaseLineMarkingLayer.js} +1 -1
  21. package/src/layers/court/layers/{BenchAreaLayer.js → NBA/BenchAreaLayer.js} +1 -1
  22. package/src/layers/court/layers/{Big3Layer.js → NBA/Big3Layer.js} +3 -3
  23. package/src/layers/court/layers/NBA/BorderRectLayer.js +13 -0
  24. package/src/layers/court/layers/{CenterCircleLayer.js → NBA/CenterCircleLayer.js} +3 -2
  25. package/src/layers/court/layers/NBA/CenterLineLayer.js +17 -0
  26. package/src/layers/court/layers/{FreeThrowLayer.js → NBA/FreeThrowLayer.js} +1 -1
  27. package/src/layers/court/layers/{HoopLayer.js → NBA/HoopLayer.js} +1 -1
  28. package/src/layers/court/layers/{InnerOuterRectLayer.js → NBA/InnerOuterRectLayer.js} +1 -1
  29. package/src/layers/court/layers/{LaneMarkingLayer.js → NBA/LaneMarkingLayer.js} +1 -1
  30. package/src/layers/court/layers/{RestrictedAreaLayer.js → NBA/RestrictedAreaLayer.js} +1 -1
  31. package/src/layers/court/layers/{ThreePointLineLayer.js → NBA/ThreePointLineLayer.js} +1 -1
  32. package/src/layers/line/base/InternalLineLayer.js +1 -0
  33. package/src/layers/line/layers/CutLineLayer.js +1 -1
  34. package/src/layers/line/layers/DribbleLineLayer.js +1 -1
  35. package/src/layers/line/layers/ScreenLineLayer.js +1 -1
  36. package/src/models/Animation.js +4 -1
  37. package/src/models/Frame.js +2 -1
  38. package/src/models/Line.js +4 -0
  39. package/src/models/Play.js +11 -7
  40. package/src/assets/cristmas_hat.svg +0 -8
  41. package/src/layers/court/layers/BorderRectLayer.js +0 -12
  42. package/src/layers/court/layers/CenterLineLayer.js +0 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luceosports/play-rendering",
3
- "version": "1.9.25",
3
+ "version": "1.9.29",
4
4
  "description": "",
5
5
  "main": "dist/play-rendering.js",
6
6
  "scripts": {
Binary file
Binary file
@@ -1,15 +1,12 @@
1
1
  const courtLayers = require('./court');
2
- const constants = require('../constants');
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
- ...court,
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.options.courtLineWidth;
43
+ this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH;
34
44
 
35
45
  this.setColor();
36
46
 
37
- Object.values(courtLayers).forEach(LayerClass => {
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.options.background) {
59
- if (this.staticData.background && this.staticData.background[this.options.background]) {
60
- this.ctx.drawImage(
61
- this.staticData.background[this.options.background],
62
- 0,
63
- 0,
64
- this.ctx.canvas.width,
65
- this.ctx.canvas.height
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 > constants.COURT_RECT_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.ctx.fillText(player.textLabel, x, y + textVerticalOffset);
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,7 +1,6 @@
1
1
  class BaseLayer {
2
2
  constructor(parentLayer) {
3
3
  this.ctx = parentLayer.ctx;
4
- this.playData = parentLayer.playData;
5
4
  this.options = parentLayer.options ? parentLayer.options : {};
6
5
  }
7
6
 
@@ -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.options.courtRectHeight;
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
  }
@@ -0,0 +1,7 @@
1
+ module.exports = Object.freeze({
2
+ COURT_LINE_WIDTH: 0.32,
3
+ COURT_RECT_WIDTH: 160.0,
4
+ COURT_RECT_HEIGHT: 360.0,
5
+ END_ZONE_HEIGHT: 30,
6
+ TEN_YARDS_HEIGHT: 30
7
+ });
@@ -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 mname = key.replace('./', '').replace('.js', '');
8
- modules[mname] = req(key);
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,4 +1,4 @@
1
- const InternalCourtLayer = require('../base/InternalCourtLayer');
1
+ const InternalCourtLayer = require('../../base/InternalCourtLayer');
2
2
 
3
3
  class BaseLineMarkingLayer extends InternalCourtLayer {
4
4
  reflection() {
@@ -1,4 +1,4 @@
1
- const InternalCourtLayer = require('../base/InternalCourtLayer');
1
+ const InternalCourtLayer = require('../../base/InternalCourtLayer');
2
2
 
3
3
  class BenchAreaLayer extends InternalCourtLayer {
4
4
  reflection() {
@@ -1,5 +1,5 @@
1
- const InternalCourtLayer = require('../base/InternalCourtLayer');
2
- const { COURT_LINE_WIDTH } = require('../../../constants');
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: this.options.courtRectWidth / 2, y: courtHoopCenter.y + distance };
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('../base/InternalCourtLayer');
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: this.options.courtRectWidth / 2, y: this.options.courtRectHeight / 2 };
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;
@@ -1,4 +1,4 @@
1
- const InternalCourtLayer = require('../base/InternalCourtLayer');
1
+ const InternalCourtLayer = require('../../base/InternalCourtLayer');
2
2
 
3
3
  class FreeThrowLayer extends InternalCourtLayer {
4
4
  reflection() {
@@ -1,4 +1,4 @@
1
- const InternalCourtLayer = require('../base/InternalCourtLayer');
1
+ const InternalCourtLayer = require('../../base/InternalCourtLayer');
2
2
 
3
3
  class HoopLayer extends InternalCourtLayer {
4
4
  reflection() {
@@ -1,4 +1,4 @@
1
- const InternalCourtLayer = require('../base/InternalCourtLayer');
1
+ const InternalCourtLayer = require('../../base/InternalCourtLayer');
2
2
 
3
3
  class InnerOuterRectLayer extends InternalCourtLayer {
4
4
  reflection() {
@@ -1,4 +1,4 @@
1
- const InternalCourtLayer = require('../base/InternalCourtLayer');
1
+ const InternalCourtLayer = require('../../base/InternalCourtLayer');
2
2
 
3
3
  class LaneMarkingLayer extends InternalCourtLayer {
4
4
  reflection() {
@@ -1,4 +1,4 @@
1
- const InternalCourtLayer = require('../base/InternalCourtLayer');
1
+ const InternalCourtLayer = require('../../base/InternalCourtLayer');
2
2
 
3
3
  class RestrictedAreaLayer extends InternalCourtLayer {
4
4
  reflection() {
@@ -1,4 +1,4 @@
1
- const InternalCourtLayer = require('../base/InternalCourtLayer');
1
+ const InternalCourtLayer = require('../../base/InternalCourtLayer');
2
2
 
3
3
  class ThreePointLineLayer extends InternalCourtLayer {
4
4
  reflection() {
@@ -5,6 +5,7 @@ class InternalLineLayer extends BaseLayer {
5
5
  constructor(parentLineLayer, line) {
6
6
  super(parentLineLayer);
7
7
  this.line = line;
8
+ this.playData = parentLineLayer.playData;
8
9
  this.debugMasking = false;
9
10
  this.startMaskSettings = null;
10
11
  this.endMaskSettings = null;
@@ -2,7 +2,7 @@ const InternalLineLayer = require('../base/InternalLineLayer');
2
2
 
3
3
  class CutLineLayer extends InternalLineLayer {
4
4
  drawLineCap() {
5
- if (this.options.linesHiddenTipIds.includes(this.line.id)) return;
5
+ if (this.line.hideLineTip) return;
6
6
  this.drawArrowLineCap();
7
7
  }
8
8
  }
@@ -5,7 +5,7 @@ const Bezier = require('../../../math/Bezier');
5
5
 
6
6
  class DribbleLineLayer extends InternalLineLayer {
7
7
  drawLineCap() {
8
- if (this.options.linesHiddenTipIds.includes(this.line.id)) return;
8
+ if (this.line.hideLineTip) return;
9
9
  this.drawArrowLineCap();
10
10
  }
11
11
 
@@ -2,7 +2,7 @@ const InternalLineLayer = require('../base/InternalLineLayer');
2
2
 
3
3
  class ScreenLineLayer extends InternalLineLayer {
4
4
  drawLineCap() {
5
- if (this.options.linesHiddenTipIds.includes(this.line.id)) return;
5
+ if (this.line.hideLineTip) return;
6
6
  this.drawPerpendicularLineCap();
7
7
  }
8
8
  }
@@ -109,7 +109,10 @@ class Animation {
109
109
  if (this.globalProgress >= this.linePhaseIntervalMaxRounded) {
110
110
  this.reset();
111
111
  cancelAnimationFrame(this.loopId);
112
- return finishCallback();
112
+ setTimeout(() => {
113
+ finishCallback();
114
+ }, 1000);
115
+ return;
113
116
  }
114
117
 
115
118
  progressCallback(this.globalProgress);
@@ -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);
@@ -99,6 +99,10 @@ class Line extends Model {
99
99
  return this._getAttr('playerLineSequence');
100
100
  }
101
101
 
102
+ get hideLineTip() {
103
+ return this._getAttr('hideLineTip');
104
+ }
105
+
102
106
  get animations() {
103
107
  return this._getAttr('animations');
104
108
  }
@@ -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
- Play.background = {
56
- Hardwood: hardwoodImage
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
- background: Play.background,
90
+ backgroundOptions: Play.backgroundOptions,
87
91
  watermark: Play.watermark,
88
92
  playerHats: Play.playerHats
89
93
  };