@luceosports/play-rendering 1.13.1 → 1.14.0

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/index.js CHANGED
@@ -8,5 +8,10 @@ module.exports.Shape = require('./src/models/Shape');
8
8
  module.exports.ShapeModels = require('./src/models/ShapeModels');
9
9
  module.exports.LineDrawingMath = require('./src/math/LineDrawingMath');
10
10
  module.exports.Bezier = require('./src/math/Bezier').Bezier;
11
- module.exports.CourtTypeConstants = require('./src/layers/court').courtTypeConstants;
12
11
  module.exports.Constants = require('./src/constants');
12
+
13
+ const { courtTypeConstants, sportConstants, sportCourtTypeMap } = require('./src/layers/court');
14
+
15
+ module.exports.SportConstants = sportConstants;
16
+ module.exports.CourtTypeConstants = courtTypeConstants;
17
+ module.exports.SportCourtTypeMap = sportCourtTypeMap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luceosports/play-rendering",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "description": "",
5
5
  "main": "dist/play-rendering.js",
6
6
  "scripts": {
package/src/constants.js CHANGED
@@ -1,11 +1,22 @@
1
1
  module.exports = Object.freeze({
2
2
  SPORT_TYPE_BASKETBALL: 'BASKETBALL',
3
+ SPORT_TYPE_VOLLEYBALL: 'VOLLEYBALL',
3
4
  SPORT_TYPE_FOOTBALL: 'FOOTBALL',
4
5
 
6
+ COURT_TYPE_BIG3: 'BIG3',
7
+ COURT_TYPE_FIBA: 'FIBA',
5
8
  COURT_TYPE_NBA: 'NBA',
9
+ COURT_TYPE_NCAAM: 'NCAAM',
10
+ COURT_TYPE_NCAAW: 'NCAAW',
11
+ COURT_TYPE_US_HIGH_SCHOOL: 'US_HIGH_SCHOOL',
12
+ COURT_TYPE_US_JUNIOR_HIGH: 'US_JUNIOR_HIGH',
13
+ COURT_TYPE_WNBA: 'WNBA',
14
+
6
15
  COURT_TYPE_HIGH_SCHOOL_FOOTBALL: 'HIGH_SCHOOL_FOOTBALL',
7
16
  COURT_TYPE_HIGH_SCHOOL_FOOTBALL_LEGACY: 'FOOTBALL',
8
17
 
18
+ COURT_TYPE_INDOOR: 'INDOOR',
19
+
9
20
  SHAPE_TYPE_CIRCLE: 'CIRCLE',
10
21
  SHAPE_TYPE_SQUARE: 'SQUARE',
11
22
  SHAPE_TYPE_TRIANGLE: 'TRIANGLE',
@@ -5,12 +5,15 @@ const sportLayers = {};
5
5
  const courtTypeLayers = {};
6
6
  const sportConstants = {};
7
7
  const courtTypeConstants = {};
8
+ const sportCourtTypeMap = {};
8
9
 
9
10
  req.keys().forEach(key => {
10
11
  if (key.match(/layers\//)) {
11
12
  return processLayers(key);
12
13
  }
13
- processConstants(key);
14
+ if (key.match(/\/constants\.js/)) {
15
+ return processConstants(key);
16
+ }
14
17
  });
15
18
 
16
19
  function processLayers(key) {
@@ -36,20 +39,26 @@ function processLayers(key) {
36
39
  }
37
40
 
38
41
  function processConstants(key) {
39
- if (key.match(/\/courtTypes\//)) {
40
- const mPath = key
41
- .replace('./', '')
42
- .replace('/courtTypes', '')
43
- .replace('/constants.js', '');
44
- const [, courtType] = mPath.split('/');
45
- courtTypeConstants[courtType] = req(key);
42
+ if (!key.match(/\/courtTypes\//)) {
43
+ // Process sport
44
+ const sportType = key.replace('./', '').replace('/constants.js', '');
45
+ sportConstants[sportType] = req(key);
46
+
47
+ sportCourtTypeMap[sportType] = {
48
+ courtTypes: []
49
+ };
46
50
  return;
47
51
  }
48
- const mPath = key.replace('./', '').replace('/constants.js', '');
49
- const [sportName, courtType] = mPath.split('/');
50
- if (!courtType) {
51
- sportConstants[sportName] = req(key);
52
- }
52
+
53
+ // Process court type
54
+ const mPath = key
55
+ .replace('./', '')
56
+ .replace('/courtTypes', '')
57
+ .replace('/constants.js', '');
58
+ const [sportType, courtType] = mPath.split('/');
59
+ courtTypeConstants[courtType] = req(key);
60
+
61
+ sportCourtTypeMap[sportType].courtTypes.push(courtType);
53
62
  }
54
63
 
55
- module.exports = { sportLayers, courtTypeLayers, sportConstants, courtTypeConstants };
64
+ module.exports = { sportLayers, courtTypeLayers, sportConstants, courtTypeConstants, sportCourtTypeMap };
@@ -0,0 +1,7 @@
1
+ module.exports = Object.freeze({
2
+ COURT_LINE_WIDTH: 0.1667,
3
+ PLAYER_TOKEN_RADIUS: 1.5,
4
+ PLAYER_TOKEN_SCALE: 1,
5
+ LINE_WIDTH: 0.33,
6
+ LINE_MASKING: true
7
+ });
@@ -0,0 +1,4 @@
1
+ module.exports = Object.freeze({
2
+ COURT_RECT_WIDTH: 29.5,
3
+ COURT_RECT_HEIGHT: 59.1
4
+ });
@@ -0,0 +1,40 @@
1
+ const InternalCourtLayer = require('../../../base/InternalCourtLayer');
2
+
3
+ const ATTACK_LINE_CENTER_OFFSET_Y = 9.8;
4
+ const ATTACK_LINE_HASH_MARK_LENGTH = 0.574;
5
+ class AttackLineLayer extends InternalCourtLayer {
6
+ reflection() {
7
+ return true;
8
+ }
9
+
10
+ drawLogic() {
11
+ const courtOrigin = { x: 0.0, y: this.courtCenter.y - ATTACK_LINE_CENTER_OFFSET_Y };
12
+ const courtTerminus = {
13
+ x: this.courtTypeConstants.COURT_RECT_WIDTH,
14
+ y: this.courtCenter.y - ATTACK_LINE_CENTER_OFFSET_Y
15
+ };
16
+
17
+ this.ctx.beginPath();
18
+ this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH;
19
+ this.ctx.moveTo(courtOrigin.x, courtOrigin.y);
20
+ this.ctx.lineTo(courtTerminus.x, courtTerminus.y);
21
+ this.ctx.stroke();
22
+
23
+ let hashStart = ATTACK_LINE_HASH_MARK_LENGTH;
24
+ for (let i = 0; i < 5; i++) {
25
+ this.ctx.beginPath();
26
+ this.ctx.moveTo(courtOrigin.x - hashStart, courtOrigin.y);
27
+ this.ctx.lineTo(courtOrigin.x - hashStart - ATTACK_LINE_HASH_MARK_LENGTH, courtTerminus.y);
28
+ this.ctx.stroke();
29
+
30
+ this.ctx.beginPath();
31
+ this.ctx.moveTo(courtTerminus.x + hashStart, courtOrigin.y);
32
+ this.ctx.lineTo(courtTerminus.x + hashStart + ATTACK_LINE_HASH_MARK_LENGTH, courtTerminus.y);
33
+ this.ctx.stroke();
34
+
35
+ hashStart += ATTACK_LINE_HASH_MARK_LENGTH * 2;
36
+ }
37
+ }
38
+ }
39
+
40
+ module.exports = AttackLineLayer;
@@ -0,0 +1,12 @@
1
+ const InternalCourtLayer = require('../../../base/InternalCourtLayer');
2
+
3
+ class BorderRectLayer extends InternalCourtLayer {
4
+ drawLogic() {
5
+ this.ctx.beginPath();
6
+ this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
7
+ this.ctx.rect(0, 0, this.courtTypeConstants.COURT_RECT_WIDTH, this.courtTypeConstants.COURT_RECT_HEIGHT);
8
+ this.ctx.stroke();
9
+ }
10
+ }
11
+
12
+ module.exports = BorderRectLayer;
@@ -0,0 +1,18 @@
1
+ const InternalCourtLayer = require('../../../base/InternalCourtLayer');
2
+
3
+ class CenterLineLayer extends InternalCourtLayer {
4
+ drawLogic() {
5
+ const courtOrigin = { x: 0.0, y: this.courtCenter.y };
6
+ const courtTerminus = { x: this.courtTypeConstants.COURT_RECT_WIDTH, y: this.courtCenter.y };
7
+
8
+ this.ctx.beginPath();
9
+ this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
10
+ this.ctx.moveTo(courtOrigin.x, courtOrigin.y);
11
+ this.ctx.lineTo(courtTerminus.x, courtTerminus.y);
12
+ this.ctx.stroke();
13
+
14
+ this.ctx.beginPath();
15
+ }
16
+ }
17
+
18
+ module.exports = CenterLineLayer;
@@ -0,0 +1,25 @@
1
+ const InternalCourtLayer = require('../../../base/InternalCourtLayer');
2
+
3
+ const HASH_MARK_LENGTH = 0.574;
4
+ class HashMarkLayer extends InternalCourtLayer {
5
+ reflection() {
6
+ return true;
7
+ }
8
+
9
+ drawLogic() {
10
+ const courtOriginX = 0.0;
11
+ const courtTerminusX = this.courtTypeConstants.COURT_RECT_WIDTH;
12
+
13
+ this.ctx.beginPath();
14
+ this.ctx.moveTo(courtOriginX, -HASH_MARK_LENGTH);
15
+ this.ctx.lineTo(courtOriginX, -HASH_MARK_LENGTH * 2);
16
+ this.ctx.stroke();
17
+
18
+ this.ctx.beginPath();
19
+ this.ctx.moveTo(courtTerminusX, -HASH_MARK_LENGTH);
20
+ this.ctx.lineTo(courtTerminusX, -HASH_MARK_LENGTH * 2);
21
+ this.ctx.stroke();
22
+ }
23
+ }
24
+
25
+ module.exports = HashMarkLayer;
@@ -3,7 +3,7 @@ const { loadImage } = require('canvas');
3
3
  const playerHatsConfig = require('../playerHatsConfig');
4
4
  const shapesConfig = require('../shapesConfig');
5
5
  const { useDefaults } = require('./Play/Options');
6
- const { SPORT_TYPE_BASKETBALL, SPORT_TYPE_FOOTBALL } = require('../constants');
6
+ const { SPORT_TYPE_BASKETBALL, SPORT_TYPE_VOLLEYBALL, SPORT_TYPE_FOOTBALL } = require('../constants');
7
7
 
8
8
  const STORAGE_URL = 'https://playbooksstore.blob.core.windows.net/public';
9
9
  const LUCEOSPORTS_WATERMARK_PATH = 'partners/LuceoSports/luceo-sports-logo-powered-by-sm.png';
@@ -27,6 +27,7 @@ class Play {
27
27
  Play.backgroundOptions = {
28
28
  Hardwood: hardwoodImage,
29
29
  [SPORT_TYPE_BASKETBALL]: hardwoodImage,
30
+ [SPORT_TYPE_VOLLEYBALL]: hardwoodImage,
30
31
  [SPORT_TYPE_FOOTBALL]: grassImage
31
32
  };
32
33