@luceosports/play-rendering 2.1.3 → 2.1.5
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
package/src/layers/NoteLayer.ts
CHANGED
|
@@ -67,7 +67,10 @@ export default class NoteLayer extends BaseLayer {
|
|
|
67
67
|
lines.forEach(({ words }, index) => {
|
|
68
68
|
this.ctx.save();
|
|
69
69
|
|
|
70
|
-
this.ctx.translate(
|
|
70
|
+
this.ctx.translate(
|
|
71
|
+
NoteModel.NOTE_WRAP_PADDING,
|
|
72
|
+
note.fontSize + NoteModel.NOTE_WRAP_PADDING + note.lineHeight * index
|
|
73
|
+
);
|
|
71
74
|
|
|
72
75
|
let wordStartX = 0;
|
|
73
76
|
words.forEach((word, i) => {
|
|
@@ -80,7 +83,17 @@ export default class NoteLayer extends BaseLayer {
|
|
|
80
83
|
|
|
81
84
|
this.ctx.fillStyle = `rgba(0, 0, 0, ${this.animationAlpha})`;
|
|
82
85
|
const wordText = matches.length ? word.text.replace(/(<player=(\d*)>)/gi, '') : word.text;
|
|
83
|
-
this.ctx.fillText(wordText, wordStartX,
|
|
86
|
+
this.ctx.fillText(wordText, wordStartX, -note.baseLineOffset);
|
|
87
|
+
|
|
88
|
+
// BASELINE FOR TESTING
|
|
89
|
+
// this.ctx.save();
|
|
90
|
+
// this.ctx.strokeStyle = 'red';
|
|
91
|
+
// this.ctx.beginPath();
|
|
92
|
+
// this.ctx.moveTo(wordStartX, 0);
|
|
93
|
+
// this.ctx.lineTo(word.width, 0);
|
|
94
|
+
// this.ctx.stroke();
|
|
95
|
+
// this.ctx.restore();
|
|
96
|
+
|
|
84
97
|
wordStartX += word.width;
|
|
85
98
|
if (matches.length) {
|
|
86
99
|
wordStartX -= note.playerTokenRadius * 2;
|
|
@@ -92,7 +105,7 @@ export default class NoteLayer extends BaseLayer {
|
|
|
92
105
|
}
|
|
93
106
|
|
|
94
107
|
if (i !== words.length - 1) {
|
|
95
|
-
this.ctx.fillText(' ', wordStartX,
|
|
108
|
+
this.ctx.fillText(' ', wordStartX, -note.baseLineOffset);
|
|
96
109
|
wordStartX += this.ctx.measureText(' ').width;
|
|
97
110
|
}
|
|
98
111
|
});
|
|
@@ -102,12 +115,12 @@ export default class NoteLayer extends BaseLayer {
|
|
|
102
115
|
this.ctx.strokeStyle = `rgba(0, 0, 0, ${this.animationAlpha})`;
|
|
103
116
|
this.ctx.beginPath();
|
|
104
117
|
if (note.font.underline) {
|
|
105
|
-
this.ctx.moveTo(0, note.
|
|
106
|
-
this.ctx.lineTo(wordStartX, note.
|
|
118
|
+
this.ctx.moveTo(0, note.baseLineOffset);
|
|
119
|
+
this.ctx.lineTo(wordStartX, note.baseLineOffset);
|
|
107
120
|
}
|
|
108
121
|
if (note.font.strikethrough) {
|
|
109
|
-
this.ctx.moveTo(0, note.
|
|
110
|
-
this.ctx.lineTo(wordStartX, note.
|
|
122
|
+
this.ctx.moveTo(0, -note.fontSize / 2 + note.baseLineOffset);
|
|
123
|
+
this.ctx.lineTo(wordStartX, -note.fontSize / 2 + note.baseLineOffset);
|
|
111
124
|
}
|
|
112
125
|
this.ctx.stroke();
|
|
113
126
|
}
|
|
@@ -124,14 +137,14 @@ export default class NoteLayer extends BaseLayer {
|
|
|
124
137
|
this.ctx.beginPath();
|
|
125
138
|
this.ctx.strokeStyle = `rgba(255, 255, 255, ${this.animationAlpha})`;
|
|
126
139
|
this.ctx.fillStyle = `rgba(243, 111, 33, ${this.animationAlpha})`;
|
|
127
|
-
this.ctx.arc(0, note.
|
|
140
|
+
this.ctx.arc(0, -note.fontSize / 2, note.playerTokenRadius, 0, Math.PI * 2);
|
|
128
141
|
this.ctx.fill();
|
|
129
142
|
this.ctx.stroke();
|
|
130
143
|
|
|
131
144
|
const playerFontSize = note.fontSize * 0.8;
|
|
132
145
|
this.ctx.font = `${playerFontSize}px Arial`;
|
|
133
146
|
const textX = -this.ctx.measureText(label).width / 2;
|
|
134
|
-
const textY =
|
|
147
|
+
const textY = -playerFontSize / 4;
|
|
135
148
|
this.ctx.fillStyle = `rgba(255, 255, 255, ${this.animationAlpha})`;
|
|
136
149
|
this.ctx.fillText(label, textX, textY);
|
|
137
150
|
|
|
@@ -3,11 +3,12 @@ import InternalShapeLayer from '../base/InternalShapeLayer';
|
|
|
3
3
|
export default class ConeShapeLayer extends InternalShapeLayer {
|
|
4
4
|
drawShapeLogic() {
|
|
5
5
|
const { color, outerCircleRadius } = this.shape;
|
|
6
|
-
if (color.alpha === 0
|
|
6
|
+
if (color.alpha === 0) return;
|
|
7
7
|
|
|
8
8
|
if (this.staticData.shapes && this.staticData.shapes.length) {
|
|
9
9
|
const coneShape = this.staticData.shapes.find(shape => shape.key === 'cone');
|
|
10
10
|
if (coneShape) {
|
|
11
|
+
this.ctx.globalAlpha = this.animationAlpha;
|
|
11
12
|
this.ctx.drawImage(
|
|
12
13
|
coneShape.image,
|
|
13
14
|
-outerCircleRadius / 2,
|
package/src/models/NoteModel.ts
CHANGED
|
@@ -2,6 +2,8 @@ import Model from './Base/InternalFrameModel';
|
|
|
2
2
|
import { CourtPoint, Note as NoteData } from '../types';
|
|
3
3
|
|
|
4
4
|
const NOTE_GREY_COLOR = { red: 0.502, green: 0.502, blue: 0.502, alpha: 0.35 };
|
|
5
|
+
const NOTE_LINE_HEIGHT_OFFSET = 0.3;
|
|
6
|
+
const NOTE_BASE_LINE_ALPHABETIC_OFFSET = 0.1;
|
|
5
7
|
|
|
6
8
|
export default class NoteModel extends Model<NoteData, NoteData> {
|
|
7
9
|
private internalCanvas: HTMLCanvasElement;
|
|
@@ -19,10 +21,6 @@ export default class NoteModel extends Model<NoteData, NoteData> {
|
|
|
19
21
|
return 0.43;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
static get NOTE_LINE_HEIGHT_OFFSET() {
|
|
23
|
-
return 0.3;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
24
|
get id() {
|
|
27
25
|
return this._getAttr('id');
|
|
28
26
|
}
|
|
@@ -68,7 +66,15 @@ export default class NoteModel extends Model<NoteData, NoteData> {
|
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
get lineHeight() {
|
|
71
|
-
return this.fontSize +
|
|
69
|
+
return this.fontSize + this.lineHeightOffset;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get lineHeightOffset() {
|
|
73
|
+
return this.fontSize * NOTE_LINE_HEIGHT_OFFSET;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get baseLineOffset() {
|
|
77
|
+
return this.fontSize * NOTE_BASE_LINE_ALPHABETIC_OFFSET;
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
get playerTokenRadius() {
|
|
@@ -85,7 +91,7 @@ export default class NoteModel extends Model<NoteData, NoteData> {
|
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
get textBaseline(): CanvasTextBaseline {
|
|
88
|
-
return '
|
|
94
|
+
return 'alphabetic';
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
get internalCtx(): CanvasRenderingContext2D {
|
|
@@ -100,7 +106,7 @@ export default class NoteModel extends Model<NoteData, NoteData> {
|
|
|
100
106
|
lines,
|
|
101
107
|
box: {
|
|
102
108
|
width: maxLineWidth + NoteModel.NOTE_WRAP_PADDING * 2,
|
|
103
|
-
height: lines.length * this.lineHeight + NoteModel.NOTE_WRAP_PADDING * 2
|
|
109
|
+
height: lines.length * this.lineHeight + NoteModel.NOTE_WRAP_PADDING * 2
|
|
104
110
|
}
|
|
105
111
|
};
|
|
106
112
|
}
|