vexflow 5.0.0-alpha.4 → 5.0.0-beta.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/README.md +6 -6
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +1546 -1393
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +600 -549
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/src/annotation.js +0 -2
- package/build/esm/src/barnote.js +3 -3
- package/build/esm/src/beam.js +2 -4
- package/build/esm/src/bend.js +11 -3
- package/build/esm/src/chordsymbol.js +0 -4
- package/build/esm/src/clef.js +0 -2
- package/build/esm/src/curve.js +8 -5
- package/build/esm/src/element.js +11 -17
- package/build/esm/src/factory.js +4 -4
- package/build/esm/src/flag.js +20 -0
- package/build/esm/src/formatter.js +4 -4
- package/build/esm/src/glyphnote.js +0 -2
- package/build/esm/src/gracenote.js +0 -2
- package/build/esm/src/gracenotegroup.js +17 -8
- package/build/esm/src/index.js +1 -0
- package/build/esm/src/keysignature.js +38 -31
- package/build/esm/src/keysignote.js +1 -1
- package/build/esm/src/metrics.js +55 -7
- package/build/esm/src/modifier.js +4 -2
- package/build/esm/src/notehead.js +6 -1
- package/build/esm/src/ornament.js +0 -2
- package/build/esm/src/pedalmarking.js +33 -41
- package/build/esm/src/stave.js +10 -16
- package/build/esm/src/stavebarline.js +2 -3
- package/build/esm/src/stavehairpin.js +1 -1
- package/build/esm/src/staveline.js +0 -4
- package/build/esm/src/stavemodifier.js +0 -2
- package/build/esm/src/stavenote.js +16 -28
- package/build/esm/src/staverepetition.js +3 -2
- package/build/esm/src/stavesection.js +13 -15
- package/build/esm/src/stavetempo.js +3 -2
- package/build/esm/src/stavetext.js +2 -2
- package/build/esm/src/stavetie.js +0 -4
- package/build/esm/src/stavevolta.js +3 -2
- package/build/esm/src/stem.js +0 -4
- package/build/esm/src/stemmablenote.js +5 -6
- package/build/esm/src/stringnumber.js +0 -2
- package/build/esm/src/svgcontext.js +0 -1
- package/build/esm/src/tabnote.js +2 -8
- package/build/esm/src/textbracket.js +0 -3
- package/build/esm/src/textnote.js +0 -2
- package/build/esm/src/timesignature.js +2 -4
- package/build/esm/src/timesignote.js +2 -0
- package/build/esm/src/tuplet.js +37 -30
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vexflow.js +6 -2
- package/build/esm/tests/accidental_tests.js +30 -17
- package/build/esm/tests/annotation_tests.js +12 -12
- package/build/esm/tests/articulation_tests.js +13 -13
- package/build/esm/tests/auto_beam_formatting_tests.js +33 -33
- package/build/esm/tests/beam_tests.js +1 -1
- package/build/esm/tests/bend_tests.js +7 -7
- package/build/esm/tests/chordsymbol_tests.js +8 -8
- package/build/esm/tests/curve_tests.js +34 -0
- package/build/esm/tests/{bach_tests.js → demo_petzold_tests.js} +7 -7
- package/build/esm/tests/dot_tests.js +4 -4
- package/build/esm/tests/formatter_tests.js +25 -25
- package/build/esm/tests/gracenote_tests.js +2 -1
- package/build/esm/tests/gracetabnote_tests.js +1 -1
- package/build/esm/tests/index.js +1 -1
- package/build/esm/tests/key_clef_tests.js +6 -6
- package/build/esm/tests/keysignature_tests.js +20 -17
- package/build/esm/tests/notehead_tests.js +10 -7
- package/build/esm/tests/offscreencanvas_tests.js +1 -1
- package/build/esm/tests/ornament_tests.js +8 -8
- package/build/esm/tests/pedalmarking_tests.js +27 -0
- package/build/esm/tests/percussion_tests.js +6 -3
- package/build/esm/tests/renderer_tests.js +1 -1
- package/build/esm/tests/rests_tests.js +26 -26
- package/build/esm/tests/rhythm_tests.js +15 -15
- package/build/esm/tests/stave_tests.js +44 -43
- package/build/esm/tests/staveconnector_tests.js +73 -73
- package/build/esm/tests/stavehairpin_tests.js +1 -1
- package/build/esm/tests/stavemodifier_tests.js +3 -3
- package/build/esm/tests/stavenote_tests.js +29 -29
- package/build/esm/tests/stringnumber_tests.js +1 -1
- package/build/esm/tests/strokes_tests.js +1 -1
- package/build/esm/tests/style_tests.js +1 -1
- package/build/esm/tests/tabnote_tests.js +7 -7
- package/build/esm/tests/tabslide_tests.js +6 -6
- package/build/esm/tests/tabstave_tests.js +1 -1
- package/build/esm/tests/tabtie_tests.js +8 -8
- package/build/esm/tests/textnote_tests.js +1 -1
- package/build/esm/tests/threevoice_tests.js +2 -2
- package/build/esm/tests/timesignature_tests.js +23 -13
- package/build/esm/tests/vibrato_tests.js +3 -3
- package/build/esm/tests/voice_tests.js +1 -1
- package/build/types/src/bend.d.ts +6 -0
- package/build/types/src/curve.d.ts +5 -4
- package/build/types/src/element.d.ts +10 -11
- package/build/types/src/factory.d.ts +2 -2
- package/build/types/src/flag.d.ts +12 -0
- package/build/types/src/frethandfinger.d.ts +1 -1
- package/build/types/src/index.d.ts +1 -0
- package/build/types/src/keysignature.d.ts +7 -7
- package/build/types/src/metrics.d.ts +5 -0
- package/build/types/src/modifier.d.ts +1 -1
- package/build/types/src/pedalmarking.d.ts +2 -2
- package/build/types/src/stave.d.ts +1 -3
- package/build/types/src/stavebarline.d.ts +1 -1
- package/build/types/src/staveline.d.ts +1 -1
- package/build/types/src/stavemodifier.d.ts +0 -1
- package/build/types/src/staverepetition.d.ts +1 -1
- package/build/types/src/stavesection.d.ts +3 -4
- package/build/types/src/stavetempo.d.ts +1 -2
- package/build/types/src/stavetext.d.ts +1 -2
- package/build/types/src/stavevolta.d.ts +1 -2
- package/build/types/src/stemmablenote.d.ts +2 -3
- package/build/types/src/tuplet.d.ts +2 -12
- package/build/types/src/typeguard.d.ts +1 -0
- package/package.json +32 -28
|
@@ -1,38 +1,36 @@
|
|
|
1
|
+
import { Metrics } from './metrics.js';
|
|
1
2
|
import { StaveModifier } from './stavemodifier.js';
|
|
2
3
|
export class StaveSection extends StaveModifier {
|
|
3
4
|
static get CATEGORY() {
|
|
4
5
|
return "StaveSection";
|
|
5
6
|
}
|
|
6
|
-
constructor(section, x, yShift, drawRect = true) {
|
|
7
|
+
constructor(section, x = 0, yShift = 0, drawRect = true) {
|
|
7
8
|
super();
|
|
8
|
-
this.
|
|
9
|
+
this.setText(section);
|
|
9
10
|
this.x = x;
|
|
10
11
|
this.yShift = yShift;
|
|
11
12
|
this.drawRect = drawRect;
|
|
13
|
+
this.padding = Metrics.get('StaveSection.padding');
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
+
setDrawRect(drawRect) {
|
|
16
|
+
this.drawRect = drawRect;
|
|
15
17
|
return this;
|
|
16
18
|
}
|
|
17
|
-
draw(
|
|
18
|
-
const
|
|
19
|
-
const padding = 2;
|
|
19
|
+
draw() {
|
|
20
|
+
const stave = this.checkStave();
|
|
20
21
|
const ctx = stave.checkContext();
|
|
21
22
|
this.setRendered();
|
|
22
|
-
|
|
23
|
-
ctx.setLineWidth(borderWidth);
|
|
23
|
+
this.x = stave.getX() + stave.getModifierXShift(this.getPosition());
|
|
24
24
|
const headroom = -1 * this.textMetrics.actualBoundingBoxDescent;
|
|
25
|
-
const width = this.width + 2 * padding;
|
|
26
|
-
const height = this.height + 2 * padding;
|
|
25
|
+
const width = this.width + 2 * this.padding;
|
|
26
|
+
const height = this.height + 2 * this.padding;
|
|
27
27
|
const y = stave.getYForTopText(1.5) + this.yShift;
|
|
28
|
-
const x = this.x + xShift;
|
|
28
|
+
const x = this.x + this.xShift;
|
|
29
29
|
if (this.drawRect) {
|
|
30
30
|
ctx.beginPath();
|
|
31
31
|
ctx.rect(x, y - height + headroom, width, height);
|
|
32
32
|
ctx.stroke();
|
|
33
33
|
}
|
|
34
|
-
this.renderText(ctx, xShift + padding, y - padding);
|
|
35
|
-
ctx.restore();
|
|
36
|
-
return this;
|
|
34
|
+
this.renderText(ctx, this.xShift + this.padding, y - this.padding);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
@@ -49,7 +49,9 @@ export class StaveTempo extends StaveModifier {
|
|
|
49
49
|
this.tempo = tempo;
|
|
50
50
|
return this;
|
|
51
51
|
}
|
|
52
|
-
draw(
|
|
52
|
+
draw() {
|
|
53
|
+
const stave = this.checkStave();
|
|
54
|
+
const shiftX = stave.getModifierXShift(this.getPosition());
|
|
53
55
|
const ctx = stave.checkContext();
|
|
54
56
|
this.setRendered();
|
|
55
57
|
const { name, duration, dots, bpm, duration2, dots2, parenthesis } = this.tempo;
|
|
@@ -104,6 +106,5 @@ export class StaveTempo extends StaveModifier {
|
|
|
104
106
|
elText.renderText(ctx, x + this.xShift, y + this.yShift);
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
|
-
return this;
|
|
108
109
|
}
|
|
109
110
|
}
|
|
@@ -14,7 +14,8 @@ export class StaveText extends StaveModifier {
|
|
|
14
14
|
this.position = position;
|
|
15
15
|
this.justification = (_c = options.justification) !== null && _c !== void 0 ? _c : TextNote.Justification.CENTER;
|
|
16
16
|
}
|
|
17
|
-
draw(
|
|
17
|
+
draw() {
|
|
18
|
+
const stave = this.checkStave();
|
|
18
19
|
const ctx = stave.checkContext();
|
|
19
20
|
this.setRendered();
|
|
20
21
|
let x;
|
|
@@ -50,6 +51,5 @@ export class StaveText extends StaveModifier {
|
|
|
50
51
|
throw new RuntimeError('InvalidPosition', 'Value Must be in Modifier.Position.');
|
|
51
52
|
}
|
|
52
53
|
this.renderText(ctx, x, y + 4);
|
|
53
|
-
return this;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -74,7 +74,6 @@ export class StaveTie extends Element {
|
|
|
74
74
|
const yShift = this.renderOptions.yShift * params.direction;
|
|
75
75
|
const firstIndexes = this.notes.firstIndexes;
|
|
76
76
|
const lastIndexes = this.notes.lastIndexes;
|
|
77
|
-
this.applyStyle();
|
|
78
77
|
ctx.openGroup('stavetie', this.getAttribute('id'));
|
|
79
78
|
for (let i = 0; i < firstIndexes.length; ++i) {
|
|
80
79
|
const cpX = (params.lastX + lastXShift + (params.firstX + firstXShift)) / 2;
|
|
@@ -93,7 +92,6 @@ export class StaveTie extends Element {
|
|
|
93
92
|
ctx.fill();
|
|
94
93
|
}
|
|
95
94
|
ctx.closeGroup();
|
|
96
|
-
this.restoreStyle();
|
|
97
95
|
}
|
|
98
96
|
renderTieText(firstX, lastX) {
|
|
99
97
|
var _a, _b, _c;
|
|
@@ -102,10 +100,8 @@ export class StaveTie extends Element {
|
|
|
102
100
|
centerX -= ctx.measureText(this.text).width / 2;
|
|
103
101
|
const stave = (_b = (_a = this.notes.firstNote) === null || _a === void 0 ? void 0 : _a.checkStave()) !== null && _b !== void 0 ? _b : (_c = this.notes.lastNote) === null || _c === void 0 ? void 0 : _c.checkStave();
|
|
104
102
|
if (stave) {
|
|
105
|
-
ctx.save();
|
|
106
103
|
ctx.setFont(this.fontInfo);
|
|
107
104
|
ctx.fillText(this.text, centerX + this.renderOptions.textShiftX, stave.getYForTopText() - 1);
|
|
108
|
-
ctx.restore();
|
|
109
105
|
}
|
|
110
106
|
}
|
|
111
107
|
getNotes() {
|
|
@@ -21,7 +21,9 @@ export class Volta extends StaveModifier {
|
|
|
21
21
|
this.yShift = yShift;
|
|
22
22
|
this.text = label;
|
|
23
23
|
}
|
|
24
|
-
draw(
|
|
24
|
+
draw() {
|
|
25
|
+
const stave = this.checkStave();
|
|
26
|
+
const x = stave.getModifierXShift(this.getPosition());
|
|
25
27
|
const ctx = stave.checkContext();
|
|
26
28
|
this.setRendered();
|
|
27
29
|
let width = stave.getWidth() - x;
|
|
@@ -47,6 +49,5 @@ export class Volta extends StaveModifier {
|
|
|
47
49
|
this.renderText(ctx, x + 5, topY - this.yShift + 15);
|
|
48
50
|
}
|
|
49
51
|
ctx.fillRect(this.x + x, topY, width, 1);
|
|
50
|
-
return this;
|
|
51
52
|
}
|
|
52
53
|
}
|
package/build/esm/src/stem.js
CHANGED
|
@@ -120,8 +120,6 @@ export class Stem extends Element {
|
|
|
120
120
|
const stemHeight = this.getHeight();
|
|
121
121
|
L('Rendering stem - ', 'Top Y: ', this.yTop, 'Bottom Y: ', this.yBottom);
|
|
122
122
|
const stemletYOffset = this.isStemlet ? stemHeight - this.stemletHeight * this.stemDirection : 0;
|
|
123
|
-
ctx.save();
|
|
124
|
-
this.applyStyle();
|
|
125
123
|
ctx.openGroup('stem', this.getAttribute('id'));
|
|
126
124
|
ctx.beginPath();
|
|
127
125
|
ctx.setLineWidth(Stem.WIDTH);
|
|
@@ -129,8 +127,6 @@ export class Stem extends Element {
|
|
|
129
127
|
ctx.lineTo(stemX, stemY - stemHeight - this.renderHeightAdjustment * stemDirection);
|
|
130
128
|
ctx.stroke();
|
|
131
129
|
ctx.closeGroup();
|
|
132
|
-
this.restoreStyle();
|
|
133
|
-
ctx.restore();
|
|
134
130
|
}
|
|
135
131
|
}
|
|
136
132
|
Stem.DEBUG = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flag } from './flag.js';
|
|
2
2
|
import { Glyphs } from './glyphs.js';
|
|
3
3
|
import { Note } from './note.js';
|
|
4
4
|
import { Stem } from './stem.js';
|
|
@@ -10,8 +10,7 @@ export class StemmableNote extends Note {
|
|
|
10
10
|
}
|
|
11
11
|
constructor(noteStruct) {
|
|
12
12
|
super(noteStruct);
|
|
13
|
-
this.flag = new
|
|
14
|
-
this.flagStyle = {};
|
|
13
|
+
this.flag = new Flag();
|
|
15
14
|
}
|
|
16
15
|
getStem() {
|
|
17
16
|
return this.stem;
|
|
@@ -24,7 +23,7 @@ export class StemmableNote extends Note {
|
|
|
24
23
|
}
|
|
25
24
|
setStem(stem) {
|
|
26
25
|
this.stem = stem;
|
|
27
|
-
this.
|
|
26
|
+
this.addChild(stem);
|
|
28
27
|
return this;
|
|
29
28
|
}
|
|
30
29
|
buildStem() {
|
|
@@ -38,7 +37,7 @@ export class StemmableNote extends Note {
|
|
|
38
37
|
if (this.hasFlag()) {
|
|
39
38
|
const flagCode = this.getStemDirection() === Stem.DOWN
|
|
40
39
|
? String.fromCodePoint(((_b = (_a = glyphProps.codeFlagUp) === null || _a === void 0 ? void 0 : _a.codePointAt(0)) !== null && _b !== void 0 ? _b : -1) + 1)
|
|
41
|
-
: (_c = glyphProps.codeFlagUp) !== null && _c !== void 0 ? _c : Glyphs.null;
|
|
40
|
+
: ((_c = glyphProps.codeFlagUp) !== null && _c !== void 0 ? _c : Glyphs.null);
|
|
42
41
|
this.flag.setText(flagCode);
|
|
43
42
|
this.flag.fontInfo = this.fontInfo;
|
|
44
43
|
}
|
|
@@ -180,6 +179,6 @@ export class StemmableNote extends Note {
|
|
|
180
179
|
this.checkContext();
|
|
181
180
|
this.setRendered();
|
|
182
181
|
this.setStem(new Stem(stemOptions));
|
|
183
|
-
(_a = this.stem) === null || _a === void 0 ? void 0 : _a.setContext(this.getContext()).
|
|
182
|
+
(_a = this.stem) === null || _a === void 0 ? void 0 : _a.setContext(this.getContext()).drawWithStyle();
|
|
184
183
|
}
|
|
185
184
|
}
|
|
@@ -186,7 +186,6 @@ export class StringNumber extends Modifier {
|
|
|
186
186
|
default:
|
|
187
187
|
throw new RuntimeError('InvalidPosition', `The position ${this.position} is invalid`);
|
|
188
188
|
}
|
|
189
|
-
ctx.save();
|
|
190
189
|
if (this.drawCircle) {
|
|
191
190
|
ctx.beginPath();
|
|
192
191
|
ctx.arc(dotX, dotY, this.radius, 0, Math.PI * 2, false);
|
|
@@ -225,6 +224,5 @@ export class StringNumber extends Modifier {
|
|
|
225
224
|
break;
|
|
226
225
|
}
|
|
227
226
|
}
|
|
228
|
-
ctx.restore();
|
|
229
227
|
}
|
|
230
228
|
}
|
|
@@ -177,7 +177,6 @@ export class SVGContext extends RenderContext {
|
|
|
177
177
|
while (this.svg.lastChild) {
|
|
178
178
|
this.svg.removeChild(this.svg.lastChild);
|
|
179
179
|
}
|
|
180
|
-
this.scale(this.state.scaleX, this.state.scaleY);
|
|
181
180
|
}
|
|
182
181
|
rect(x, y, width, height, attributes) {
|
|
183
182
|
if (height < 0) {
|
package/build/esm/src/tabnote.js
CHANGED
|
@@ -207,9 +207,7 @@ export class TabNote extends StemmableNote {
|
|
|
207
207
|
this.getStemY() - this.checkStem().getHeight() - this.getStemExtension()
|
|
208
208
|
:
|
|
209
209
|
this.getStemY() - this.checkStem().getHeight() + this.getStemExtension();
|
|
210
|
-
this.
|
|
211
|
-
this.flag.renderText(context, flagX, flagY);
|
|
212
|
-
this.restoreStyle(context, this.flagStyle);
|
|
210
|
+
this.flag.setContext(context).setX(flagX).setY(flagY).drawWithStyle();
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
drawModifiers() {
|
|
@@ -232,7 +230,6 @@ export class TabNote extends StemmableNote {
|
|
|
232
230
|
const stringsUsed = this.positions.map((position) => Number(position.str));
|
|
233
231
|
const unusedStrings = getUnusedStringGroups(numLines, stringsUsed);
|
|
234
232
|
const stemLines = getPartialStemLines(stemY, unusedStrings, this.checkStave(), this.getStemDirection());
|
|
235
|
-
ctx.save();
|
|
236
233
|
ctx.setLineWidth(Stem.WIDTH);
|
|
237
234
|
stemLines.forEach((bounds) => {
|
|
238
235
|
if (bounds.length === 0)
|
|
@@ -243,7 +240,6 @@ export class TabNote extends StemmableNote {
|
|
|
243
240
|
ctx.stroke();
|
|
244
241
|
ctx.closePath();
|
|
245
242
|
});
|
|
246
|
-
ctx.restore();
|
|
247
243
|
}
|
|
248
244
|
}
|
|
249
245
|
drawPositions() {
|
|
@@ -265,18 +261,16 @@ export class TabNote extends StemmableNote {
|
|
|
265
261
|
}
|
|
266
262
|
this.setRendered();
|
|
267
263
|
const renderStem = this.beam === undefined && this.renderOptions.drawStem;
|
|
268
|
-
this.applyStyle();
|
|
269
264
|
ctx.openGroup('tabnote', this.getAttribute('id'));
|
|
270
265
|
this.drawPositions();
|
|
271
266
|
this.drawStemThrough();
|
|
272
267
|
if (this.stem && renderStem) {
|
|
273
268
|
const stemX = this.getStemX();
|
|
274
269
|
this.stem.setNoteHeadXBounds(stemX, stemX);
|
|
275
|
-
this.stem.setContext(ctx).
|
|
270
|
+
this.stem.setContext(ctx).drawWithStyle();
|
|
276
271
|
}
|
|
277
272
|
this.drawFlag();
|
|
278
273
|
this.drawModifiers();
|
|
279
274
|
ctx.closeGroup();
|
|
280
|
-
this.restoreStyle();
|
|
281
275
|
}
|
|
282
276
|
}
|
|
@@ -86,8 +86,6 @@ export class TextBracket extends Element {
|
|
|
86
86
|
const stop = { x: this.stop.getAbsoluteX(), y };
|
|
87
87
|
L('Rendering TextBracket: start:', start, 'stop:', stop, 'y:', y);
|
|
88
88
|
const bracketHeight = this.renderOptions.bracketHeight * this.position;
|
|
89
|
-
ctx.save();
|
|
90
|
-
this.applyStyle(ctx);
|
|
91
89
|
this.textElement.renderText(ctx, start.x, start.y);
|
|
92
90
|
const mainWidth = this.textElement.getWidth();
|
|
93
91
|
const mainHeight = this.textElement.getHeight();
|
|
@@ -125,7 +123,6 @@ export class TextBracket extends Element {
|
|
|
125
123
|
ctx.stroke();
|
|
126
124
|
ctx.closePath();
|
|
127
125
|
}
|
|
128
|
-
ctx.restore();
|
|
129
126
|
}
|
|
130
127
|
}
|
|
131
128
|
TextBracket.DEBUG = false;
|
|
@@ -103,7 +103,6 @@ export class TextNote extends Note {
|
|
|
103
103
|
x -= width;
|
|
104
104
|
}
|
|
105
105
|
const y = stave.getYForLine(this.line + -3);
|
|
106
|
-
this.applyStyle(ctx);
|
|
107
106
|
this.renderText(ctx, x, y);
|
|
108
107
|
const height = this.getHeight();
|
|
109
108
|
if (this.superscript) {
|
|
@@ -112,7 +111,6 @@ export class TextNote extends Note {
|
|
|
112
111
|
if (this.subscript) {
|
|
113
112
|
this.subscript.renderText(ctx, x + this.width + 2, y + height / 2.2 - 1);
|
|
114
113
|
}
|
|
115
|
-
this.restoreStyle(ctx);
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
TextNote.Justification = TextJustification;
|
|
@@ -123,12 +123,12 @@ export class TimeSignature extends StaveModifier {
|
|
|
123
123
|
const stave = this.checkStave();
|
|
124
124
|
const ctx = stave.checkContext();
|
|
125
125
|
this.setRendered();
|
|
126
|
+
ctx.openGroup('timesignature', this.getAttribute('id'));
|
|
126
127
|
this.drawAt(ctx, stave, this.x);
|
|
128
|
+
ctx.closeGroup();
|
|
127
129
|
}
|
|
128
130
|
drawAt(ctx, stave, x) {
|
|
129
131
|
this.setRendered();
|
|
130
|
-
this.applyStyle(ctx);
|
|
131
|
-
ctx.openGroup('timesignature', this.getAttribute('id'));
|
|
132
132
|
if (this.isNumeric) {
|
|
133
133
|
let startX = x + this.topStartX;
|
|
134
134
|
let y = 0;
|
|
@@ -144,7 +144,5 @@ export class TimeSignature extends StaveModifier {
|
|
|
144
144
|
else {
|
|
145
145
|
this.renderText(ctx, x - this.x, stave.getYForLine(this.line));
|
|
146
146
|
}
|
|
147
|
-
ctx.closeGroup();
|
|
148
|
-
this.restoreStyle(ctx);
|
|
149
147
|
}
|
|
150
148
|
}
|
|
@@ -21,6 +21,8 @@ export class TimeSigNote extends Note {
|
|
|
21
21
|
const stave = this.checkStave();
|
|
22
22
|
const ctx = this.checkContext();
|
|
23
23
|
this.setRendered();
|
|
24
|
+
ctx.openGroup('timesignote', this.getAttribute('id'));
|
|
24
25
|
this.timeSig.drawAt(ctx, stave, this.getAbsoluteX());
|
|
26
|
+
ctx.closeGroup();
|
|
25
27
|
}
|
|
26
28
|
}
|
package/build/esm/src/tuplet.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Element } from './element.js';
|
|
2
2
|
import { Formatter } from './formatter.js';
|
|
3
3
|
import { Glyphs } from './glyphs.js';
|
|
4
|
+
import { Metrics } from './metrics.js';
|
|
4
5
|
import { Stem } from './stem.js';
|
|
5
6
|
import { Tables } from './tables.js';
|
|
6
7
|
import { RuntimeError } from './util.js';
|
|
@@ -22,20 +23,25 @@ export class Tuplet extends Element {
|
|
|
22
23
|
if (!notes || !notes.length) {
|
|
23
24
|
throw new RuntimeError('BadArguments', 'No notes provided for tuplet.');
|
|
24
25
|
}
|
|
25
|
-
this.options = options;
|
|
26
26
|
this.notes = notes;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
const numNotes = options.numNotes !== undefined ? options.numNotes : notes.length;
|
|
28
|
+
const notesOccupied = options.notesOccupied || 2;
|
|
29
|
+
const bracketed = options.bracketed !== undefined ? options.bracketed : notes.some((note) => !note.hasBeam());
|
|
30
|
+
const ratioed = options.ratioed !== undefined ? options.ratioed : Math.abs(notesOccupied - numNotes) > 1;
|
|
31
|
+
const location = options.location || Tuplet.LOCATION_TOP;
|
|
32
|
+
const yOffset = options.yOffset || Metrics.get('Tuplet.yOffset');
|
|
33
|
+
const textYOffset = options.textYOffset || Metrics.get('Tuplet.textYOffset');
|
|
34
|
+
this.options = {
|
|
35
|
+
bracketed,
|
|
36
|
+
location,
|
|
37
|
+
notesOccupied,
|
|
38
|
+
numNotes,
|
|
39
|
+
ratioed,
|
|
40
|
+
yOffset,
|
|
41
|
+
textYOffset,
|
|
42
|
+
};
|
|
37
43
|
this.textElement = new Element('Tuplet');
|
|
38
|
-
this.setTupletLocation(
|
|
44
|
+
this.setTupletLocation(location || Tuplet.LOCATION_TOP);
|
|
39
45
|
Formatter.AlignRestsToNotes(notes, true, true);
|
|
40
46
|
this.resolveGlyphs();
|
|
41
47
|
this.attach();
|
|
@@ -53,11 +59,11 @@ export class Tuplet extends Element {
|
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
setBracketed(bracketed) {
|
|
56
|
-
this.bracketed =
|
|
62
|
+
this.options.bracketed = bracketed;
|
|
57
63
|
return this;
|
|
58
64
|
}
|
|
59
65
|
setRatioed(ratioed) {
|
|
60
|
-
this.ratioed =
|
|
66
|
+
this.options.ratioed = ratioed;
|
|
61
67
|
return this;
|
|
62
68
|
}
|
|
63
69
|
setTupletLocation(location) {
|
|
@@ -65,34 +71,34 @@ export class Tuplet extends Element {
|
|
|
65
71
|
console.warn(`Invalid tuplet location [${location}]. Using Tuplet.LOCATION_TOP.`);
|
|
66
72
|
location = Tuplet.LOCATION_TOP;
|
|
67
73
|
}
|
|
68
|
-
this.location = location;
|
|
74
|
+
this.options.location = location;
|
|
69
75
|
return this;
|
|
70
76
|
}
|
|
71
77
|
getNotes() {
|
|
72
78
|
return this.notes;
|
|
73
79
|
}
|
|
74
80
|
getNoteCount() {
|
|
75
|
-
return this.numNotes;
|
|
81
|
+
return this.options.numNotes;
|
|
76
82
|
}
|
|
77
83
|
getNotesOccupied() {
|
|
78
|
-
return this.notesOccupied;
|
|
84
|
+
return this.options.notesOccupied;
|
|
79
85
|
}
|
|
80
86
|
setNotesOccupied(notes) {
|
|
81
87
|
this.detach();
|
|
82
|
-
this.notesOccupied = notes;
|
|
88
|
+
this.options.notesOccupied = notes;
|
|
83
89
|
this.resolveGlyphs();
|
|
84
90
|
this.attach();
|
|
85
91
|
}
|
|
86
92
|
resolveGlyphs() {
|
|
87
93
|
let numerator = '';
|
|
88
94
|
let denominator = '';
|
|
89
|
-
let n = this.numNotes;
|
|
95
|
+
let n = this.options.numNotes;
|
|
90
96
|
while (n >= 1) {
|
|
91
97
|
numerator = String.fromCharCode(0xe880 + (n % 10)) + numerator;
|
|
92
98
|
n = Math.floor(n / 10);
|
|
93
99
|
}
|
|
94
|
-
if (this.ratioed) {
|
|
95
|
-
n = this.notesOccupied;
|
|
100
|
+
if (this.options.ratioed) {
|
|
101
|
+
n = this.options.notesOccupied;
|
|
96
102
|
while (n >= 1) {
|
|
97
103
|
denominator = String.fromCharCode(0xe880 + (n % 10)) + denominator;
|
|
98
104
|
n = Math.floor(n / 10);
|
|
@@ -102,12 +108,12 @@ export class Tuplet extends Element {
|
|
|
102
108
|
this.textElement.setText(numerator + denominator);
|
|
103
109
|
}
|
|
104
110
|
getNestedTupletCount() {
|
|
105
|
-
const location = this.
|
|
111
|
+
const { location } = this.options;
|
|
106
112
|
const firstNote = this.notes[0];
|
|
107
113
|
let maxTupletCount = countTuplets(firstNote, location);
|
|
108
114
|
let minTupletCount = countTuplets(firstNote, location);
|
|
109
115
|
function countTuplets(note, location) {
|
|
110
|
-
return note.getTupletStack().filter((tuplet) => tuplet.location === location).length;
|
|
116
|
+
return note.getTupletStack().filter((tuplet) => tuplet.options.location === location).length;
|
|
111
117
|
}
|
|
112
118
|
this.notes.forEach((note) => {
|
|
113
119
|
const tupletCount = countTuplets(note, location);
|
|
@@ -118,11 +124,11 @@ export class Tuplet extends Element {
|
|
|
118
124
|
}
|
|
119
125
|
getYPosition() {
|
|
120
126
|
var _a;
|
|
121
|
-
const nestedTupletYOffset = this.getNestedTupletCount() * Tuplet.NESTING_OFFSET * -this.location;
|
|
127
|
+
const nestedTupletYOffset = this.getNestedTupletCount() * Tuplet.NESTING_OFFSET * -this.options.location;
|
|
122
128
|
const yOffset = (_a = this.options.yOffset) !== null && _a !== void 0 ? _a : 0;
|
|
123
129
|
const firstNote = this.notes[0];
|
|
124
130
|
let yPosition;
|
|
125
|
-
if (this.location === Tuplet.LOCATION_TOP) {
|
|
131
|
+
if (this.options.location === Tuplet.LOCATION_TOP) {
|
|
126
132
|
yPosition = firstNote.checkStave().getYForLine(0) - 1.5 * Tables.STAVE_LINE_DISTANCE;
|
|
127
133
|
for (let i = 0; i < this.notes.length; ++i) {
|
|
128
134
|
const note = this.notes[i];
|
|
@@ -166,13 +172,14 @@ export class Tuplet extends Element {
|
|
|
166
172
|
return yPosition + nestedTupletYOffset + yOffset;
|
|
167
173
|
}
|
|
168
174
|
draw() {
|
|
175
|
+
const { location, bracketed, textYOffset } = this.options;
|
|
169
176
|
const ctx = this.checkContext();
|
|
170
177
|
let xPos = 0;
|
|
171
178
|
let yPos = 0;
|
|
172
179
|
this.setRendered();
|
|
173
180
|
const firstNote = this.notes[0];
|
|
174
181
|
const lastNote = this.notes[this.notes.length - 1];
|
|
175
|
-
if (!
|
|
182
|
+
if (!bracketed) {
|
|
176
183
|
xPos = firstNote.getStemX();
|
|
177
184
|
this.width = lastNote.getStemX() - xPos;
|
|
178
185
|
}
|
|
@@ -183,15 +190,15 @@ export class Tuplet extends Element {
|
|
|
183
190
|
yPos = this.getYPosition();
|
|
184
191
|
const notationCenterX = xPos + this.width / 2;
|
|
185
192
|
const notationStartX = notationCenterX - this.textElement.getWidth() / 2;
|
|
186
|
-
if (
|
|
193
|
+
if (bracketed) {
|
|
187
194
|
const lineWidth = this.width / 2 - this.textElement.getWidth() / 2 - 5;
|
|
188
195
|
if (lineWidth > 0) {
|
|
189
196
|
ctx.fillRect(xPos, yPos, lineWidth, 1);
|
|
190
197
|
ctx.fillRect(xPos + this.width / 2 + this.textElement.getWidth() / 2 + 5, yPos, lineWidth, 1);
|
|
191
|
-
ctx.fillRect(xPos, yPos + (
|
|
192
|
-
ctx.fillRect(xPos + this.width, yPos + (
|
|
198
|
+
ctx.fillRect(xPos, yPos + (location === Tuplet.LOCATION_BOTTOM ? 1 : 0), 1, location * 10);
|
|
199
|
+
ctx.fillRect(xPos + this.width, yPos + (location === Tuplet.LOCATION_BOTTOM ? 1 : 0), 1, location * 10);
|
|
193
200
|
}
|
|
194
201
|
}
|
|
195
|
-
this.textElement.renderText(ctx, notationStartX, yPos + this.textElement.getHeight() / 2);
|
|
202
|
+
this.textElement.renderText(ctx, notationStartX, yPos + this.textElement.getHeight() / 2 + (location === Tuplet.LOCATION_TOP ? -1 : 1) * textYOffset);
|
|
196
203
|
}
|
|
197
204
|
}
|
package/build/esm/src/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const VERSION = '5.0.0-
|
|
2
|
-
export const ID = '
|
|
3
|
-
export const DATE = '2024-
|
|
1
|
+
export const VERSION = '5.0.0-beta.0';
|
|
2
|
+
export const ID = '2daeb4def8b685227f2a3c924177b40ddcc5bda3';
|
|
3
|
+
export const DATE = '2024-09-12T19:16:57.446Z';
|
package/build/esm/src/vexflow.js
CHANGED
|
@@ -104,6 +104,7 @@ export class VexFlow {
|
|
|
104
104
|
}
|
|
105
105
|
static setFonts(...fontNames) {
|
|
106
106
|
MetricsDefaults.fontFamily = fontNames.join(',');
|
|
107
|
+
Metrics.clear();
|
|
107
108
|
}
|
|
108
109
|
static getFonts() {
|
|
109
110
|
return Metrics.get('fontFamily').split(',');
|
|
@@ -157,10 +158,13 @@ export class VexFlow {
|
|
|
157
158
|
Tables.STAVE_LINE_DISTANCE = value;
|
|
158
159
|
}
|
|
159
160
|
static get STAVE_LINE_THICKNESS() {
|
|
160
|
-
return
|
|
161
|
+
return MetricsDefaults.Stave.lineWidth;
|
|
161
162
|
}
|
|
162
163
|
static set STAVE_LINE_THICKNESS(value) {
|
|
163
|
-
|
|
164
|
+
MetricsDefaults.Stave.lineWidth = value;
|
|
165
|
+
MetricsDefaults.TabStave.lineWidth = value;
|
|
166
|
+
Metrics.clear('Stave');
|
|
167
|
+
Metrics.clear('TabStave');
|
|
164
168
|
}
|
|
165
169
|
static get STEM_HEIGHT() {
|
|
166
170
|
return Tables.STEM_HEIGHT;
|
|
@@ -126,9 +126,11 @@ function formatAccidentalSpaces(options) {
|
|
|
126
126
|
duration: '8d',
|
|
127
127
|
}).addModifier(new Accidental('##'), 0),
|
|
128
128
|
new StaveNote({
|
|
129
|
-
keys: ['
|
|
129
|
+
keys: ['Bb/4', 'Bn/4'],
|
|
130
130
|
duration: '16',
|
|
131
|
-
})
|
|
131
|
+
})
|
|
132
|
+
.addModifier(new Accidental('b'), 0)
|
|
133
|
+
.addModifier(new Accidental('n'), 0),
|
|
132
134
|
new StaveNote({
|
|
133
135
|
keys: ['f/3'],
|
|
134
136
|
duration: '8',
|
|
@@ -166,9 +168,11 @@ function formatAccidentalSpaces(options) {
|
|
|
166
168
|
duration: '16',
|
|
167
169
|
}),
|
|
168
170
|
new StaveNote({
|
|
169
|
-
keys: ['
|
|
171
|
+
keys: ['Db/4', 'Dn/4'],
|
|
170
172
|
duration: 'q',
|
|
171
|
-
})
|
|
173
|
+
})
|
|
174
|
+
.addModifier(new Accidental('b'), 0)
|
|
175
|
+
.addModifier(new Accidental('n'), 0),
|
|
172
176
|
];
|
|
173
177
|
Dot.buildAndAttach([notes[0]], { all: true });
|
|
174
178
|
const beams = Beam.generateBeams(notes);
|
|
@@ -180,10 +184,10 @@ function formatAccidentalSpaces(options) {
|
|
|
180
184
|
const formatter = new Formatter({ softmaxFactor }).joinVoices([voice]);
|
|
181
185
|
const width = formatter.preCalculateMinTotalWidth([voice]);
|
|
182
186
|
const stave = new Stave(10, 40, width + 20);
|
|
183
|
-
stave.setContext(context).
|
|
187
|
+
stave.setContext(context).drawWithStyle();
|
|
184
188
|
formatter.format([voice], width);
|
|
185
189
|
voice.draw(context, stave);
|
|
186
|
-
beams.forEach((b) => b.setContext(context).
|
|
190
|
+
beams.forEach((b) => b.setContext(context).drawWithStyle());
|
|
187
191
|
notes.forEach((note) => Note.plotMetrics(context, note, 30));
|
|
188
192
|
VexFlowTests.plotLegendForNoteWidth(context, 300, 150);
|
|
189
193
|
options.assert.ok(true);
|
|
@@ -270,7 +274,15 @@ function genAccidentals() {
|
|
|
270
274
|
accs.push(String.fromCodePoint(u));
|
|
271
275
|
}
|
|
272
276
|
for (let u = 0xe310; u <= 0xe335; u++) {
|
|
273
|
-
|
|
277
|
+
switch (u) {
|
|
278
|
+
case 0xe31a:
|
|
279
|
+
case 0xe31b:
|
|
280
|
+
case 0xe31e:
|
|
281
|
+
case 0xe31f:
|
|
282
|
+
break;
|
|
283
|
+
default:
|
|
284
|
+
accs.push(String.fromCodePoint(u));
|
|
285
|
+
}
|
|
274
286
|
}
|
|
275
287
|
for (let u = 0xe340; u <= 0xe367; u++) {
|
|
276
288
|
accs.push(String.fromCodePoint(u));
|
|
@@ -309,21 +321,22 @@ function genAccidentals() {
|
|
|
309
321
|
}
|
|
310
322
|
const accidentals = genAccidentals();
|
|
311
323
|
function cautionary(options) {
|
|
312
|
-
const staveCount =
|
|
324
|
+
const staveCount = 20;
|
|
325
|
+
const notesPerStave = 22;
|
|
313
326
|
const scale = 0.85;
|
|
314
|
-
const staveWidth =
|
|
327
|
+
const staveWidth = 900;
|
|
328
|
+
const staveHeight = 75;
|
|
315
329
|
let i = 0;
|
|
316
330
|
let j = 0;
|
|
317
|
-
const f = VexFlowTests.makeFactory(options, staveWidth + 10,
|
|
331
|
+
const f = VexFlowTests.makeFactory(options, staveWidth + 10, staveHeight * staveCount + 10);
|
|
318
332
|
f.getContext().scale(scale, scale);
|
|
319
333
|
const accids = Object.values(accidentals).filter((accid) => accid !== '{' && accid !== '}');
|
|
320
|
-
const mod = Math.round(accids.length / staveCount);
|
|
321
334
|
for (i = 0; i < staveCount; ++i) {
|
|
322
|
-
const stave = f.Stave({ x: 0, y: 10 +
|
|
335
|
+
const stave = f.Stave({ x: 0, y: 10 + (staveHeight / scale) * i, width: staveWidth / scale });
|
|
323
336
|
const score = f.EasyScore();
|
|
324
337
|
const rowMap = [];
|
|
325
|
-
for (j = 0; j <
|
|
326
|
-
rowMap.push(accids[j + i *
|
|
338
|
+
for (j = 0; j < notesPerStave && j + i * notesPerStave < accids.length; ++j) {
|
|
339
|
+
rowMap.push(accids[j + i * notesPerStave]);
|
|
327
340
|
}
|
|
328
341
|
const notes = rowMap.map((accidType) => f
|
|
329
342
|
.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: Stem.UP })
|
|
@@ -435,8 +448,8 @@ function multiVoice(options) {
|
|
|
435
448
|
note1.addToModifierContext(modifierContext);
|
|
436
449
|
note2.addToModifierContext(modifierContext);
|
|
437
450
|
new TickContext().addTickable(note1).addTickable(note2).preFormat().setX(x);
|
|
438
|
-
note1.setContext(ctx).
|
|
439
|
-
note2.setContext(ctx).
|
|
451
|
+
note1.setContext(ctx).drawWithStyle();
|
|
452
|
+
note2.setContext(ctx).drawWithStyle();
|
|
440
453
|
Note.plotMetrics(ctx, note1, 180);
|
|
441
454
|
Note.plotMetrics(ctx, note2, 15);
|
|
442
455
|
}
|
|
@@ -444,7 +457,7 @@ function multiVoice(options) {
|
|
|
444
457
|
const accid = makeNewAccid(f);
|
|
445
458
|
const stave = f.Stave({ x: 10, y: 45, width: 420 });
|
|
446
459
|
const ctx = f.getContext();
|
|
447
|
-
stave.
|
|
460
|
+
stave.drawWithStyle();
|
|
448
461
|
let note1 = f
|
|
449
462
|
.StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: '2', stemDirection: -1 })
|
|
450
463
|
.addModifier(accid('b'), 0)
|