vexflow 4.0.2 → 4.0.3
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 +3 -1
- 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 +508 -265
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +232 -127
- 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/annotation.js +1 -1
- package/build/esm/src/chordsymbol.js +33 -9
- package/build/esm/src/element.js +10 -0
- package/build/esm/src/factory.js +20 -2
- package/build/esm/src/flow.js +6 -0
- package/build/esm/src/fonts/bravura_metrics.js +12 -12
- package/build/esm/src/fonts/gonville_metrics.js +8 -8
- package/build/esm/src/fonts/petaluma_metrics.js +8 -8
- package/build/esm/src/formatter.js +1 -1
- package/build/esm/src/gracenotegroup.js +3 -2
- package/build/esm/src/ornament.js +6 -2
- package/build/esm/src/stavenote.js +34 -9
- package/build/esm/src/stemmablenote.js +1 -0
- package/build/esm/src/stringnumber.js +12 -5
- package/build/esm/src/tables.js +1 -0
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/voice.js +4 -2
- package/build/esm/tests/chordsymbol_tests.js +91 -9
- package/build/esm/tests/ornament_tests.js +98 -94
- package/build/esm/tests/stavenote_tests.js +36 -0
- package/build/esm/tests/stringnumber_tests.js +28 -23
- package/build/types/src/chordsymbol.d.ts +1 -0
- package/build/types/src/element.d.ts +4 -1
- package/build/types/src/factory.d.ts +8 -4
- package/build/types/src/flow.d.ts +2 -0
- package/build/types/src/ornament.d.ts +1 -0
- package/build/types/src/stringnumber.d.ts +3 -1
- package/build/types/src/tables.d.ts +1 -0
- package/build/types/src/voice.d.ts +1 -3
- package/package.json +1 -1
- package/src/annotation.ts +1 -1
- package/src/chordsymbol.ts +35 -10
- package/src/element.ts +13 -1
- package/src/factory.ts +30 -3
- package/src/flow.ts +8 -0
- package/src/fonts/bravura_metrics.ts +12 -12
- package/src/fonts/gonville_metrics.ts +8 -8
- package/src/fonts/petaluma_metrics.ts +8 -8
- package/src/formatter.ts +1 -1
- package/src/gracenotegroup.ts +5 -2
- package/src/ornament.ts +6 -2
- package/src/stavenote.ts +36 -8
- package/src/stemmablenote.ts +1 -0
- package/src/stringnumber.ts +15 -6
- package/src/tables.ts +1 -0
- package/src/voice.ts +2 -3
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
2
|
import { Accidental } from '../src/accidental.js';
|
|
3
3
|
import { ChordSymbol } from '../src/chordsymbol.js';
|
|
4
|
+
import { Font } from '../src/font.js';
|
|
4
5
|
import { Formatter } from '../src/formatter.js';
|
|
6
|
+
import { Ornament } from '../src/ornament.js';
|
|
5
7
|
import { Stave } from '../src/stave.js';
|
|
6
8
|
import { StaveNote } from '../src/stavenote.js';
|
|
9
|
+
import { Tables } from '../src/tables.js';
|
|
7
10
|
const ChordSymbolTests = {
|
|
8
11
|
Start() {
|
|
9
12
|
QUnit.module('ChordSymbol');
|
|
10
13
|
const run = VexFlowTests.runTests;
|
|
14
|
+
run('Chord Symbol With Modifiers', withModifiers);
|
|
11
15
|
run('Chord Symbol Font Size Tests', fontSize);
|
|
12
16
|
run('Chord Symbol Kerning Tests', kern);
|
|
13
17
|
run('Top Chord Symbols', top);
|
|
@@ -20,6 +24,84 @@ const ChordSymbolTests = {
|
|
|
20
24
|
const superscript = { symbolModifier: ChordSymbol.symbolModifiers.SUPERSCRIPT };
|
|
21
25
|
const subscript = { symbolModifier: ChordSymbol.symbolModifiers.SUBSCRIPT };
|
|
22
26
|
const note = (factory, keys, duration, chordSymbol) => factory.StaveNote({ keys, duration }).addModifier(chordSymbol, 0);
|
|
27
|
+
function getGlyphWidth(glyphName) {
|
|
28
|
+
const musicFont = Tables.currentMusicFont();
|
|
29
|
+
const glyph = musicFont.getGlyphs()[glyphName];
|
|
30
|
+
const widthInEm = (glyph.x_max - glyph.x_min) / musicFont.getResolution();
|
|
31
|
+
return widthInEm * 38 * Font.scaleToPxFrom.pt;
|
|
32
|
+
}
|
|
33
|
+
function withModifiers(options) {
|
|
34
|
+
const f = VexFlowTests.makeFactory(options, 750, 580);
|
|
35
|
+
const ctx = f.getContext();
|
|
36
|
+
ctx.scale(1.5, 1.5);
|
|
37
|
+
ctx.fillStyle = '#221';
|
|
38
|
+
ctx.strokeStyle = '#221';
|
|
39
|
+
function draw(chords, y) {
|
|
40
|
+
const notes = [
|
|
41
|
+
note(f, ['c/4'], 'q', chords[0]).addModifier(new Ornament('doit')),
|
|
42
|
+
note(f, ['c/4'], 'q', chords[1]),
|
|
43
|
+
note(f, ['c/4'], 'q', chords[2]).addModifier(new Ornament('fall')),
|
|
44
|
+
note(f, ['c/4'], 'q', chords[3]),
|
|
45
|
+
];
|
|
46
|
+
const score = f.EasyScore();
|
|
47
|
+
const voice = score.voice(notes, { time: '4/4' });
|
|
48
|
+
const formatter = f.Formatter();
|
|
49
|
+
formatter.joinVoices([voice]);
|
|
50
|
+
const voiceW = formatter.preCalculateMinTotalWidth([voice]);
|
|
51
|
+
const staffW = voiceW + Stave.defaultPadding + getGlyphWidth('gClef');
|
|
52
|
+
formatter.format([voice], voiceW);
|
|
53
|
+
const staff = f.Stave({ x: 10, y, width: staffW }).addClef('treble').draw();
|
|
54
|
+
voice.draw(ctx, staff);
|
|
55
|
+
}
|
|
56
|
+
let chords = [];
|
|
57
|
+
chords.push(f
|
|
58
|
+
.ChordSymbol({ fontSize: 10 })
|
|
59
|
+
.addText('F7')
|
|
60
|
+
.addGlyph('leftParenTall')
|
|
61
|
+
.addGlyphOrText('b9', superscript)
|
|
62
|
+
.addGlyphOrText('#11', subscript)
|
|
63
|
+
.addGlyph('rightParenTall'));
|
|
64
|
+
chords.push(f.ChordSymbol({ fontSize: 12 }).addText('F7').addGlyphOrText('b9', superscript).addGlyphOrText('#11', subscript));
|
|
65
|
+
chords.push(f
|
|
66
|
+
.ChordSymbol({ fontSize: 14 })
|
|
67
|
+
.addText('F7')
|
|
68
|
+
.addGlyph('leftParenTall')
|
|
69
|
+
.addGlyphOrText('add 3', superscript)
|
|
70
|
+
.addGlyphOrText('omit 9', subscript)
|
|
71
|
+
.addGlyph('rightParenTall'));
|
|
72
|
+
chords.push(f
|
|
73
|
+
.ChordSymbol({ fontSize: 16 })
|
|
74
|
+
.addText('F7')
|
|
75
|
+
.addGlyph('leftParenTall')
|
|
76
|
+
.addGlyphOrText('b9', superscript)
|
|
77
|
+
.addGlyphOrText('#11', subscript)
|
|
78
|
+
.addGlyph('rightParenTall'));
|
|
79
|
+
draw(chords, 40);
|
|
80
|
+
chords = [];
|
|
81
|
+
chords.push(f
|
|
82
|
+
.ChordSymbol({ fontSize: 10 })
|
|
83
|
+
.setFontSize(10)
|
|
84
|
+
.addText('F7')
|
|
85
|
+
.addGlyphOrText('#11', superscript)
|
|
86
|
+
.addGlyphOrText('b9', subscript));
|
|
87
|
+
chords.push(f.ChordSymbol({ fontSize: 12 }).addText('F7').addGlyphOrText('#11', superscript).addGlyphOrText('b9', subscript));
|
|
88
|
+
chords.push(f.ChordSymbol({ fontSize: 14 }).addText('F7').addGlyphOrText('#11', superscript).addGlyphOrText('b9', subscript));
|
|
89
|
+
chords.push(f
|
|
90
|
+
.ChordSymbol({ fontSize: 16 })
|
|
91
|
+
.setFontSize(16)
|
|
92
|
+
.addText('F7')
|
|
93
|
+
.addGlyphOrText('#11', superscript)
|
|
94
|
+
.addGlyphOrText('b9', subscript));
|
|
95
|
+
draw(chords, 140);
|
|
96
|
+
chords = [
|
|
97
|
+
f.ChordSymbol({ fontSize: 10 }).addGlyphOrText('Ab').addGlyphOrText('7(#11b9)', superscript),
|
|
98
|
+
f.ChordSymbol({ fontSize: 14 }).addGlyphOrText('C#').addGlyphOrText('7(#11b9)', superscript),
|
|
99
|
+
f.ChordSymbol({ fontSize: 16 }).addGlyphOrText('Ab').addGlyphOrText('7(#11b9)', superscript),
|
|
100
|
+
f.ChordSymbol({ fontSize: 18 }).addGlyphOrText('C#').addGlyphOrText('7(#11b9)', superscript),
|
|
101
|
+
];
|
|
102
|
+
draw(chords, 240);
|
|
103
|
+
ok(true, 'Font Size Chord Symbol');
|
|
104
|
+
}
|
|
23
105
|
function fontSize(options) {
|
|
24
106
|
const f = VexFlowTests.makeFactory(options, 750, 580);
|
|
25
107
|
const ctx = f.getContext();
|
|
@@ -97,7 +179,7 @@ function fontSize(options) {
|
|
|
97
179
|
ok(true, 'Font Size Chord Symbol');
|
|
98
180
|
}
|
|
99
181
|
function kern(options) {
|
|
100
|
-
const f = VexFlowTests.makeFactory(options, 650, 650);
|
|
182
|
+
const f = VexFlowTests.makeFactory(options, 650 * 1.5, 650);
|
|
101
183
|
const ctx = f.getContext();
|
|
102
184
|
ctx.scale(1.5, 1.5);
|
|
103
185
|
ctx.fillStyle = '#221';
|
|
@@ -146,7 +228,7 @@ function kern(options) {
|
|
|
146
228
|
ok(true, 'Chord Symbol Kerning Tests');
|
|
147
229
|
}
|
|
148
230
|
function top(options) {
|
|
149
|
-
const f = VexFlowTests.makeFactory(options, 650, 650);
|
|
231
|
+
const f = VexFlowTests.makeFactory(options, 650 * 1.5, 650);
|
|
150
232
|
const ctx = f.getContext();
|
|
151
233
|
ctx.scale(1.5, 1.5);
|
|
152
234
|
ctx.fillStyle = '#221';
|
|
@@ -192,7 +274,7 @@ function top(options) {
|
|
|
192
274
|
ok(true, 'Top Chord Symbol');
|
|
193
275
|
}
|
|
194
276
|
function topJustify(options) {
|
|
195
|
-
const f = VexFlowTests.makeFactory(options, 500, 680);
|
|
277
|
+
const f = VexFlowTests.makeFactory(options, 500 * 1.5, 680);
|
|
196
278
|
const ctx = f.getContext();
|
|
197
279
|
ctx.scale(1.5, 1.5);
|
|
198
280
|
ctx.fillStyle = '#221';
|
|
@@ -234,7 +316,7 @@ function topJustify(options) {
|
|
|
234
316
|
ok(true, 'Top Chord Justified');
|
|
235
317
|
}
|
|
236
318
|
function bottom(options) {
|
|
237
|
-
const f = VexFlowTests.makeFactory(options, 600, 230);
|
|
319
|
+
const f = VexFlowTests.makeFactory(options, 600 * 1.5, 230);
|
|
238
320
|
const ctx = f.getContext();
|
|
239
321
|
ctx.scale(1.5, 1.5);
|
|
240
322
|
ctx.fillStyle = '#221';
|
|
@@ -259,7 +341,7 @@ function bottom(options) {
|
|
|
259
341
|
ok(true, 'Bottom Chord Symbol');
|
|
260
342
|
}
|
|
261
343
|
function bottomStemDown(options) {
|
|
262
|
-
const f = VexFlowTests.makeFactory(options, 600, 330);
|
|
344
|
+
const f = VexFlowTests.makeFactory(options, 600 * 1.5, 330);
|
|
263
345
|
const ctx = f.getContext();
|
|
264
346
|
ctx.scale(1.5, 1.5);
|
|
265
347
|
ctx.fillStyle = '#221';
|
|
@@ -285,19 +367,19 @@ function bottomStemDown(options) {
|
|
|
285
367
|
ok(true, 'Bottom Stem Down Chord Symbol');
|
|
286
368
|
}
|
|
287
369
|
function doubleBottom(options) {
|
|
288
|
-
const f = VexFlowTests.makeFactory(options, 600, 260);
|
|
370
|
+
const f = VexFlowTests.makeFactory(options, 600 * 1.5, 260);
|
|
289
371
|
const ctx = f.getContext();
|
|
290
372
|
ctx.scale(1.5, 1.5);
|
|
291
373
|
ctx.fillStyle = '#221';
|
|
292
374
|
ctx.strokeStyle = '#221';
|
|
293
375
|
function draw(chords, chords2, y) {
|
|
294
376
|
const note = (keys, duration, chordSymbol1, chordSymbol2) => new StaveNote({ keys, duration }).addModifier(chordSymbol1, 0).addModifier(chordSymbol2, 0);
|
|
295
|
-
const stave =
|
|
377
|
+
const stave = f.Stave({ x: 10, y, width: 450 }).addClef('treble').setContext(ctx).draw();
|
|
296
378
|
const notes = [
|
|
297
379
|
note(['c/4', 'f/4', 'a/4'], 'q', chords[0], chords2[0]),
|
|
298
|
-
note(['c/4', 'e/4', 'b/4'], 'q', chords[1], chords2[1]).addModifier(
|
|
380
|
+
note(['c/4', 'e/4', 'b/4'], 'q', chords[1], chords2[1]).addModifier(f.Accidental({ type: 'b' }), 2),
|
|
299
381
|
note(['c/4', 'e/4', 'g/4'], 'q', chords[2], chords2[2]),
|
|
300
|
-
note(['c/4', 'f/4', 'a/4'], 'q', chords[3], chords2[3]).addModifier(
|
|
382
|
+
note(['c/4', 'f/4', 'a/4'], 'q', chords[3], chords2[3]).addModifier(f.Accidental({ type: '#' }), 1),
|
|
301
383
|
];
|
|
302
384
|
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
303
385
|
}
|
|
@@ -92,83 +92,87 @@ function drawOrnamentsDisplaced(options, contextBuilder) {
|
|
|
92
92
|
notes[12].addModifier(new Ornament('prallprall'), 0);
|
|
93
93
|
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
94
94
|
}
|
|
95
|
-
const addDelayedTurns = (
|
|
96
|
-
const context =
|
|
97
|
-
const stave =
|
|
95
|
+
const addDelayedTurns = (f) => {
|
|
96
|
+
const context = f.getContext();
|
|
97
|
+
const stave = f.Stave({ x: 10, y: 30, width: 500 });
|
|
98
98
|
stave.setContext(context).draw();
|
|
99
99
|
const notes = [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
101
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
102
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
103
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
104
104
|
];
|
|
105
|
-
notes[0].addModifier(
|
|
106
|
-
notes[1].addModifier(
|
|
107
|
-
notes[2].addModifier(
|
|
108
|
-
notes[3].addModifier(
|
|
105
|
+
notes[0].addModifier(f.Ornament('turn', { delayed: true }), 0);
|
|
106
|
+
notes[1].addModifier(f.Ornament('turn_inverted', { delayed: true }), 0);
|
|
107
|
+
notes[2].addModifier(f.Ornament('turn_inverted', { delayed: true }), 0);
|
|
108
|
+
notes[3].addModifier(f.Ornament('turn', { delayed: true }), 0);
|
|
109
109
|
return { context, stave, notes };
|
|
110
110
|
};
|
|
111
|
-
function drawOrnamentsDelayed(options
|
|
111
|
+
function drawOrnamentsDelayed(options) {
|
|
112
112
|
expect(0);
|
|
113
|
-
const
|
|
113
|
+
const f = VexFlowTests.makeFactory(options, 550, 195);
|
|
114
|
+
const { context, stave, notes } = addDelayedTurns(f);
|
|
114
115
|
Formatter.FormatAndDraw(context, stave, notes);
|
|
115
116
|
}
|
|
116
|
-
function drawOrnamentsDelayedMultipleDraws(options
|
|
117
|
+
function drawOrnamentsDelayedMultipleDraws(options) {
|
|
117
118
|
expect(0);
|
|
118
|
-
const
|
|
119
|
+
const f = VexFlowTests.makeFactory(options, 550, 195);
|
|
120
|
+
const { context, stave, notes } = addDelayedTurns(f);
|
|
119
121
|
Formatter.FormatAndDraw(context, stave, notes);
|
|
120
122
|
Formatter.FormatAndDraw(context, stave, notes);
|
|
121
123
|
}
|
|
122
|
-
function drawOrnamentsStacked(options
|
|
124
|
+
function drawOrnamentsStacked(options) {
|
|
123
125
|
expect(0);
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
+
const f = VexFlowTests.makeFactory(options, 550, 195);
|
|
127
|
+
const ctx = f.getContext();
|
|
128
|
+
const stave = f.Stave({ x: 10, y: 30, width: 500 });
|
|
126
129
|
stave.setContext(ctx).draw();
|
|
127
130
|
const notes = [
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
132
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
133
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
134
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
132
135
|
];
|
|
133
|
-
notes[0].addModifier(
|
|
134
|
-
notes[1].addModifier(
|
|
135
|
-
notes[2].addModifier(
|
|
136
|
-
notes[3].addModifier(
|
|
137
|
-
notes[0].addModifier(
|
|
138
|
-
notes[1].addModifier(
|
|
139
|
-
notes[2].addModifier(
|
|
140
|
-
notes[3].addModifier(
|
|
136
|
+
notes[0].addModifier(f.Ornament('mordent'), 0);
|
|
137
|
+
notes[1].addModifier(f.Ornament('turn_inverted'), 0);
|
|
138
|
+
notes[2].addModifier(f.Ornament('turn'), 0);
|
|
139
|
+
notes[3].addModifier(f.Ornament('turn_inverted'), 0);
|
|
140
|
+
notes[0].addModifier(f.Ornament('turn'), 0);
|
|
141
|
+
notes[1].addModifier(f.Ornament('prallup'), 0);
|
|
142
|
+
notes[2].addModifier(f.Ornament('upmordent'), 0);
|
|
143
|
+
notes[3].addModifier(f.Ornament('lineprall'), 0);
|
|
141
144
|
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
142
145
|
}
|
|
143
|
-
function drawOrnamentsWithAccidentals(options
|
|
146
|
+
function drawOrnamentsWithAccidentals(options) {
|
|
144
147
|
expect(0);
|
|
145
|
-
const
|
|
146
|
-
const
|
|
148
|
+
const f = VexFlowTests.makeFactory(options, 650, 250);
|
|
149
|
+
const ctx = f.getContext();
|
|
150
|
+
const stave = f.Stave({ x: 10, y: 60, width: 600 });
|
|
147
151
|
stave.setContext(ctx).draw();
|
|
148
152
|
const notes = [
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
154
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
155
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
156
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
157
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
158
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
159
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
160
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
161
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
162
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
163
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
160
164
|
];
|
|
161
|
-
notes[0].addModifier(
|
|
162
|
-
notes[1].addModifier(
|
|
163
|
-
notes[2].addModifier(
|
|
164
|
-
notes[3].addModifier(
|
|
165
|
-
notes[4].addModifier(
|
|
166
|
-
notes[5].addModifier(
|
|
167
|
-
notes[6].addModifier(
|
|
168
|
-
notes[7].addModifier(
|
|
169
|
-
notes[8].addModifier(
|
|
170
|
-
notes[9].addModifier(
|
|
171
|
-
notes[10].addModifier(
|
|
165
|
+
notes[0].addModifier(f.Ornament('mordent', { lowerAccidental: '#', upperAccidental: '#' }), 0);
|
|
166
|
+
notes[1].addModifier(f.Ornament('turn_inverted', { lowerAccidental: 'b', upperAccidental: 'b' }), 0);
|
|
167
|
+
notes[2].addModifier(f.Ornament('turn', { upperAccidental: '##', lowerAccidental: '##' }), 0);
|
|
168
|
+
notes[3].addModifier(f.Ornament('mordent_inverted', { lowerAccidental: 'db', upperAccidental: 'db' }), 0);
|
|
169
|
+
notes[4].addModifier(f.Ornament('turn_inverted', { upperAccidental: '++', lowerAccidental: '++' }), 0);
|
|
170
|
+
notes[5].addModifier(f.Ornament('tr', { upperAccidental: 'n', lowerAccidental: 'n' }), 0);
|
|
171
|
+
notes[6].addModifier(f.Ornament('prallup', { upperAccidental: 'd', lowerAccidental: 'd' }), 0);
|
|
172
|
+
notes[7].addModifier(f.Ornament('lineprall', { upperAccidental: 'db', lowerAccidental: 'db' }), 0);
|
|
173
|
+
notes[8].addModifier(f.Ornament('upmordent', { upperAccidental: 'bbs', lowerAccidental: 'bbs' }), 0);
|
|
174
|
+
notes[9].addModifier(f.Ornament('prallprall', { upperAccidental: 'bb', lowerAccidental: 'bb' }), 0);
|
|
175
|
+
notes[10].addModifier(f.Ornament('turn_inverted', { upperAccidental: '+', lowerAccidental: '+' }), 0);
|
|
172
176
|
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
173
177
|
}
|
|
174
178
|
function jazzOrnaments(options) {
|
|
@@ -218,79 +222,79 @@ function jazzOrnaments(options) {
|
|
|
218
222
|
let curX = xStart;
|
|
219
223
|
let curY = yStart;
|
|
220
224
|
let mods = [
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
f.Ornament('scoop'),
|
|
226
|
+
f.Ornament('doit'),
|
|
227
|
+
f.Ornament('fall'),
|
|
228
|
+
f.Ornament('doitLong'),
|
|
225
229
|
];
|
|
226
230
|
draw(mods, ['a/5'], curX, width, curY, -1);
|
|
227
231
|
curX += width;
|
|
228
232
|
mods = [
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
233
|
+
f.Ornament('fallLong'),
|
|
234
|
+
f.Ornament('bend'),
|
|
235
|
+
f.Ornament('plungerClosed'),
|
|
236
|
+
f.Ornament('plungerOpen'),
|
|
237
|
+
f.Ornament('bend'),
|
|
234
238
|
];
|
|
235
239
|
draw(mods, ['a/5'], curX, width, curY, -1);
|
|
236
240
|
curX += width;
|
|
237
241
|
mods = [
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
f.Ornament('flip'),
|
|
243
|
+
f.Ornament('jazzTurn'),
|
|
244
|
+
f.Ornament('smear'),
|
|
245
|
+
f.Ornament('doit'),
|
|
242
246
|
];
|
|
243
247
|
draw(mods, ['a/5'], curX, width, curY, 1);
|
|
244
248
|
curX = xStart;
|
|
245
249
|
curY += staffHeight;
|
|
246
250
|
mods = [
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
+
f.Ornament('scoop'),
|
|
252
|
+
f.Ornament('doit'),
|
|
253
|
+
f.Ornament('fall'),
|
|
254
|
+
f.Ornament('doitLong'),
|
|
251
255
|
];
|
|
252
256
|
draw(mods, ['e/5'], curX, width, curY);
|
|
253
257
|
curX += width;
|
|
254
258
|
mods = [
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
259
|
+
f.Ornament('fallLong'),
|
|
260
|
+
f.Ornament('bend'),
|
|
261
|
+
f.Ornament('plungerClosed'),
|
|
262
|
+
f.Ornament('plungerOpen'),
|
|
263
|
+
f.Ornament('bend'),
|
|
260
264
|
];
|
|
261
265
|
draw(mods, ['e/5'], curX, width, curY);
|
|
262
266
|
curX += width;
|
|
263
267
|
mods = [
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
+
f.Ornament('flip'),
|
|
269
|
+
f.Ornament('jazzTurn'),
|
|
270
|
+
f.Ornament('smear'),
|
|
271
|
+
f.Ornament('doit'),
|
|
268
272
|
];
|
|
269
273
|
draw(mods, ['e/5'], curX, width, curY);
|
|
270
274
|
curX = xStart;
|
|
271
275
|
curY += staffHeight;
|
|
272
276
|
mods = [
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
+
f.Ornament('scoop'),
|
|
278
|
+
f.Ornament('doit'),
|
|
279
|
+
f.Ornament('fall'),
|
|
280
|
+
f.Ornament('doitLong'),
|
|
277
281
|
];
|
|
278
282
|
draw(mods, ['e/4'], curX, width, curY);
|
|
279
283
|
curX += width;
|
|
280
284
|
mods = [
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
285
|
+
f.Ornament('fallLong'),
|
|
286
|
+
f.Ornament('bend'),
|
|
287
|
+
f.Ornament('plungerClosed'),
|
|
288
|
+
f.Ornament('plungerOpen'),
|
|
289
|
+
f.Ornament('bend'),
|
|
286
290
|
];
|
|
287
291
|
draw(mods, ['e/4'], curX, width, curY);
|
|
288
292
|
curX += width;
|
|
289
293
|
mods = [
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
+
f.Ornament('flip'),
|
|
295
|
+
f.Ornament('jazzTurn'),
|
|
296
|
+
f.Ornament('smear'),
|
|
297
|
+
f.Ornament('doit'),
|
|
294
298
|
];
|
|
295
299
|
draw(mods, ['e/4'], curX, width, curY);
|
|
296
300
|
}
|
|
@@ -49,6 +49,7 @@ const StaveNoteTests = {
|
|
|
49
49
|
run('Beam and Dot Placement - Stem Up', dotsAndBeamsUp);
|
|
50
50
|
run('Beam and Dot Placement - Stem Down', dotsAndBeamsDown);
|
|
51
51
|
run('Note Heads Placement - Simple', noteHeadsSimple);
|
|
52
|
+
run('Note Heads Placement - Hidden Notes', noteHeadsHidden);
|
|
52
53
|
run('Center Aligned Note', centerAlignedRest);
|
|
53
54
|
run('Center Aligned Note with Articulation', centerAlignedRestFermata);
|
|
54
55
|
run('Center Aligned Note with Annotation', centerAlignedRestAnnotation);
|
|
@@ -785,6 +786,41 @@ function noteHeadsSimple(options) {
|
|
|
785
786
|
vf.draw();
|
|
786
787
|
expect(0);
|
|
787
788
|
}
|
|
789
|
+
function noteHeadsHidden(options) {
|
|
790
|
+
const vf = VexFlowTests.makeFactory(options, 800, 250);
|
|
791
|
+
const score = vf.EasyScore();
|
|
792
|
+
const system1 = vf.System({ y: 100, x: 50, width: 200 });
|
|
793
|
+
const notes1 = score.notes('g4/w');
|
|
794
|
+
notes1[0].render_options.draw = false;
|
|
795
|
+
system1
|
|
796
|
+
.addStave({
|
|
797
|
+
voices: [
|
|
798
|
+
score.voice([...score.beam(score.notes('a4/8, b4/8', { stem: 'up' })), ...score.notes('a4/q/r, a4/h/r')]),
|
|
799
|
+
score.voice(notes1),
|
|
800
|
+
],
|
|
801
|
+
})
|
|
802
|
+
.addClef('treble')
|
|
803
|
+
.addTimeSignature('4/4');
|
|
804
|
+
const system2 = vf.System({ y: 100, x: 250, width: 150 });
|
|
805
|
+
const notes2 = score.notes('b4/w');
|
|
806
|
+
notes2[0].render_options.draw = false;
|
|
807
|
+
system2.addStave({
|
|
808
|
+
voices: [score.voice(score.notes('b4/h, b4/h/r')), score.voice(notes2)],
|
|
809
|
+
});
|
|
810
|
+
const system3 = vf.System({ y: 100, x: 400, width: 150 });
|
|
811
|
+
system3.addStave({
|
|
812
|
+
voices: [score.voice(score.notes('d5/h, d5/h/r')), score.voice(score.notes('e4/w'))],
|
|
813
|
+
});
|
|
814
|
+
const system4 = vf.System({ y: 100, x: 550, width: 150 });
|
|
815
|
+
const notes4 = score.notes('e4/q, e4/q/r, e4/h/r');
|
|
816
|
+
notes4[0].render_options.draw = false;
|
|
817
|
+
notes4[2].render_options.draw = false;
|
|
818
|
+
system4.addStave({
|
|
819
|
+
voices: [score.voice(notes4), score.voice(score.notes('e4/8, e4/8/r, e4/q/r, e4/h/r'))],
|
|
820
|
+
});
|
|
821
|
+
vf.draw();
|
|
822
|
+
expect(0);
|
|
823
|
+
}
|
|
788
824
|
function centerAlignedRest(options) {
|
|
789
825
|
const f = VexFlowTests.makeFactory(options, 400, 160);
|
|
790
826
|
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addClef('treble').addTimeSignature('4/4');
|
|
@@ -9,36 +9,38 @@ const StringNumberTests = {
|
|
|
9
9
|
QUnit.module('StringNumber');
|
|
10
10
|
const run = VexFlowTests.runTests;
|
|
11
11
|
run('String Number In Notation', drawMultipleMeasures);
|
|
12
|
+
run('String Number In Notation - no circle', drawMultipleMeasures, { drawCircle: false });
|
|
12
13
|
run('Fret Hand Finger In Notation', drawFretHandFingers);
|
|
13
14
|
run('Multi Voice With Strokes, String & Finger Numbers', multi);
|
|
14
15
|
run('Complex Measure With String & Finger Numbers', drawAccidentals);
|
|
15
16
|
},
|
|
16
17
|
};
|
|
17
18
|
function drawMultipleMeasures(options) {
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
18
20
|
const f = VexFlowTests.makeFactory(options, 775, 200);
|
|
19
21
|
const score = f.EasyScore();
|
|
20
22
|
const stave1 = f.Stave({ width: 300 }).setEndBarType(BarlineType.DOUBLE).addClef('treble');
|
|
21
23
|
const notes1 = score.notes('(c4 e4 g4)/4., (c5 e5 g5)/8, (c4 f4 g4)/4, (c4 f4 g4)/4', { stem: 'down' });
|
|
22
24
|
notes1[0]
|
|
23
|
-
.addModifier(f.StringNumber({ number: '5', position: 'right' }), 0)
|
|
24
|
-
.addModifier(f.StringNumber({ number: '4', position: 'left' }), 1)
|
|
25
|
-
.addModifier(f.StringNumber({ number: '3', position: 'right' }), 2);
|
|
25
|
+
.addModifier(f.StringNumber({ number: '5', position: 'right' }, (_a = options.params) === null || _a === void 0 ? void 0 : _a.drawCircle), 0)
|
|
26
|
+
.addModifier(f.StringNumber({ number: '4', position: 'left' }, (_b = options.params) === null || _b === void 0 ? void 0 : _b.drawCircle), 1)
|
|
27
|
+
.addModifier(f.StringNumber({ number: '3', position: 'right' }, (_c = options.params) === null || _c === void 0 ? void 0 : _c.drawCircle), 2);
|
|
26
28
|
notes1[1]
|
|
27
29
|
.addModifier(f.Accidental({ type: '#' }), 0)
|
|
28
|
-
.addModifier(f.StringNumber({ number: '5', position: 'below' }), 0)
|
|
30
|
+
.addModifier(f.StringNumber({ number: '5', position: 'below' }, (_d = options.params) === null || _d === void 0 ? void 0 : _d.drawCircle), 0)
|
|
29
31
|
.addModifier(f.Accidental({ type: '#' }).setAsCautionary(), 1)
|
|
30
32
|
.addModifier(f
|
|
31
|
-
.StringNumber({ number: '3', position: 'above' })
|
|
33
|
+
.StringNumber({ number: '3', position: 'above' }, (_e = options.params) === null || _e === void 0 ? void 0 : _e.drawCircle)
|
|
32
34
|
.setLastNote(notes1[3])
|
|
33
35
|
.setLineEndType(Renderer.LineEndType.DOWN), 2);
|
|
34
36
|
notes1[2]
|
|
35
|
-
.addModifier(f.StringNumber({ number: '5', position: 'left' }), 0)
|
|
36
|
-
.addModifier(f.StringNumber({ number: '3', position: 'left' }), 2)
|
|
37
|
+
.addModifier(f.StringNumber({ number: '5', position: 'left' }, (_f = options.params) === null || _f === void 0 ? void 0 : _f.drawCircle), 0)
|
|
38
|
+
.addModifier(f.StringNumber({ number: '3', position: 'left' }, (_g = options.params) === null || _g === void 0 ? void 0 : _g.drawCircle), 2)
|
|
37
39
|
.addModifier(f.Accidental({ type: '#' }), 1);
|
|
38
40
|
notes1[3]
|
|
39
|
-
.addModifier(f.StringNumber({ number: '5', position: 'right' }).setOffsetY(7), 0)
|
|
40
|
-
.addModifier(f.StringNumber({ number: '4', position: 'right' }).setOffsetY(6), 1)
|
|
41
|
-
.addModifier(f.StringNumber({ number: '3', position: 'right' }).setOffsetY(-6), 2);
|
|
41
|
+
.addModifier(f.StringNumber({ number: '5', position: 'right' }, (_h = options.params) === null || _h === void 0 ? void 0 : _h.drawCircle).setOffsetY(7), 0)
|
|
42
|
+
.addModifier(f.StringNumber({ number: '4', position: 'right' }, (_j = options.params) === null || _j === void 0 ? void 0 : _j.drawCircle).setOffsetY(6), 1)
|
|
43
|
+
.addModifier(f.StringNumber({ number: '3', position: 'right' }, (_k = options.params) === null || _k === void 0 ? void 0 : _k.drawCircle).setOffsetY(-6), 2);
|
|
42
44
|
const voice1 = score.voice(notes1);
|
|
43
45
|
f.Formatter().joinVoices([voice1]).formatToStave([voice1], stave1);
|
|
44
46
|
const stave2 = f
|
|
@@ -46,21 +48,24 @@ function drawMultipleMeasures(options) {
|
|
|
46
48
|
.setEndBarType(BarlineType.DOUBLE);
|
|
47
49
|
const notes2 = score.notes('(c4 e4 g4)/4, (c5 e5 g5), (c4 f4 g4), (c4 f4 g4)', { stem: 'up' });
|
|
48
50
|
notes2[0]
|
|
49
|
-
.addModifier(f.StringNumber({ number: '5', position: 'right' }), 0)
|
|
50
|
-
.addModifier(f.StringNumber({ number: '4', position: 'left' }), 1)
|
|
51
|
-
.addModifier(f.StringNumber({ number: '3', position: 'right' }), 2);
|
|
51
|
+
.addModifier(f.StringNumber({ number: '5', position: 'right' }, (_l = options.params) === null || _l === void 0 ? void 0 : _l.drawCircle), 0)
|
|
52
|
+
.addModifier(f.StringNumber({ number: '4', position: 'left' }, (_m = options.params) === null || _m === void 0 ? void 0 : _m.drawCircle), 1)
|
|
53
|
+
.addModifier(f.StringNumber({ number: '3', position: 'right' }, (_o = options.params) === null || _o === void 0 ? void 0 : _o.drawCircle), 2);
|
|
52
54
|
notes2[1]
|
|
53
55
|
.addModifier(f.Accidental({ type: '#' }), 0)
|
|
54
|
-
.addModifier(f.StringNumber({ number: '5', position: 'below' }), 0)
|
|
56
|
+
.addModifier(f.StringNumber({ number: '5', position: 'below' }, (_p = options.params) === null || _p === void 0 ? void 0 : _p.drawCircle), 0)
|
|
55
57
|
.addModifier(f.Accidental({ type: '#' }), 1)
|
|
56
|
-
.addModifier(f
|
|
58
|
+
.addModifier(f
|
|
59
|
+
.StringNumber({ number: '3', position: 'above' }, (_q = options.params) === null || _q === void 0 ? void 0 : _q.drawCircle)
|
|
60
|
+
.setLastNote(notes2[3])
|
|
61
|
+
.setDashed(false), 2);
|
|
57
62
|
notes2[2]
|
|
58
|
-
.addModifier(f.StringNumber({ number: '3', position: 'left' }), 2)
|
|
63
|
+
.addModifier(f.StringNumber({ number: '3', position: 'left' }, (_r = options.params) === null || _r === void 0 ? void 0 : _r.drawCircle), 2)
|
|
59
64
|
.addModifier(f.Accidental({ type: '#' }), 1);
|
|
60
65
|
notes2[3]
|
|
61
|
-
.addModifier(f.StringNumber({ number: '5', position: 'right' }).setOffsetY(7), 0)
|
|
62
|
-
.addModifier(f.StringNumber({ number: '4', position: 'right' }).setOffsetY(6), 1)
|
|
63
|
-
.addModifier(f.StringNumber({ number: '3', position: 'right' }).setOffsetY(-6), 2);
|
|
66
|
+
.addModifier(f.StringNumber({ number: '5', position: 'right' }, (_s = options.params) === null || _s === void 0 ? void 0 : _s.drawCircle).setOffsetY(7), 0)
|
|
67
|
+
.addModifier(f.StringNumber({ number: '4', position: 'right' }, (_t = options.params) === null || _t === void 0 ? void 0 : _t.drawCircle).setOffsetY(6), 1)
|
|
68
|
+
.addModifier(f.StringNumber({ number: '3', position: 'right' }, (_u = options.params) === null || _u === void 0 ? void 0 : _u.drawCircle).setOffsetY(-6), 2);
|
|
64
69
|
const voice2 = score.voice(notes2);
|
|
65
70
|
f.Formatter().joinVoices([voice2]).formatToStave([voice2], stave2);
|
|
66
71
|
const stave3 = f
|
|
@@ -68,10 +73,10 @@ function drawMultipleMeasures(options) {
|
|
|
68
73
|
.setEndBarType(BarlineType.END);
|
|
69
74
|
const notesBar3 = score.notes('(c4 e4 g4 a4)/1.');
|
|
70
75
|
notesBar3[0]
|
|
71
|
-
.addModifier(f.StringNumber({ number: '5', position: 'below' }), 0)
|
|
72
|
-
.addModifier(f.StringNumber({ number: '4', position: 'right' }), 1)
|
|
73
|
-
.addModifier(f.StringNumber({ number: '3', position: 'left' }), 2)
|
|
74
|
-
.addModifier(f.StringNumber({ number: '2', position: 'above' }), 3);
|
|
76
|
+
.addModifier(f.StringNumber({ number: '5', position: 'below' }, (_v = options.params) === null || _v === void 0 ? void 0 : _v.drawCircle), 0)
|
|
77
|
+
.addModifier(f.StringNumber({ number: '4', position: 'right' }, (_w = options.params) === null || _w === void 0 ? void 0 : _w.drawCircle), 1)
|
|
78
|
+
.addModifier(f.StringNumber({ number: '3', position: 'left' }, (_x = options.params) === null || _x === void 0 ? void 0 : _x.drawCircle), 2)
|
|
79
|
+
.addModifier(f.StringNumber({ number: '2', position: 'above' }, (_y = options.params) === null || _y === void 0 ? void 0 : _y.drawCircle), 3);
|
|
75
80
|
const voice3 = score.voice(notesBar3, { time: '6/4' });
|
|
76
81
|
f.Formatter().joinVoices([voice3]).formatToStave([voice3], stave3);
|
|
77
82
|
f.draw();
|
|
@@ -67,6 +67,7 @@ export declare class ChordSymbol extends Modifier {
|
|
|
67
67
|
static get upperKerningText(): string[];
|
|
68
68
|
static isSuperscript(block: ChordSymbolBlock): boolean;
|
|
69
69
|
static isSubscript(block: ChordSymbolBlock): boolean;
|
|
70
|
+
static get minPadding(): number;
|
|
70
71
|
/**
|
|
71
72
|
* Estimate the width of the whole chord symbol, based on the sum of the widths of the individual blocks.
|
|
72
73
|
* Estimate how many lines above/below the staff we need.
|
|
@@ -53,6 +53,7 @@ export interface ElementStyle {
|
|
|
53
53
|
*/
|
|
54
54
|
export declare abstract class Element {
|
|
55
55
|
static get CATEGORY(): string;
|
|
56
|
+
protected children: Element[];
|
|
56
57
|
protected static ID: number;
|
|
57
58
|
protected static newID(): string;
|
|
58
59
|
/**
|
|
@@ -73,7 +74,7 @@ export declare abstract class Element {
|
|
|
73
74
|
*/
|
|
74
75
|
protected textFont?: Required<FontInfo>;
|
|
75
76
|
constructor();
|
|
76
|
-
|
|
77
|
+
addChildElement(child: Element): this;
|
|
77
78
|
getCategory(): string;
|
|
78
79
|
/**
|
|
79
80
|
* Set the element style used to render.
|
|
@@ -98,6 +99,8 @@ export declare abstract class Element {
|
|
|
98
99
|
* ```
|
|
99
100
|
*/
|
|
100
101
|
setStyle(style: ElementStyle): this;
|
|
102
|
+
/** Set the element & associated children style used for rendering. */
|
|
103
|
+
setGroupStyle(style: ElementStyle): this;
|
|
101
104
|
/** Get the element style used for rendering. */
|
|
102
105
|
getStyle(): ElementStyle | undefined;
|
|
103
106
|
/** Apply the element style to `context`. */
|