@luceosports/play-rendering 1.11.7 → 1.11.10

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.7",
3
+ "version": "1.11.10",
4
4
  "description": "",
5
5
  "main": "dist/play-rendering.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@ class NoteLayer extends BaseLayer {
19
19
  const { lines, box } = note.preProcessedTextForContext();
20
20
 
21
21
  this.setFont(note);
22
- this.drawBubble(box);
22
+ this.drawBubble(note, box);
23
23
  this.drawText(note, lines);
24
24
 
25
25
  this.ctx.restore();
@@ -60,8 +60,15 @@ class NoteLayer extends BaseLayer {
60
60
  }
61
61
 
62
62
  setColor(note) {
63
- this.ctx.fillStyle = `rgba(0, 133, 133, ${this.noteAlpha / 2})`;
64
- this.ctx.strokeStyle = `rgba(0, 133, 133, ${this.noteAlpha})`;
63
+ const { alpha, blue, green, red } = note.color;
64
+
65
+ const r = Math.ceil(red * 255);
66
+ const g = Math.ceil(green * 255);
67
+ const b = Math.ceil(blue * 255);
68
+
69
+ this.ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${alpha * this.noteAlpha})`;
70
+ this.ctx.strokeStyle = `rgba(${r}, ${g}, ${b}, ${this.noteAlpha})`;
71
+
65
72
  if (this.options.noteSelectedId === note.id) {
66
73
  this.ctx.setLineDash([0.5, 0.5]);
67
74
  this.ctx.strokeStyle = `rgba(28, 127, 181, ${this.noteAlpha})`;
@@ -73,12 +80,14 @@ class NoteLayer extends BaseLayer {
73
80
  this.ctx.textBaseline = note.textBaseline;
74
81
  }
75
82
 
76
- drawBubble({ width, height }) {
83
+ drawBubble(note, { width, height }) {
77
84
  this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH;
78
85
  this.ctx.beginPath();
79
86
  this.ctx.rect(0, 0, width, height);
80
87
  this.ctx.fill();
81
- this.ctx.stroke();
88
+ if (note.showBorder || this.options.noteSelectedId === note.id) {
89
+ this.ctx.stroke();
90
+ }
82
91
  }
83
92
 
84
93
  drawText(note, lines) {
@@ -116,16 +125,16 @@ class NoteLayer extends BaseLayer {
116
125
  });
117
126
 
118
127
  if (note.font.underline || note.font.strikethrough) {
119
- this.ctx.lineWidth = 0.07;
128
+ this.ctx.lineWidth = 0.07 * note.fontSize;
120
129
  this.ctx.strokeStyle = `rgba(0, 0, 0, ${this.noteAlpha})`;
121
130
  this.ctx.beginPath();
122
131
  if (note.font.underline) {
123
- this.ctx.moveTo(0, note.lineHeight - Note.NOTE_LINE_HEIGHT_OFFSET);
124
- this.ctx.lineTo(wordStartX, note.lineHeight - Note.NOTE_LINE_HEIGHT_OFFSET);
132
+ this.ctx.moveTo(0, note.fontSize - Note.NOTE_LINE_HEIGHT_OFFSET / 2);
133
+ this.ctx.lineTo(wordStartX, note.fontSize - Note.NOTE_LINE_HEIGHT_OFFSET / 2);
125
134
  }
126
135
  if (note.font.strikethrough) {
127
- this.ctx.moveTo(0, note.lineHeight / 2 - Note.NOTE_LINE_HEIGHT_OFFSET);
128
- this.ctx.lineTo(wordStartX, note.lineHeight / 2 - Note.NOTE_LINE_HEIGHT_OFFSET);
136
+ this.ctx.moveTo(0, note.lineHeight / 2 - Note.NOTE_LINE_HEIGHT_OFFSET / 3);
137
+ this.ctx.lineTo(wordStartX, note.lineHeight / 2 - Note.NOTE_LINE_HEIGHT_OFFSET / 3);
129
138
  }
130
139
  this.ctx.stroke();
131
140
  }
@@ -142,12 +151,16 @@ class NoteLayer extends BaseLayer {
142
151
  this.ctx.beginPath();
143
152
  this.ctx.strokeStyle = `rgba(255, 255, 255, ${this.noteAlpha})`;
144
153
  this.ctx.fillStyle = `rgba(243, 111, 33, ${this.noteAlpha})`;
145
- this.ctx.arc(0, note.fontSize / 2, note.playerTokenRadius, 0, Math.PI * 2);
154
+ this.ctx.arc(0, note.playerTokenRadius, note.playerTokenRadius, 0, Math.PI * 2);
146
155
  this.ctx.fill();
147
156
  this.ctx.stroke();
148
157
 
158
+ const playerFontSize = note.fontSize * 0.8;
159
+ this.ctx.font = `${playerFontSize}px Arial`;
160
+ const textX = -this.ctx.measureText(label).width / 2;
161
+ const textY = ((note.playerTokenRadius * 2 - playerFontSize) / 2) * (1 + Note.NOTE_LINE_HEIGHT_OFFSET);
149
162
  this.ctx.fillStyle = `rgba(255, 255, 255, ${this.noteAlpha})`;
150
- this.ctx.fillText(label, -this.ctx.measureText(label).width / 2, 0);
163
+ this.ctx.fillText(label, textX, textY);
151
164
 
152
165
  this.ctx.restore();
153
166
  }
@@ -7,7 +7,7 @@ class Note extends Model {
7
7
  }
8
8
 
9
9
  static get NOTE_WRAP_MAX_WIDTH() {
10
- return 22;
10
+ return 40;
11
11
  }
12
12
 
13
13
  static get NOTE_WRAP_PADDING() {
@@ -30,6 +30,14 @@ class Note extends Model {
30
30
  return this._getAttr('location');
31
31
  }
32
32
 
33
+ get color() {
34
+ return this._getAttr('color');
35
+ }
36
+
37
+ get showBorder() {
38
+ return this._getAttr('showBorder');
39
+ }
40
+
33
41
  get animations() {
34
42
  return this._getAttr('animations');
35
43
  }
@@ -47,7 +55,7 @@ class Note extends Model {
47
55
  }
48
56
 
49
57
  get playerTokenRadius() {
50
- return 0.7 * this.fontSize;
58
+ return this.fontSize / 2;
51
59
  }
52
60
 
53
61
  get fontComputed() {