vexflow 4.0.1-alpha.2 → 4.0.1-beta.2
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/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 +345 -115
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +247 -78
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow-font-bravura.js +1 -1
- package/build/cjs/vexflow-font-bravura.js.map +1 -1
- package/build/cjs/vexflow-font-gonville.js +1 -1
- package/build/cjs/vexflow-font-gonville.js.map +1 -1
- package/build/cjs/vexflow-font-petaluma.js +1 -1
- package/build/cjs/vexflow-font-petaluma.js.map +1 -1
- package/build/cjs/vexflow-gonville.js +2 -2
- package/build/cjs/vexflow-gonville.js.map +1 -1
- package/build/cjs/vexflow-petaluma.js +2 -2
- package/build/cjs/vexflow-petaluma.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/src/accidental.js +1 -1
- package/build/esm/src/annotation.js +24 -5
- package/build/esm/src/articulation.js +5 -2
- package/build/esm/src/beam.js +4 -0
- package/build/esm/src/fonts/bravura_metrics.js +8 -5
- package/build/esm/src/fonts/gonville_glyphs.js +4 -4
- package/build/esm/src/fonts/gonville_metrics.js +8 -2
- package/build/esm/src/fonts/petaluma_metrics.js +8 -5
- package/build/esm/src/gracenote.js +2 -0
- package/build/esm/src/note.js +1 -1
- package/build/esm/src/stavenote.js +88 -22
- package/build/esm/src/staverepetition.js +8 -8
- package/build/esm/src/stavetie.js +2 -0
- package/build/esm/src/stemmablenote.js +4 -2
- package/build/esm/src/tables.js +36 -0
- package/build/esm/src/tabnote.js +12 -9
- package/build/esm/src/version.js +3 -3
- package/build/esm/tests/articulation_tests.js +11 -24
- package/build/esm/tests/formatter_tests.js +2 -2
- package/build/esm/tests/gracenote_tests.js +43 -0
- package/build/esm/tests/ornament_tests.js +0 -1
- package/build/esm/tests/stavenote_tests.js +32 -0
- package/build/types/entry/vexflow-font-bravura.d.ts +8 -5
- package/build/types/entry/vexflow-font-gonville.d.ts +8 -2
- package/build/types/entry/vexflow-font-petaluma.d.ts +8 -5
- package/build/types/src/fonts/bravura_metrics.d.ts +8 -5
- package/build/types/src/fonts/gonville_metrics.d.ts +8 -2
- package/build/types/src/fonts/petaluma_metrics.d.ts +8 -5
- package/build/types/src/glyph.d.ts +4 -0
- package/build/types/src/note.d.ts +1 -0
- package/build/types/src/stavenote.d.ts +2 -0
- package/build/types/src/stem.d.ts +4 -1
- package/build/types/src/stemmablenote.d.ts +4 -1
- package/build/types/src/tabnote.d.ts +4 -1
- package/package.json +1 -1
- package/src/accidental.ts +1 -1
- package/src/annotation.ts +27 -6
- package/src/articulation.ts +8 -2
- package/src/beam.ts +4 -0
- package/src/fonts/bravura_metrics.ts +8 -5
- package/src/fonts/gonville_glyphs.ts +4 -4
- package/src/fonts/gonville_metrics.ts +8 -2
- package/src/fonts/petaluma_metrics.ts +8 -5
- package/src/glyph.ts +4 -0
- package/src/gracenote.ts +4 -1
- package/src/note.ts +2 -2
- package/src/stavenote.ts +97 -21
- package/src/staverepetition.ts +8 -8
- package/src/stavetie.ts +8 -0
- package/src/stem.ts +1 -1
- package/src/stemmablenote.ts +6 -4
- package/src/tables.ts +36 -0
- package/src/tabnote.ts +16 -13
- package/build/esm/src/publicpath.js +0 -1
- package/build/types/src/publicpath.d.ts +0 -0
- package/src/publicpath.ts +0 -0
package/build/esm/src/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const VERSION = '4.0.1-
|
|
2
|
-
export const ID = '
|
|
3
|
-
export const DATE = '2022-02-
|
|
1
|
+
export const VERSION = '4.0.1-beta.2';
|
|
2
|
+
export const ID = '567ba80618390639c170a60de47ab4d1f2eabbff';
|
|
3
|
+
export const DATE = '2022-02-27T01:14:47.524Z';
|
|
@@ -205,28 +205,10 @@ function verticalPlacement(options, contextBuilder) {
|
|
|
205
205
|
function drawArticulations2(options) {
|
|
206
206
|
expect(0);
|
|
207
207
|
const scale = 0.8;
|
|
208
|
-
|
|
209
|
-
const y = 30;
|
|
210
|
-
const width = 350 - Stave.defaultPadding;
|
|
211
|
-
const f = VexFlowTests.makeFactory(options, 1000, 195);
|
|
208
|
+
const f = VexFlowTests.makeFactory(options, 1500, 195);
|
|
212
209
|
const ctx = f.getContext();
|
|
213
210
|
ctx.scale(scale, scale);
|
|
214
|
-
const
|
|
215
|
-
const formatAndDrawToWidth = (x, y, width, notes, barline, beams) => {
|
|
216
|
-
const voices = [score.voice(notes, { time: '4/4' })];
|
|
217
|
-
const formatter = f.Formatter();
|
|
218
|
-
voices.forEach((v) => formatter.joinVoices([v]));
|
|
219
|
-
const nwidth = Math.max(formatter.preCalculateMinTotalWidth(voices), width);
|
|
220
|
-
formatter.format(voices, nwidth);
|
|
221
|
-
const stave = f
|
|
222
|
-
.Stave({ x: x, y: y, width: nwidth + Stave.defaultPadding })
|
|
223
|
-
.setEndBarType(barline)
|
|
224
|
-
.setContext(ctx)
|
|
225
|
-
.draw();
|
|
226
|
-
voices.forEach((voice) => voice.draw(ctx, stave));
|
|
227
|
-
beams.forEach((beam) => beam.setContext(ctx).draw());
|
|
228
|
-
return stave.getWidth();
|
|
229
|
-
};
|
|
211
|
+
const stave1 = new Stave(10, 50, 500).setContext(ctx).draw();
|
|
230
212
|
const notesBar1 = [
|
|
231
213
|
f.StaveNote({ keys: ['c/4'], duration: '16', stem_direction: 1 }),
|
|
232
214
|
f.StaveNote({ keys: ['d/4'], duration: '16', stem_direction: 1 }),
|
|
@@ -255,9 +237,10 @@ function drawArticulations2(options) {
|
|
|
255
237
|
}
|
|
256
238
|
const beam1 = new Beam(notesBar1.slice(0, 8));
|
|
257
239
|
const beam2 = new Beam(notesBar1.slice(8, 16));
|
|
258
|
-
|
|
240
|
+
Formatter.FormatAndDraw(ctx, stave1, notesBar1);
|
|
259
241
|
beam1.setContext(ctx).draw();
|
|
260
242
|
beam2.setContext(ctx).draw();
|
|
243
|
+
const stave2 = new Stave(510, 50, 500).setContext(ctx).draw();
|
|
261
244
|
const notesBar2 = [
|
|
262
245
|
f.StaveNote({ keys: ['f/3'], duration: '16', stem_direction: 1 }),
|
|
263
246
|
f.StaveNote({ keys: ['g/3'], duration: '16', stem_direction: 1 }),
|
|
@@ -285,12 +268,16 @@ function drawArticulations2(options) {
|
|
|
285
268
|
}
|
|
286
269
|
const beam3 = new Beam(notesBar2.slice(0, 8));
|
|
287
270
|
const beam4 = new Beam(notesBar2.slice(8, 16));
|
|
288
|
-
|
|
271
|
+
Formatter.FormatAndDraw(ctx, stave2, notesBar2);
|
|
272
|
+
beam3.setContext(ctx).draw();
|
|
273
|
+
beam4.setContext(ctx).draw();
|
|
274
|
+
const stave3 = new Stave(1010, 50, 100).setContext(ctx).draw();
|
|
289
275
|
const notesBar3 = [f.StaveNote({ keys: ['c/4'], duration: 'w', stem_direction: 1 })];
|
|
290
276
|
notesBar3[0].addModifier(new Articulation('a-').setPosition(3), 0);
|
|
291
277
|
notesBar3[0].addModifier(new Articulation('a>').setPosition(3), 0);
|
|
292
278
|
notesBar3[0].addModifier(new Articulation('a@a').setPosition(3), 0);
|
|
293
|
-
|
|
279
|
+
Formatter.FormatAndDraw(ctx, stave3, notesBar3);
|
|
280
|
+
const stave4 = new Stave(1110, 50, 250).setContext(ctx).draw();
|
|
294
281
|
const notesBar4 = [
|
|
295
282
|
f.StaveNote({ keys: ['c/5'], duration: 'q', stem_direction: -1 }),
|
|
296
283
|
f.StaveNote({ keys: ['a/5'], duration: 'q', stem_direction: -1 }),
|
|
@@ -304,7 +291,7 @@ function drawArticulations2(options) {
|
|
|
304
291
|
}
|
|
305
292
|
notesBar4[i].addModifier(new Articulation('a-').setPosition(position1), 0);
|
|
306
293
|
}
|
|
307
|
-
|
|
294
|
+
Formatter.FormatAndDraw(ctx, stave4, notesBar4);
|
|
308
295
|
}
|
|
309
296
|
function tabNotes(options, contextBuilder) {
|
|
310
297
|
const ctx = contextBuilder(options.elementId, 600, 200);
|
|
@@ -104,8 +104,8 @@ function rightJustify(options) {
|
|
|
104
104
|
};
|
|
105
105
|
renderTest({ num_beats: 4, beat_value: 4, resolution: 4 * 4096 }, 2, '2', 10, 300);
|
|
106
106
|
renderTest({ num_beats: 4, beat_value: 4, resolution: 4 * 4096 }, 1, 'w', 310, 300);
|
|
107
|
-
renderTest({ num_beats:
|
|
108
|
-
renderTest({ num_beats:
|
|
107
|
+
renderTest({ num_beats: 4, beat_value: 4, resolution: 4 * 4096 }, 4, '4', 610, 300);
|
|
108
|
+
renderTest({ num_beats: 4, beat_value: 4, resolution: 4 * 4096 }, 8, '8', 910, 300);
|
|
109
109
|
ok(true);
|
|
110
110
|
}
|
|
111
111
|
function noteHeadPadding(options) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Accidental } from '../src/accidental.js';
|
|
3
|
+
import { Annotation } from '../src/annotation.js';
|
|
4
|
+
import { Articulation } from '../src/articulation.js';
|
|
2
5
|
import { Dot } from '../src/dot.js';
|
|
3
6
|
import { Formatter } from '../src/formatter.js';
|
|
4
7
|
const GraceNoteTests = {
|
|
@@ -6,6 +9,7 @@ const GraceNoteTests = {
|
|
|
6
9
|
QUnit.module('Grace Notes');
|
|
7
10
|
const run = VexFlowTests.runTests;
|
|
8
11
|
run('Grace Note Basic', basic);
|
|
12
|
+
run('With Articulation and Annotation on Parent Note', graceNoteModifiers);
|
|
9
13
|
run('Grace Note Basic with Slurs', basicSlurred);
|
|
10
14
|
run('Grace Note Stem', stem);
|
|
11
15
|
run('Grace Note Stem with Beams 1', stemWithBeamed, {
|
|
@@ -81,6 +85,45 @@ function basic(options) {
|
|
|
81
85
|
f.draw();
|
|
82
86
|
ok(true, 'GraceNoteBasic');
|
|
83
87
|
}
|
|
88
|
+
function graceNoteModifiers(options) {
|
|
89
|
+
const f = VexFlowTests.makeFactory(options, 700, 130);
|
|
90
|
+
const stave = f.Stave({ x: 10, y: 10, width: 650 });
|
|
91
|
+
const gracenotes = [{ keys: ['b/4'], duration: '8', slash: false }].map(f.GraceNote.bind(f));
|
|
92
|
+
const notes = [
|
|
93
|
+
f
|
|
94
|
+
.StaveNote({ keys: ['c/5'], duration: '4', auto_stem: true })
|
|
95
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0),
|
|
96
|
+
f
|
|
97
|
+
.StaveNote({ keys: ['c/5'], duration: '4', auto_stem: true })
|
|
98
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
99
|
+
.addModifier(new Articulation('a-').setPosition(3), 0),
|
|
100
|
+
f
|
|
101
|
+
.StaveNote({ keys: ['c/5'], duration: '4', auto_stem: true })
|
|
102
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
103
|
+
.addModifier(new Articulation('a-').setPosition(3), 0)
|
|
104
|
+
.addModifier(new Accidental('#')),
|
|
105
|
+
f
|
|
106
|
+
.StaveNote({ keys: ['c/5'], duration: '4', auto_stem: true })
|
|
107
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
108
|
+
.addModifier(new Articulation('a-').setPosition(3), 0)
|
|
109
|
+
.addModifier(new Annotation('words')),
|
|
110
|
+
f
|
|
111
|
+
.StaveNote({ keys: ['c/5'], duration: '4', auto_stem: true })
|
|
112
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
113
|
+
.addModifier(new Articulation('a-').setPosition(3), 0)
|
|
114
|
+
.addModifier(new Articulation('a>').setPosition(3), 0),
|
|
115
|
+
f
|
|
116
|
+
.StaveNote({ keys: ['c/5'], duration: '4', auto_stem: true })
|
|
117
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
118
|
+
.addModifier(new Articulation('a-').setPosition(3), 0)
|
|
119
|
+
.addModifier(new Articulation('a>').setPosition(3), 0)
|
|
120
|
+
.addModifier(new Articulation('a@a').setPosition(3), 0),
|
|
121
|
+
];
|
|
122
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
123
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
124
|
+
f.draw();
|
|
125
|
+
ok(true, 'GraceNoteModifiers');
|
|
126
|
+
}
|
|
84
127
|
function basicSlurred(options) {
|
|
85
128
|
const f = VexFlowTests.makeFactory(options, 700, 130);
|
|
86
129
|
const stave = f.Stave({ x: 10, y: 10, width: 650 });
|
|
@@ -160,7 +160,6 @@ function drawOrnamentsWithAccidentals(options, contextBuilder) {
|
|
|
160
160
|
];
|
|
161
161
|
notes[0].addModifier(new Ornament('mordent').setUpperAccidental('#').setLowerAccidental('#'), 0);
|
|
162
162
|
notes[1].addModifier(new Ornament('turn_inverted').setLowerAccidental('b').setUpperAccidental('b'), 0);
|
|
163
|
-
notes[1].addModifier(new Ornament('turn_inverted').setLowerAccidental('b').setUpperAccidental('b'), 0);
|
|
164
163
|
notes[2].addModifier(new Ornament('turn').setUpperAccidental('##').setLowerAccidental('##'), 0);
|
|
165
164
|
notes[3].addModifier(new Ornament('mordent_inverted').setLowerAccidental('db').setUpperAccidental('db'), 0);
|
|
166
165
|
notes[4].addModifier(new Ornament('turn_inverted').setUpperAccidental('++').setLowerAccidental('++'), 0);
|
|
@@ -48,6 +48,7 @@ const StaveNoteTests = {
|
|
|
48
48
|
run('Flag and Dots Placement - Stem Down', dotsAndFlagsStemDown);
|
|
49
49
|
run('Beam and Dot Placement - Stem Up', dotsAndBeamsUp);
|
|
50
50
|
run('Beam and Dot Placement - Stem Down', dotsAndBeamsDown);
|
|
51
|
+
run('Note Heads Placement - Simple', noteHeadsSimple);
|
|
51
52
|
run('Center Aligned Note', centerAlignedRest);
|
|
52
53
|
run('Center Aligned Note with Articulation', centerAlignedRestFermata);
|
|
53
54
|
run('Center Aligned Note with Annotation', centerAlignedRestAnnotation);
|
|
@@ -753,6 +754,37 @@ function dotsAndBeamsDown(options, contextBuilder) {
|
|
|
753
754
|
beam.setContext(ctx).draw();
|
|
754
755
|
ok(true, 'Full Dot');
|
|
755
756
|
}
|
|
757
|
+
function noteHeadsSimple(options) {
|
|
758
|
+
const vf = VexFlowTests.makeFactory(options, 800, 250);
|
|
759
|
+
const score = vf.EasyScore();
|
|
760
|
+
const system1 = vf.System({ y: 100, x: 50, width: 200 });
|
|
761
|
+
system1
|
|
762
|
+
.addStave({
|
|
763
|
+
voices: [
|
|
764
|
+
score.voice([...score.beam(score.notes('a4/8, b4/8', { stem: 'up' })), ...score.notes('a4/q/r, a4/h/r')]),
|
|
765
|
+
score.voice(score.notes('g4/w')),
|
|
766
|
+
],
|
|
767
|
+
})
|
|
768
|
+
.addClef('treble')
|
|
769
|
+
.addTimeSignature('4/4');
|
|
770
|
+
const system2 = vf.System({ y: 100, x: 250, width: 150 });
|
|
771
|
+
system2.addStave({
|
|
772
|
+
voices: [score.voice(score.notes('b4/h, b4/h/r')), score.voice(score.notes('b4/w'))],
|
|
773
|
+
});
|
|
774
|
+
const system3 = vf.System({ y: 100, x: 400, width: 150 });
|
|
775
|
+
system3.addStave({
|
|
776
|
+
voices: [score.voice(score.notes('d5/h, d5/h/r')), score.voice(score.notes('e4/w'))],
|
|
777
|
+
});
|
|
778
|
+
const system4 = vf.System({ y: 100, x: 550, width: 150 });
|
|
779
|
+
system4.addStave({
|
|
780
|
+
voices: [
|
|
781
|
+
score.voice(score.notes('e4/q, e4/q/r, e4/h/r')),
|
|
782
|
+
score.voice(score.notes('e4/8, e4/8/r, e4/q/r, e4/h/r')),
|
|
783
|
+
],
|
|
784
|
+
});
|
|
785
|
+
vf.draw();
|
|
786
|
+
expect(0);
|
|
787
|
+
}
|
|
756
788
|
function centerAlignedRest(options) {
|
|
757
789
|
const f = VexFlowTests.makeFactory(options, 400, 160);
|
|
758
790
|
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addClef('treble').addTimeSignature('4/4');
|
|
@@ -3379,11 +3379,17 @@ export declare const Font: {
|
|
|
3379
3379
|
};
|
|
3380
3380
|
};
|
|
3381
3381
|
staveRepetition: {
|
|
3382
|
-
|
|
3382
|
+
symbolText: {
|
|
3383
|
+
offsetX: number;
|
|
3383
3384
|
offsetY: number;
|
|
3384
|
-
offsetSymbol: number;
|
|
3385
3385
|
spacing: number;
|
|
3386
3386
|
};
|
|
3387
|
+
coda: {
|
|
3388
|
+
offsetY: number;
|
|
3389
|
+
};
|
|
3390
|
+
segno: {
|
|
3391
|
+
offsetY: number;
|
|
3392
|
+
};
|
|
3387
3393
|
};
|
|
3388
3394
|
stem: {
|
|
3389
3395
|
heightAdjustmentForFlag: number;
|
|
@@ -3437,9 +3443,6 @@ export declare const Font: {
|
|
|
3437
3443
|
};
|
|
3438
3444
|
flag: {
|
|
3439
3445
|
shiftX: number;
|
|
3440
|
-
tabStem: {
|
|
3441
|
-
shiftX: number;
|
|
3442
|
-
};
|
|
3443
3446
|
staveTempo: {
|
|
3444
3447
|
shiftX: number;
|
|
3445
3448
|
};
|
|
@@ -958,11 +958,17 @@ export declare const Font: {
|
|
|
958
958
|
};
|
|
959
959
|
};
|
|
960
960
|
staveRepetition: {
|
|
961
|
-
|
|
961
|
+
symbolText: {
|
|
962
|
+
offsetX: number;
|
|
962
963
|
offsetY: number;
|
|
963
|
-
offsetSymbol: number;
|
|
964
964
|
spacing: number;
|
|
965
965
|
};
|
|
966
|
+
coda: {
|
|
967
|
+
offsetY: number;
|
|
968
|
+
};
|
|
969
|
+
segno: {
|
|
970
|
+
offsetY: number;
|
|
971
|
+
};
|
|
966
972
|
};
|
|
967
973
|
stem: {
|
|
968
974
|
heightAdjustmentForFlag: number;
|
|
@@ -1475,11 +1475,17 @@ export declare const Font: {
|
|
|
1475
1475
|
};
|
|
1476
1476
|
};
|
|
1477
1477
|
staveRepetition: {
|
|
1478
|
-
|
|
1478
|
+
symbolText: {
|
|
1479
|
+
offsetX: number;
|
|
1479
1480
|
offsetY: number;
|
|
1480
|
-
offsetSymbol: number;
|
|
1481
1481
|
spacing: number;
|
|
1482
1482
|
};
|
|
1483
|
+
coda: {
|
|
1484
|
+
offsetY: number;
|
|
1485
|
+
};
|
|
1486
|
+
segno: {
|
|
1487
|
+
offsetY: number;
|
|
1488
|
+
};
|
|
1483
1489
|
};
|
|
1484
1490
|
noteHead: {
|
|
1485
1491
|
displaced: {
|
|
@@ -1562,9 +1568,6 @@ export declare const Font: {
|
|
|
1562
1568
|
flag128thDown: {
|
|
1563
1569
|
shiftX: number;
|
|
1564
1570
|
};
|
|
1565
|
-
tabStem: {
|
|
1566
|
-
shiftX: number;
|
|
1567
|
-
};
|
|
1568
1571
|
staveTempo: {
|
|
1569
1572
|
shiftX: number;
|
|
1570
1573
|
};
|
|
@@ -143,11 +143,17 @@ export declare const BravuraMetrics: {
|
|
|
143
143
|
};
|
|
144
144
|
};
|
|
145
145
|
staveRepetition: {
|
|
146
|
-
|
|
146
|
+
symbolText: {
|
|
147
|
+
offsetX: number;
|
|
147
148
|
offsetY: number;
|
|
148
|
-
offsetSymbol: number;
|
|
149
149
|
spacing: number;
|
|
150
150
|
};
|
|
151
|
+
coda: {
|
|
152
|
+
offsetY: number;
|
|
153
|
+
};
|
|
154
|
+
segno: {
|
|
155
|
+
offsetY: number;
|
|
156
|
+
};
|
|
151
157
|
};
|
|
152
158
|
stem: {
|
|
153
159
|
heightAdjustmentForFlag: number;
|
|
@@ -201,9 +207,6 @@ export declare const BravuraMetrics: {
|
|
|
201
207
|
};
|
|
202
208
|
flag: {
|
|
203
209
|
shiftX: number;
|
|
204
|
-
tabStem: {
|
|
205
|
-
shiftX: number;
|
|
206
|
-
};
|
|
207
210
|
staveTempo: {
|
|
208
211
|
shiftX: number;
|
|
209
212
|
};
|
|
@@ -133,11 +133,17 @@ export declare const GonvilleMetrics: {
|
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
135
|
staveRepetition: {
|
|
136
|
-
|
|
136
|
+
symbolText: {
|
|
137
|
+
offsetX: number;
|
|
137
138
|
offsetY: number;
|
|
138
|
-
offsetSymbol: number;
|
|
139
139
|
spacing: number;
|
|
140
140
|
};
|
|
141
|
+
coda: {
|
|
142
|
+
offsetY: number;
|
|
143
|
+
};
|
|
144
|
+
segno: {
|
|
145
|
+
offsetY: number;
|
|
146
|
+
};
|
|
141
147
|
};
|
|
142
148
|
stem: {
|
|
143
149
|
heightAdjustmentForFlag: number;
|
|
@@ -143,11 +143,17 @@ export declare const PetalumaMetrics: {
|
|
|
143
143
|
};
|
|
144
144
|
};
|
|
145
145
|
staveRepetition: {
|
|
146
|
-
|
|
146
|
+
symbolText: {
|
|
147
|
+
offsetX: number;
|
|
147
148
|
offsetY: number;
|
|
148
|
-
offsetSymbol: number;
|
|
149
149
|
spacing: number;
|
|
150
150
|
};
|
|
151
|
+
coda: {
|
|
152
|
+
offsetY: number;
|
|
153
|
+
};
|
|
154
|
+
segno: {
|
|
155
|
+
offsetY: number;
|
|
156
|
+
};
|
|
151
157
|
};
|
|
152
158
|
noteHead: {
|
|
153
159
|
displaced: {
|
|
@@ -230,9 +236,6 @@ export declare const PetalumaMetrics: {
|
|
|
230
236
|
flag128thDown: {
|
|
231
237
|
shiftX: number;
|
|
232
238
|
};
|
|
233
|
-
tabStem: {
|
|
234
|
-
shiftX: number;
|
|
235
|
-
};
|
|
236
239
|
staveTempo: {
|
|
237
240
|
shiftX: number;
|
|
238
241
|
};
|
|
@@ -12,6 +12,8 @@ export interface GlyphProps {
|
|
|
12
12
|
line_below: number;
|
|
13
13
|
line_above: number;
|
|
14
14
|
stem_beam_extension: number;
|
|
15
|
+
stem_up_extension: number;
|
|
16
|
+
stem_down_extension: number;
|
|
15
17
|
stem: Stem;
|
|
16
18
|
code: string;
|
|
17
19
|
code_flag_upstem: string;
|
|
@@ -19,6 +21,8 @@ export interface GlyphProps {
|
|
|
19
21
|
flag: boolean;
|
|
20
22
|
width: number;
|
|
21
23
|
text: string;
|
|
24
|
+
tabnote_stem_down_extension: number;
|
|
25
|
+
tabnote_stem_up_extension: number;
|
|
22
26
|
beam_count: number;
|
|
23
27
|
shift_y: number;
|
|
24
28
|
getWidth(a?: number): number;
|
|
@@ -200,6 +200,7 @@ export declare abstract class Note extends Tickable {
|
|
|
200
200
|
* @returns this
|
|
201
201
|
*/
|
|
202
202
|
addModifier(modifier: Modifier, index?: number): this;
|
|
203
|
+
/** Get all modifiers of a specific type in `this.modifiers`. */
|
|
203
204
|
getModifiersByType(type: string): Modifier[];
|
|
204
205
|
/** Get the coordinates for where modifiers begin. */
|
|
205
206
|
getModifierStartXY(position?: number, index?: number, options?: any): {
|
|
@@ -144,6 +144,8 @@ export declare class StaveNote extends StemmableNote {
|
|
|
144
144
|
drawFlag(): void;
|
|
145
145
|
drawNoteHeads(): void;
|
|
146
146
|
drawStem(stemOptions?: StemOptions): void;
|
|
147
|
+
/** Primarily used as the scaling factor for grace notes, GraceNote will return the required scale. */
|
|
148
|
+
getStaveNoteScale(): number;
|
|
147
149
|
/**
|
|
148
150
|
* Override stemmablenote stem extension to adjust for distance from middle line.
|
|
149
151
|
*/
|
|
@@ -46,7 +46,10 @@ export declare class Stem extends Element {
|
|
|
46
46
|
setYBounds(y_top: number, y_bottom: number): void;
|
|
47
47
|
getHeight(): number;
|
|
48
48
|
getBoundingBox(): BoundingBox;
|
|
49
|
-
getExtents():
|
|
49
|
+
getExtents(): {
|
|
50
|
+
topY: number;
|
|
51
|
+
baseY: number;
|
|
52
|
+
};
|
|
50
53
|
setVisibility(isVisible: boolean): this;
|
|
51
54
|
setStemlet(isStemlet: boolean, stemletHeight: number): this;
|
|
52
55
|
adjustHeightForFlag(): void;
|
|
@@ -23,7 +23,10 @@ export declare abstract class StemmableNote extends Note {
|
|
|
23
23
|
getCenterGlyphX(): number;
|
|
24
24
|
getStemExtension(): number;
|
|
25
25
|
setStemLength(height: number): this;
|
|
26
|
-
getStemExtents():
|
|
26
|
+
getStemExtents(): {
|
|
27
|
+
topY: number;
|
|
28
|
+
baseY: number;
|
|
29
|
+
};
|
|
27
30
|
/** Gets the `y` value for the top modifiers at a specific `textLine`. */
|
|
28
31
|
getYForTopText(textLine: number): number;
|
|
29
32
|
/** Gets the `y` value for the bottom modifiers at a specific `textLine`. */
|
|
@@ -32,7 +32,10 @@ export declare class TabNote extends StemmableNote {
|
|
|
32
32
|
preFormat(): void;
|
|
33
33
|
getStemX(): number;
|
|
34
34
|
getStemY(): number;
|
|
35
|
-
getStemExtents():
|
|
35
|
+
getStemExtents(): {
|
|
36
|
+
topY: number;
|
|
37
|
+
baseY: number;
|
|
38
|
+
};
|
|
36
39
|
drawFlag(): void;
|
|
37
40
|
drawModifiers(): void;
|
|
38
41
|
drawStemThrough(): void;
|
package/package.json
CHANGED
package/src/accidental.ts
CHANGED
|
@@ -97,7 +97,7 @@ export class Accidental extends Modifier {
|
|
|
97
97
|
if (note !== prevNote) {
|
|
98
98
|
// Iterate through all notes to get the displaced pixels
|
|
99
99
|
for (let n = 0; n < note.keys.length; ++n) {
|
|
100
|
-
shiftL = Math.max(note.getLeftDisplacedHeadPx(), shiftL);
|
|
100
|
+
shiftL = Math.max(note.getLeftDisplacedHeadPx() - note.getXShift(), shiftL);
|
|
101
101
|
}
|
|
102
102
|
prevNote = note;
|
|
103
103
|
}
|
package/src/annotation.ts
CHANGED
|
@@ -72,7 +72,10 @@ export class Annotation extends Modifier {
|
|
|
72
72
|
/** Arrange annotations within a `ModifierContext` */
|
|
73
73
|
static format(annotations: Annotation[], state: ModifierContextState): boolean {
|
|
74
74
|
if (!annotations || annotations.length === 0) return false;
|
|
75
|
-
let
|
|
75
|
+
let leftWidth = 0;
|
|
76
|
+
let rightWidth = 0;
|
|
77
|
+
let maxLeftGlyphWidth = 0;
|
|
78
|
+
let maxRightGlyphWidth = 0;
|
|
76
79
|
for (let i = 0; i < annotations.length; ++i) {
|
|
77
80
|
const annotation = annotations[i];
|
|
78
81
|
const textFormatter = TextFormatter.create(annotation.textFont);
|
|
@@ -81,6 +84,22 @@ export class Annotation extends Modifier {
|
|
|
81
84
|
let verticalSpaceNeeded = textLines;
|
|
82
85
|
|
|
83
86
|
const note = annotation.checkAttachedNote();
|
|
87
|
+
const glyphWidth = note.getGlyph().getWidth();
|
|
88
|
+
// Get the text width from the font metrics.
|
|
89
|
+
const textWidth = textFormatter.getWidthForTextInPx(annotation.text);
|
|
90
|
+
if (annotation.horizontalJustification === AnnotationHorizontalJustify.LEFT) {
|
|
91
|
+
maxLeftGlyphWidth = Math.max(glyphWidth, maxLeftGlyphWidth);
|
|
92
|
+
leftWidth = Math.max(leftWidth, textWidth);
|
|
93
|
+
} else if (annotation.horizontalJustification === AnnotationHorizontalJustify.RIGHT) {
|
|
94
|
+
maxRightGlyphWidth = Math.max(glyphWidth, maxLeftGlyphWidth);
|
|
95
|
+
rightWidth = Math.max(rightWidth, textWidth);
|
|
96
|
+
} else {
|
|
97
|
+
leftWidth = Math.max(leftWidth, textWidth / 2);
|
|
98
|
+
rightWidth = Math.max(rightWidth, textWidth / 2);
|
|
99
|
+
maxLeftGlyphWidth = Math.max(glyphWidth / 2, maxLeftGlyphWidth);
|
|
100
|
+
maxRightGlyphWidth = Math.max(glyphWidth / 2, maxRightGlyphWidth);
|
|
101
|
+
}
|
|
102
|
+
|
|
84
103
|
const stave: Stave | undefined = note.getStave();
|
|
85
104
|
const stemDirection = note.hasStem() ? note.getStemDirection() : Stem.UP;
|
|
86
105
|
let stemHeight = 0;
|
|
@@ -104,9 +123,6 @@ export class Annotation extends Modifier {
|
|
|
104
123
|
if (stave) {
|
|
105
124
|
lines = stave.getNumLines();
|
|
106
125
|
}
|
|
107
|
-
// Get the text width from the font metrics.
|
|
108
|
-
const textWidth = textFormatter.getWidthForTextInPx(annotation.text);
|
|
109
|
-
width = Math.max(width, textWidth);
|
|
110
126
|
|
|
111
127
|
if (annotation.verticalJustification === this.VerticalJustify.TOP) {
|
|
112
128
|
let noteLine = note.getLineNumber(true);
|
|
@@ -146,8 +162,13 @@ export class Annotation extends Modifier {
|
|
|
146
162
|
annotation.setTextLine(state.text_line);
|
|
147
163
|
}
|
|
148
164
|
}
|
|
149
|
-
|
|
150
|
-
|
|
165
|
+
const rightOverlap = Math.min(
|
|
166
|
+
Math.max(rightWidth - maxRightGlyphWidth, 0),
|
|
167
|
+
Math.max(rightWidth - state.right_shift, 0)
|
|
168
|
+
);
|
|
169
|
+
const leftOverlap = Math.min(Math.max(leftWidth - maxLeftGlyphWidth, 0), Math.max(leftWidth - state.left_shift, 0));
|
|
170
|
+
state.left_shift += leftOverlap / 2;
|
|
171
|
+
state.right_shift += rightOverlap / 2;
|
|
151
172
|
return true;
|
|
152
173
|
}
|
|
153
174
|
|
package/src/articulation.ts
CHANGED
|
@@ -205,6 +205,7 @@ export class Articulation extends Modifier {
|
|
|
205
205
|
if (!articulations || articulations.length === 0) return false;
|
|
206
206
|
|
|
207
207
|
const margin = 0.5;
|
|
208
|
+
let maxGlyphWidth = 0;
|
|
208
209
|
|
|
209
210
|
const getIncrement = (articulation: Articulation, line: number, position: number) =>
|
|
210
211
|
roundToNearestHalf(
|
|
@@ -214,6 +215,7 @@ export class Articulation extends Modifier {
|
|
|
214
215
|
|
|
215
216
|
articulations.forEach((articulation) => {
|
|
216
217
|
const note = articulation.checkAttachedNote();
|
|
218
|
+
maxGlyphWidth = Math.max(note.getGlyph().getWidth(), maxGlyphWidth);
|
|
217
219
|
let lines = 5;
|
|
218
220
|
const stemDirection = note.hasStem() ? note.getStemDirection() : Stem.UP;
|
|
219
221
|
let stemHeight = 0;
|
|
@@ -261,9 +263,13 @@ export class Articulation extends Modifier {
|
|
|
261
263
|
const width = articulations
|
|
262
264
|
.map((articulation) => articulation.getWidth())
|
|
263
265
|
.reduce((maxWidth, articWidth) => Math.max(articWidth, maxWidth));
|
|
266
|
+
const overlap = Math.min(
|
|
267
|
+
Math.max(width - maxGlyphWidth, 0),
|
|
268
|
+
Math.max(width - (state.left_shift + state.right_shift), 0)
|
|
269
|
+
);
|
|
264
270
|
|
|
265
|
-
state.left_shift +=
|
|
266
|
-
state.right_shift +=
|
|
271
|
+
state.left_shift += overlap / 2;
|
|
272
|
+
state.right_shift += overlap / 2;
|
|
267
273
|
return true;
|
|
268
274
|
}
|
|
269
275
|
|
package/src/beam.ts
CHANGED
|
@@ -851,7 +851,9 @@ export class Beam extends Element {
|
|
|
851
851
|
this.notes.forEach((note) => {
|
|
852
852
|
const stem = note.getStem();
|
|
853
853
|
if (stem) {
|
|
854
|
+
ctx.openGroup('stem', note.getAttribute('id') + '-stem');
|
|
854
855
|
stem.setContext(ctx).draw();
|
|
856
|
+
ctx.closeGroup();
|
|
855
857
|
}
|
|
856
858
|
}, this);
|
|
857
859
|
}
|
|
@@ -879,6 +881,7 @@ export class Beam extends Element {
|
|
|
879
881
|
if (lastBeamX) {
|
|
880
882
|
const lastBeamY = this.getSlopeY(lastBeamX, firstStemX, beamY, this.slope);
|
|
881
883
|
|
|
884
|
+
this.setAttribute('el', ctx.openGroup('beam'));
|
|
882
885
|
ctx.beginPath();
|
|
883
886
|
ctx.moveTo(startBeamX, startBeamY);
|
|
884
887
|
ctx.lineTo(startBeamX, startBeamY + beamThickness);
|
|
@@ -886,6 +889,7 @@ export class Beam extends Element {
|
|
|
886
889
|
ctx.lineTo(lastBeamX + 1, lastBeamY);
|
|
887
890
|
ctx.closePath();
|
|
888
891
|
ctx.fill();
|
|
892
|
+
ctx.closeGroup();
|
|
889
893
|
} else {
|
|
890
894
|
throw new RuntimeError('NoLastBeamX', 'lastBeamX undefined.');
|
|
891
895
|
}
|
|
@@ -143,11 +143,17 @@ export const BravuraMetrics = {
|
|
|
143
143
|
},
|
|
144
144
|
|
|
145
145
|
staveRepetition: {
|
|
146
|
-
|
|
146
|
+
symbolText: {
|
|
147
|
+
offsetX: 12,
|
|
147
148
|
offsetY: 25,
|
|
148
|
-
offsetSymbol: 12,
|
|
149
149
|
spacing: 5,
|
|
150
150
|
},
|
|
151
|
+
coda: {
|
|
152
|
+
offsetY: 25,
|
|
153
|
+
},
|
|
154
|
+
segno: {
|
|
155
|
+
offsetY: 10,
|
|
156
|
+
},
|
|
151
157
|
},
|
|
152
158
|
|
|
153
159
|
// noteHead: {
|
|
@@ -217,9 +223,6 @@ export const BravuraMetrics = {
|
|
|
217
223
|
},
|
|
218
224
|
flag: {
|
|
219
225
|
shiftX: -0.75,
|
|
220
|
-
tabStem: {
|
|
221
|
-
shiftX: -1.75,
|
|
222
|
-
},
|
|
223
226
|
staveTempo: {
|
|
224
227
|
shiftX: -1,
|
|
225
228
|
},
|
|
@@ -697,10 +697,10 @@ export const GonvilleFont = {
|
|
|
697
697
|
o: 'm -413 173 b -408 174 -412 174 -409 174 b -397 173 -404 174 -400 173 b -308 86 -394 172 -374 151 b -223 0 -261 37 -223 0 b -153 84 -223 0 -191 37 b -77 174 -83 173 -84 172 b -72 174 -76 174 -74 174 b -62 173 -68 174 -63 173 b 25 86 -59 172 -39 151 b 112 0 73 37 111 0 b 181 84 112 0 144 37 b 257 174 251 173 251 172 b 262 174 258 174 261 174 b 273 173 266 174 270 173 b 436 9 276 172 347 101 l 447 -1 l 477 36 b 522 79 511 79 513 79 l 522 79 b 552 51 533 79 539 73 b 596 -112 582 6 596 -51 b 567 -262 596 -161 586 -213 b 539 -322 558 -287 544 -316 b 524 -327 534 -326 529 -327 b 504 -315 515 -327 507 -323 b 503 -308 503 -312 503 -309 b 511 -285 503 -302 504 -297 b 555 -113 540 -227 555 -169 b 544 -34 555 -86 551 -59 b 522 19 540 -16 530 8 l 521 22 l 481 -26 l 405 -122 b 353 -176 366 -172 362 -176 b 349 -176 352 -176 351 -176 b 253 -87 341 -176 347 -180 b 167 0 206 -38 167 0 b 99 -86 167 0 136 -38 b 21 -174 27 -174 28 -173 b 17 -176 20 -176 19 -176 b 6 -174 13 -176 9 -174 b -81 -87 4 -173 -14 -152 b -167 0 -129 -38 -167 0 b -236 -86 -167 0 -198 -38 b -313 -174 -307 -174 -306 -173 b -318 -176 -314 -176 -315 -176 b -328 -174 -321 -176 -325 -174 b -491 -12 -330 -173 -367 -137 l -503 0 l -530 -34 b -570 -77 -562 -73 -564 -76 b -577 -79 -571 -79 -574 -79 b -597 -58 -588 -79 -597 -69 b -596 -49 -597 -55 -597 -52 b -417 172 -593 -43 -423 167 b -413 173 -417 172 -415 173 ',
|
|
698
698
|
},
|
|
699
699
|
stringsDownBow: {
|
|
700
|
-
x_min: -
|
|
701
|
-
x_max:
|
|
702
|
-
ha:
|
|
703
|
-
o: 'm -
|
|
700
|
+
x_min: -228.671875,
|
|
701
|
+
x_max: 227.3125,
|
|
702
|
+
ha: 232,
|
|
703
|
+
o: 'm -217 487 l -213 488 l 0 488 l 212 488 l 216 487 b 225 476 220 484 224 480 l 227 473 l 227 244 l 227 15 l 225 12 b 206 0 223 4 215 0 b 197 1 204 0 200 0 b 187 12 193 4 189 6 l 186 15 l 186 138 l 186 262 l -1 262 l -187 262 l -187 138 l -187 15 l -189 12 b -208 0 -193 4 -200 0 b -227 12 -216 0 -223 4 l -228 15 l -228 244 l -228 473 l -227 476 b -217 487 -225 480 -221 484 ',
|
|
704
704
|
},
|
|
705
705
|
stringsUpBow: {
|
|
706
706
|
x_min: -149.71875,
|
|
@@ -133,11 +133,17 @@ export const GonvilleMetrics = {
|
|
|
133
133
|
},
|
|
134
134
|
|
|
135
135
|
staveRepetition: {
|
|
136
|
-
|
|
136
|
+
symbolText: {
|
|
137
|
+
offsetX: 12,
|
|
137
138
|
offsetY: 25,
|
|
138
|
-
offsetSymbol: 12,
|
|
139
139
|
spacing: 5,
|
|
140
140
|
},
|
|
141
|
+
coda: {
|
|
142
|
+
offsetY: 25,
|
|
143
|
+
},
|
|
144
|
+
segno: {
|
|
145
|
+
offsetY: 0,
|
|
146
|
+
},
|
|
141
147
|
},
|
|
142
148
|
|
|
143
149
|
// noteHead: {
|