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.
Files changed (122) hide show
  1. package/README.md +6 -6
  2. package/build/cjs/vexflow-bravura.js +2 -2
  3. package/build/cjs/vexflow-bravura.js.map +1 -1
  4. package/build/cjs/vexflow-core.js +2 -2
  5. package/build/cjs/vexflow-core.js.map +1 -1
  6. package/build/cjs/vexflow-debug-with-tests.js +1546 -1393
  7. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  8. package/build/cjs/vexflow-debug.js +600 -549
  9. package/build/cjs/vexflow-debug.js.map +1 -1
  10. package/build/cjs/vexflow.js +2 -2
  11. package/build/cjs/vexflow.js.map +1 -1
  12. package/build/esm/src/annotation.js +0 -2
  13. package/build/esm/src/barnote.js +3 -3
  14. package/build/esm/src/beam.js +2 -4
  15. package/build/esm/src/bend.js +11 -3
  16. package/build/esm/src/chordsymbol.js +0 -4
  17. package/build/esm/src/clef.js +0 -2
  18. package/build/esm/src/curve.js +8 -5
  19. package/build/esm/src/element.js +11 -17
  20. package/build/esm/src/factory.js +4 -4
  21. package/build/esm/src/flag.js +20 -0
  22. package/build/esm/src/formatter.js +4 -4
  23. package/build/esm/src/glyphnote.js +0 -2
  24. package/build/esm/src/gracenote.js +0 -2
  25. package/build/esm/src/gracenotegroup.js +17 -8
  26. package/build/esm/src/index.js +1 -0
  27. package/build/esm/src/keysignature.js +38 -31
  28. package/build/esm/src/keysignote.js +1 -1
  29. package/build/esm/src/metrics.js +55 -7
  30. package/build/esm/src/modifier.js +4 -2
  31. package/build/esm/src/notehead.js +6 -1
  32. package/build/esm/src/ornament.js +0 -2
  33. package/build/esm/src/pedalmarking.js +33 -41
  34. package/build/esm/src/stave.js +10 -16
  35. package/build/esm/src/stavebarline.js +2 -3
  36. package/build/esm/src/stavehairpin.js +1 -1
  37. package/build/esm/src/staveline.js +0 -4
  38. package/build/esm/src/stavemodifier.js +0 -2
  39. package/build/esm/src/stavenote.js +16 -28
  40. package/build/esm/src/staverepetition.js +3 -2
  41. package/build/esm/src/stavesection.js +13 -15
  42. package/build/esm/src/stavetempo.js +3 -2
  43. package/build/esm/src/stavetext.js +2 -2
  44. package/build/esm/src/stavetie.js +0 -4
  45. package/build/esm/src/stavevolta.js +3 -2
  46. package/build/esm/src/stem.js +0 -4
  47. package/build/esm/src/stemmablenote.js +5 -6
  48. package/build/esm/src/stringnumber.js +0 -2
  49. package/build/esm/src/svgcontext.js +0 -1
  50. package/build/esm/src/tabnote.js +2 -8
  51. package/build/esm/src/textbracket.js +0 -3
  52. package/build/esm/src/textnote.js +0 -2
  53. package/build/esm/src/timesignature.js +2 -4
  54. package/build/esm/src/timesignote.js +2 -0
  55. package/build/esm/src/tuplet.js +37 -30
  56. package/build/esm/src/version.js +3 -3
  57. package/build/esm/src/vexflow.js +6 -2
  58. package/build/esm/tests/accidental_tests.js +30 -17
  59. package/build/esm/tests/annotation_tests.js +12 -12
  60. package/build/esm/tests/articulation_tests.js +13 -13
  61. package/build/esm/tests/auto_beam_formatting_tests.js +33 -33
  62. package/build/esm/tests/beam_tests.js +1 -1
  63. package/build/esm/tests/bend_tests.js +7 -7
  64. package/build/esm/tests/chordsymbol_tests.js +8 -8
  65. package/build/esm/tests/curve_tests.js +34 -0
  66. package/build/esm/tests/{bach_tests.js → demo_petzold_tests.js} +7 -7
  67. package/build/esm/tests/dot_tests.js +4 -4
  68. package/build/esm/tests/formatter_tests.js +25 -25
  69. package/build/esm/tests/gracenote_tests.js +2 -1
  70. package/build/esm/tests/gracetabnote_tests.js +1 -1
  71. package/build/esm/tests/index.js +1 -1
  72. package/build/esm/tests/key_clef_tests.js +6 -6
  73. package/build/esm/tests/keysignature_tests.js +20 -17
  74. package/build/esm/tests/notehead_tests.js +10 -7
  75. package/build/esm/tests/offscreencanvas_tests.js +1 -1
  76. package/build/esm/tests/ornament_tests.js +8 -8
  77. package/build/esm/tests/pedalmarking_tests.js +27 -0
  78. package/build/esm/tests/percussion_tests.js +6 -3
  79. package/build/esm/tests/renderer_tests.js +1 -1
  80. package/build/esm/tests/rests_tests.js +26 -26
  81. package/build/esm/tests/rhythm_tests.js +15 -15
  82. package/build/esm/tests/stave_tests.js +44 -43
  83. package/build/esm/tests/staveconnector_tests.js +73 -73
  84. package/build/esm/tests/stavehairpin_tests.js +1 -1
  85. package/build/esm/tests/stavemodifier_tests.js +3 -3
  86. package/build/esm/tests/stavenote_tests.js +29 -29
  87. package/build/esm/tests/stringnumber_tests.js +1 -1
  88. package/build/esm/tests/strokes_tests.js +1 -1
  89. package/build/esm/tests/style_tests.js +1 -1
  90. package/build/esm/tests/tabnote_tests.js +7 -7
  91. package/build/esm/tests/tabslide_tests.js +6 -6
  92. package/build/esm/tests/tabstave_tests.js +1 -1
  93. package/build/esm/tests/tabtie_tests.js +8 -8
  94. package/build/esm/tests/textnote_tests.js +1 -1
  95. package/build/esm/tests/threevoice_tests.js +2 -2
  96. package/build/esm/tests/timesignature_tests.js +23 -13
  97. package/build/esm/tests/vibrato_tests.js +3 -3
  98. package/build/esm/tests/voice_tests.js +1 -1
  99. package/build/types/src/bend.d.ts +6 -0
  100. package/build/types/src/curve.d.ts +5 -4
  101. package/build/types/src/element.d.ts +10 -11
  102. package/build/types/src/factory.d.ts +2 -2
  103. package/build/types/src/flag.d.ts +12 -0
  104. package/build/types/src/frethandfinger.d.ts +1 -1
  105. package/build/types/src/index.d.ts +1 -0
  106. package/build/types/src/keysignature.d.ts +7 -7
  107. package/build/types/src/metrics.d.ts +5 -0
  108. package/build/types/src/modifier.d.ts +1 -1
  109. package/build/types/src/pedalmarking.d.ts +2 -2
  110. package/build/types/src/stave.d.ts +1 -3
  111. package/build/types/src/stavebarline.d.ts +1 -1
  112. package/build/types/src/staveline.d.ts +1 -1
  113. package/build/types/src/stavemodifier.d.ts +0 -1
  114. package/build/types/src/staverepetition.d.ts +1 -1
  115. package/build/types/src/stavesection.d.ts +3 -4
  116. package/build/types/src/stavetempo.d.ts +1 -2
  117. package/build/types/src/stavetext.d.ts +1 -2
  118. package/build/types/src/stavevolta.d.ts +1 -2
  119. package/build/types/src/stemmablenote.d.ts +2 -3
  120. package/build/types/src/tuplet.d.ts +2 -12
  121. package/build/types/src/typeguard.d.ts +1 -0
  122. package/package.json +32 -28
@@ -5,6 +5,8 @@ const CurveTests = {
5
5
  QUnit.module('Curve');
6
6
  const run = VexFlowTests.runTests;
7
7
  run('Simple Curve', simple);
8
+ run('Opening Direction - up', openingDirUp);
9
+ run('Opening Direction - down', openingDirDown);
8
10
  run('Rounded Curve', rounded);
9
11
  run('Thick Thin Curves', thickThin);
10
12
  run('Top Curve', top);
@@ -48,6 +50,38 @@ const simple = createTest(['c4/8, f5, d5, g5', { stem: 'up' }], ['d6/8, f5, d5,
48
50
  },
49
51
  }).setStyle({ lineDash: '10 10' });
50
52
  });
53
+ const openingDirUp = createTest(['c4/8, f5, d5, g5', { stem: 'up' }], ['d6/8, f5, d5, g5', { stem: 'down' }], (f, notes) => {
54
+ f.Curve({
55
+ from: notes[0],
56
+ to: notes[3],
57
+ options: {
58
+ openingDirection: 'up',
59
+ },
60
+ });
61
+ f.Curve({
62
+ from: notes[4],
63
+ to: notes[7],
64
+ options: {
65
+ openingDirection: 'up',
66
+ },
67
+ });
68
+ });
69
+ const openingDirDown = createTest(['c4/8, f5, d5, g5', { stem: 'up' }], ['d6/8, f5, d5, g5', { stem: 'down' }], (f, notes) => {
70
+ f.Curve({
71
+ from: notes[0],
72
+ to: notes[3],
73
+ options: {
74
+ openingDirection: 'down',
75
+ },
76
+ });
77
+ f.Curve({
78
+ from: notes[4],
79
+ to: notes[7],
80
+ options: {
81
+ openingDirection: 'down',
82
+ },
83
+ });
84
+ });
51
85
  const rounded = createTest(['c5/8, f4, d4, g5', { stem: 'up' }], ['d5/8, d6, d6, g5', { stem: 'down' }], (f, notes) => {
52
86
  f.Curve({
53
87
  from: notes[0],
@@ -1,12 +1,12 @@
1
1
  import { concat, VexFlowTests } from './vexflow_test_helpers.js';
2
2
  import { BarlineType, Registry } from '../src/index.js';
3
- const BachDemoTests = {
3
+ const DemoPetzoldTests = {
4
4
  Start() {
5
- QUnit.module('Bach Demo');
6
- VexFlowTests.runTests('Minuet 1', minuet1);
5
+ QUnit.module('Demo - Petzold');
6
+ VexFlowTests.runTests('Minuet in G', minuetInG);
7
7
  },
8
8
  };
9
- function minuet1(options) {
9
+ function minuetInG(options) {
10
10
  const registry = new Registry();
11
11
  Registry.enableDefaultRegistry(registry);
12
12
  const id = (id) => registry.getElementById(id);
@@ -329,7 +329,7 @@ function minuet1(options) {
329
329
  });
330
330
  f.draw();
331
331
  Registry.disableDefaultRegistry();
332
- options.assert.ok(true, 'Bach Minuet 1');
332
+ options.assert.ok(true, 'Petzold Minuet in G');
333
333
  }
334
- VexFlowTests.register(BachDemoTests);
335
- export { BachDemoTests };
334
+ VexFlowTests.register(DemoPetzoldTests);
335
+ export { DemoPetzoldTests };
@@ -20,14 +20,14 @@ function showOneNote(note1, stave, ctx, x) {
20
20
  const modifierContext = new ModifierContext();
21
21
  note1.setStave(stave).addToModifierContext(modifierContext);
22
22
  new TickContext().addTickable(note1).preFormat().setX(x);
23
- note1.setContext(ctx).draw();
23
+ note1.setContext(ctx).drawWithStyle();
24
24
  Note.plotMetrics(ctx, note1, 140);
25
25
  }
26
26
  function basic(options, contextBuilder) {
27
27
  const ctx = contextBuilder(options.elementId, 1000, 240);
28
28
  const stave = new Stave(10, 10, 975);
29
29
  stave.setContext(ctx);
30
- stave.draw();
30
+ stave.drawWithStyle();
31
31
  const notes = [
32
32
  new StaveNote({ keys: ['c/4', 'e/4', 'a/4', 'b/4'], duration: 'w' }),
33
33
  new StaveNote({ keys: ['a/4', 'b/4', 'c/5'], duration: '4', stemDirection: 1 }),
@@ -71,13 +71,13 @@ function basic(options, contextBuilder) {
71
71
  options.assert.ok(dots[j].getWidth() > 0, 'Dot ' + j + ' has width set');
72
72
  }
73
73
  }
74
- beam.setContext(ctx).draw();
74
+ beam.setContext(ctx).drawWithStyle();
75
75
  VexFlowTests.plotLegendForNoteWidth(ctx, 890, 140);
76
76
  options.assert.ok(true, 'Full Dot');
77
77
  }
78
78
  function multiVoice(options, contextBuilder) {
79
79
  const ctx = contextBuilder(options.elementId, 750, 300);
80
- const stave = new Stave(30, 45, 700).setContext(ctx).draw();
80
+ const stave = new Stave(30, 45, 700).setContext(ctx).drawWithStyle();
81
81
  const notes1 = [
82
82
  new StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: '2', stemDirection: -1 }),
83
83
  new StaveNote({ keys: ['c/4', 'e/4', 'c/5'], duration: '2', stemDirection: -1 }),
@@ -102,7 +102,7 @@ function rightJustify(options) {
102
102
  const stave = f.Stave({ x, y: 20, width });
103
103
  const voice = getTickables(time, n, duration, duration2);
104
104
  formatter.joinVoices([voice]).formatToStave([voice], stave);
105
- stave.draw();
105
+ stave.drawWithStyle();
106
106
  voice.draw(f.getContext(), stave);
107
107
  };
108
108
  renderTest({ numBeats: 4, beatValue: 4, resolution: 4 * 4096 }, 3, '4', '2', 10, 300);
@@ -178,11 +178,11 @@ function noteHeadPadding(options) {
178
178
  const staveWidth = width + Stave.defaultPadding;
179
179
  const stave1 = f.Stave({ y: 50, width: staveWidth });
180
180
  const stave2 = f.Stave({ y: 150, width: staveWidth });
181
- stave1.draw();
182
- stave2.draw();
181
+ stave1.drawWithStyle();
182
+ stave2.drawWithStyle();
183
183
  voice1.draw(f.getContext(), stave1);
184
184
  voice2.draw(f.getContext(), stave2);
185
- beams.forEach((b) => b.setContext(f.getContext()).draw());
185
+ beams.forEach((b) => b.setContext(f.getContext()).drawWithStyle());
186
186
  options.assert.ok(true);
187
187
  }
188
188
  function longMeasureProblems(options) {
@@ -202,8 +202,8 @@ function longMeasureProblems(options) {
202
202
  formatter.format([voice1, voice2], width);
203
203
  const stave1 = f.Stave({ y: 50, width: width + Stave.defaultPadding });
204
204
  const stave2 = f.Stave({ y: 200, width: width + Stave.defaultPadding });
205
- stave1.draw();
206
- stave2.draw();
205
+ stave1.drawWithStyle();
206
+ stave2.drawWithStyle();
207
207
  voice1.draw(f.getContext(), stave1);
208
208
  voice2.draw(f.getContext(), stave2);
209
209
  options.assert.ok(true);
@@ -224,11 +224,11 @@ function accidentalJustification(options) {
224
224
  const stave21 = f.Stave({ y: 130, width: width + Stave.defaultPadding });
225
225
  formatter.format([voice11, voice21], width);
226
226
  const ctx = f.getContext();
227
- stave11.setContext(ctx).draw();
228
- stave21.setContext(ctx).draw();
227
+ stave11.setContext(ctx).drawWithStyle();
228
+ stave21.setContext(ctx).drawWithStyle();
229
229
  voice11.draw(ctx, stave11);
230
230
  voice21.draw(ctx, stave21);
231
- beams.forEach((b) => b.setContext(ctx).draw());
231
+ beams.forEach((b) => b.setContext(ctx).drawWithStyle());
232
232
  options.assert.ok(true);
233
233
  }
234
234
  function unalignedNoteDurations1(options) {
@@ -257,12 +257,12 @@ function unalignedNoteDurations1(options) {
257
257
  const stave11 = f.Stave({ y: 20, width: width + Stave.defaultPadding });
258
258
  const stave21 = f.Stave({ y: 130, width: width + Stave.defaultPadding });
259
259
  formatter.format([voice11, voice21], width);
260
- stave11.setContext(ctx).draw();
261
- stave21.setContext(ctx).draw();
260
+ stave11.setContext(ctx).drawWithStyle();
261
+ stave21.setContext(ctx).drawWithStyle();
262
262
  voice11.draw(ctx, stave11);
263
263
  voice21.draw(ctx, stave21);
264
- beams21.forEach((b) => b.setContext(ctx).draw());
265
- beams11.forEach((b) => b.setContext(ctx).draw());
264
+ beams21.forEach((b) => b.setContext(ctx).drawWithStyle());
265
+ beams11.forEach((b) => b.setContext(ctx).drawWithStyle());
266
266
  options.assert.ok(voice11.getTickables()[1].getX() > voice21.getTickables()[1].getX());
267
267
  }
268
268
  function unalignedNoteDurations2(options) {
@@ -303,8 +303,8 @@ function unalignedNoteDurations2(options) {
303
303
  formatter.format([voice1, voice2], width);
304
304
  const stave1 = new Stave(10, 40, width + Stave.defaultPadding);
305
305
  const stave2 = new Stave(10, 100, width + Stave.defaultPadding);
306
- stave1.setContext(context).draw();
307
- stave2.setContext(context).draw();
306
+ stave1.setContext(context).drawWithStyle();
307
+ stave2.setContext(context).drawWithStyle();
308
308
  voice1.draw(context, stave1);
309
309
  voice2.draw(context, stave2);
310
310
  options.assert.ok(voice1.getTickables()[1].getX() > voice2.getTickables()[1].getX());
@@ -355,10 +355,10 @@ function alignedMixedElements(options) {
355
355
  const tuplet2 = new Tuplet(notes2).setTupletLocation(1);
356
356
  Formatter.FormatAndDraw(context, stave, notes);
357
357
  Formatter.FormatAndDraw(context, stave2, notes2);
358
- stave.setContext(context).draw();
359
- stave2.setContext(context).draw();
360
- tuplet.setContext(context).draw();
361
- tuplet2.setContext(context).draw();
358
+ stave.setContext(context).drawWithStyle();
359
+ stave2.setContext(context).drawWithStyle();
360
+ tuplet.setContext(context).drawWithStyle();
361
+ tuplet2.setContext(context).drawWithStyle();
362
362
  options.assert.ok(true);
363
363
  }
364
364
  function justifyStaveNotes(options) {
@@ -458,10 +458,10 @@ function multiStaves(options) {
458
458
  type: 'brace',
459
459
  });
460
460
  for (let i = 0; i < staves.length; ++i) {
461
- staves[i].setContext(ctx).draw();
461
+ staves[i].setContext(ctx).drawWithStyle();
462
462
  voices[i].draw(ctx, staves[i]);
463
463
  }
464
- beams.forEach((beam) => beam.setContext(ctx).draw());
464
+ beams.forEach((beam) => beam.setContext(ctx).drawWithStyle());
465
465
  const notes12 = score.notes('ab4/4, bb4/8, (cb5 eb5)/4[stem="down"], d5/8[stem="down"]');
466
466
  const notes22 = score.notes('(eb4 ab4)/4., (c4 eb4 ab4)/4, db5/8', { stem: 'up' });
467
467
  const notes32 = score.notes('a5/8, a5, a5, a5, a5, a5', { stem: 'down' });
@@ -486,11 +486,11 @@ function multiStaves(options) {
486
486
  new Beam(notes32.slice(3, 6), true),
487
487
  ];
488
488
  for (let i = 0; i < staves.length; ++i) {
489
- staves[i].setContext(ctx).draw();
489
+ staves[i].setContext(ctx).drawWithStyle();
490
490
  voices[i].draw(ctx, staves[i]);
491
491
  voices[i].getTickables().forEach((note) => Note.plotMetrics(ctx, note, staveYs[i] - 20));
492
492
  }
493
- beams.forEach((beam) => beam.setContext(ctx).draw());
493
+ beams.forEach((beam) => beam.setContext(ctx).drawWithStyle());
494
494
  options.assert.ok(true);
495
495
  }
496
496
  function proportional(options) {
@@ -714,9 +714,9 @@ function annotations(options) {
714
714
  const voice1 = new Voice({ numBeats: beats, beatValue: beatsPer }).setMode(Voice.Mode.SOFT).addTickables(notes);
715
715
  const fmt = new Formatter({ softmaxFactor: sm.sm, maxIterations: 2 }).joinVoices([voice1]);
716
716
  fmt.format([voice1], sm.width - 11);
717
- stave.setContext(context).draw();
717
+ stave.setContext(context).drawWithStyle();
718
718
  voice1.draw(context, stave);
719
- beams.forEach((b) => b.setContext(context).draw());
719
+ beams.forEach((b) => b.setContext(context).drawWithStyle());
720
720
  });
721
721
  options.assert.ok(true);
722
722
  }
@@ -1,4 +1,5 @@
1
1
  import { VexFlowTests } from './vexflow_test_helpers.js';
2
+ import { ModifierPosition } from '../src.js';
2
3
  import { Accidental } from '../src/accidental.js';
3
4
  import { Annotation } from '../src/annotation.js';
4
5
  import { Articulation } from '../src/articulation.js';
@@ -78,7 +79,7 @@ function basic(options) {
78
79
  .addModifier(f.GraceNoteGroup({ notes: gracenotes3 }).beamNotes(), 0),
79
80
  f
80
81
  .StaveNote({ keys: ['a/4'], duration: '4', autoStem: true })
81
- .addModifier(f.GraceNoteGroup({ notes: gracenotes4 }).beamNotes(), 0),
82
+ .addModifier(f.GraceNoteGroup({ notes: gracenotes4 }).beamNotes().setPosition(ModifierPosition.RIGHT), 0),
82
83
  ];
83
84
  const voice = f.Voice().setStrict(false).addTickables(notes);
84
85
  new Formatter().joinVoices([voice]).formatToStave([voice], stave);
@@ -18,7 +18,7 @@ const tabNote = (noteStruct) => new TabNote(noteStruct);
18
18
  const graceTabNote = (noteStruct) => new GraceTabNote(noteStruct);
19
19
  function setupContext(opts, ctxBuilder) {
20
20
  const context = ctxBuilder(opts.elementId, 350, 140);
21
- const stave = new TabStave(10, 10, 350).addTabGlyph().setContext(context).draw();
21
+ const stave = new TabStave(10, 10, 350).addTabGlyph().setContext(context).drawWithStyle();
22
22
  return { context, stave };
23
23
  }
24
24
  function simple(options, contextBuilder) {
@@ -2,7 +2,6 @@ export * from './accidental_tests.js';
2
2
  export * from './annotation_tests.js';
3
3
  export * from './articulation_tests.js';
4
4
  export * from './auto_beam_formatting_tests.js';
5
- export * from './bach_tests.js';
6
5
  export * from './barline_tests.js';
7
6
  export * from './beam_tests.js';
8
7
  export * from './bend_tests.js';
@@ -11,6 +10,7 @@ export * from './chordsymbol_tests.js';
11
10
  export * from './clef_tests.js';
12
11
  export * from './crossbeam_tests.js';
13
12
  export * from './curve_tests.js';
13
+ export * from './demo_petzold_tests.js';
14
14
  export * from './dot_tests.js';
15
15
  export * from './easyscore_tests.js';
16
16
  export * from './factory_tests.js';
@@ -63,9 +63,9 @@ function keys(options, contextBuilder) {
63
63
  Stave.formatBegModifiers(staves);
64
64
  for (i = 0; i < clefs.length; i++) {
65
65
  staves[i].setContext(ctx);
66
- staves[i].draw();
66
+ staves[i].drawWithStyle();
67
67
  staves[i + clefs.length].setContext(ctx);
68
- staves[i + clefs.length].draw();
68
+ staves[i + clefs.length].drawWithStyle();
69
69
  }
70
70
  options.assert.ok(true, 'all pass');
71
71
  }
@@ -93,13 +93,13 @@ function staveHelper(options, contextBuilder) {
93
93
  stave4.addKeySignature(keys[i]);
94
94
  }
95
95
  stave1.setContext(ctx);
96
- stave1.draw();
96
+ stave1.drawWithStyle();
97
97
  stave2.setContext(ctx);
98
- stave2.draw();
98
+ stave2.drawWithStyle();
99
99
  stave3.setContext(ctx);
100
- stave3.draw();
100
+ stave3.drawWithStyle();
101
101
  stave4.setContext(ctx);
102
- stave4.draw();
102
+ stave4.drawWithStyle();
103
103
  options.assert.ok(true, 'all pass');
104
104
  }
105
105
  VexFlowTests.register(ClefKeySignatureTests);
@@ -72,9 +72,12 @@ function majorKeys(options, contextBuilder) {
72
72
  keySig.addToStave(stave2);
73
73
  }
74
74
  stave1.setContext(ctx);
75
- stave1.draw();
75
+ stave1.drawWithStyle();
76
+ stave1.getModifiers().forEach((modifier) => {
77
+ VexFlowTests.drawBoundingBox(ctx, modifier);
78
+ });
76
79
  stave2.setContext(ctx);
77
- stave2.draw();
80
+ stave2.drawWithStyle();
78
81
  options.assert.ok(true, 'all pass');
79
82
  }
80
83
  function majorKeysCanceled(options, contextBuilder) {
@@ -124,13 +127,13 @@ function majorKeysCanceled(options, contextBuilder) {
124
127
  keySig.addToStave(stave4);
125
128
  }
126
129
  stave1.setContext(ctx);
127
- stave1.draw();
130
+ stave1.drawWithStyle();
128
131
  stave2.setContext(ctx);
129
- stave2.draw();
132
+ stave2.drawWithStyle();
130
133
  stave3.setContext(ctx);
131
- stave3.draw();
134
+ stave3.drawWithStyle();
132
135
  stave4.setContext(ctx);
133
- stave4.draw();
136
+ stave4.drawWithStyle();
134
137
  options.assert.ok(true, 'all pass');
135
138
  }
136
139
  function keysCanceledForEachClef(options, contextBuilder) {
@@ -161,7 +164,7 @@ function keysCanceledForEachClef(options, contextBuilder) {
161
164
  stave.addKeySignature(cancelKey);
162
165
  stave.addKeySignature(key, cancelKey);
163
166
  stave.addKeySignature(key);
164
- stave.setContext(ctx).draw();
167
+ stave.setContext(ctx).drawWithStyle();
165
168
  tx += width;
166
169
  });
167
170
  tx = x;
@@ -205,13 +208,13 @@ function majorKeysAltered(options, contextBuilder) {
205
208
  keySig.addToStave(stave4);
206
209
  }
207
210
  stave1.setContext(ctx);
208
- stave1.draw();
211
+ stave1.drawWithStyle();
209
212
  stave2.setContext(ctx);
210
- stave2.draw();
213
+ stave2.drawWithStyle();
211
214
  stave3.setContext(ctx);
212
- stave3.draw();
215
+ stave3.drawWithStyle();
213
216
  stave4.setContext(ctx);
214
- stave4.draw();
217
+ stave4.drawWithStyle();
215
218
  options.assert.ok(true, 'all pass');
216
219
  }
217
220
  function minorKeys(options, contextBuilder) {
@@ -235,9 +238,9 @@ function minorKeys(options, contextBuilder) {
235
238
  keySig.addToStave(stave2);
236
239
  }
237
240
  stave1.setContext(ctx);
238
- stave1.draw();
241
+ stave1.drawWithStyle();
239
242
  stave2.setContext(ctx);
240
- stave2.draw();
243
+ stave2.drawWithStyle();
241
244
  options.assert.ok(true, 'all pass');
242
245
  }
243
246
  function endKeyWithClef(options, contextBuilder) {
@@ -254,8 +257,8 @@ function endKeyWithClef(options, contextBuilder) {
254
257
  .setEndKeySignature('Cb');
255
258
  const stave2 = new Stave(10, 90, 350);
256
259
  stave2.setKeySignature('Cb').setClef('bass').setEndClef('treble').setEndKeySignature('G');
257
- stave1.setContext(ctx).draw();
258
- stave2.setContext(ctx).draw();
260
+ stave1.setContext(ctx).drawWithStyle();
261
+ stave2.setContext(ctx).drawWithStyle();
259
262
  options.assert.ok(true, 'all pass');
260
263
  }
261
264
  function staveHelper(options, contextBuilder) {
@@ -276,9 +279,9 @@ function staveHelper(options, contextBuilder) {
276
279
  stave2.addKeySignature(keys[n]);
277
280
  }
278
281
  stave1.setContext(ctx);
279
- stave1.draw();
282
+ stave1.drawWithStyle();
280
283
  stave2.setContext(ctx);
281
- stave2.draw();
284
+ stave2.drawWithStyle();
282
285
  options.assert.ok(true, 'all pass');
283
286
  }
284
287
  function changeKey(options) {
@@ -27,7 +27,7 @@ function basic(options, contextBuilder) {
27
27
  const ctx = contextBuilder(options.elementId, 450, 250);
28
28
  setContextStyle(ctx);
29
29
  const stave = new Stave(10, 0, 250).addClef('treble');
30
- stave.setContext(ctx).draw();
30
+ stave.setContext(ctx).drawWithStyle();
31
31
  const formatter = new Formatter();
32
32
  const voice = new Voice(VexFlow.TIME4_4).setStrict(false);
33
33
  const noteHead1 = new NoteHead({ duration: '4', line: 3 });
@@ -41,7 +41,7 @@ function basic(options, contextBuilder) {
41
41
  function showNote(noteStruct, stave, ctx, x) {
42
42
  const note = new StaveNote(noteStruct).setStave(stave);
43
43
  new TickContext().addTickable(note).preFormat().setX(x);
44
- note.setContext(ctx).draw();
44
+ note.setContext(ctx).drawWithStyle();
45
45
  return note;
46
46
  }
47
47
  function variousHeads(options, contextBuilder) {
@@ -72,7 +72,7 @@ function variousHeads(options, contextBuilder) {
72
72
  const stave = new Stave(10, 10 + staveNum * 120, notes.length * 25 + 75)
73
73
  .addClef('percussion')
74
74
  .setContext(ctx)
75
- .draw();
75
+ .drawWithStyle();
76
76
  for (let i = 0; i < notes.length; ++i) {
77
77
  const note = notes[i];
78
78
  note.stemDirection = staveNum === 0 ? -1 : 1;
@@ -135,7 +135,7 @@ function variousNoteHeads(options, contextBuilder) {
135
135
  const stave = new Stave(10, 10 + staveNum * 120, notes.length * 25 + 75)
136
136
  .addClef('percussion')
137
137
  .setContext(ctx)
138
- .draw();
138
+ .drawWithStyle();
139
139
  for (let i = 0; i < notes.length; ++i) {
140
140
  const note = notes[i];
141
141
  note.stemDirection = staveNum === 0 ? -1 : 1;
@@ -157,7 +157,7 @@ function variousNoteHeads2(options, contextBuilder) {
157
157
  { keys: ['g/5/ti'], duration: '4', autoStem: true },
158
158
  ];
159
159
  const ctx = contextBuilder(options.elementId, notes.length * 25 + 100, 240);
160
- const stave = new Stave(10, 10, notes.length * 25 + 75).addClef('percussion').setContext(ctx).draw();
160
+ const stave = new Stave(10, 10, notes.length * 25 + 75).addClef('percussion').setContext(ctx).drawWithStyle();
161
161
  for (let i = 0; i < notes.length; ++i) {
162
162
  const note = notes[i];
163
163
  const staveNote = showNote(note, stave, ctx, (i + 1) * 25);
@@ -188,7 +188,10 @@ function drumChordHeads(options, contextBuilder) {
188
188
  ];
189
189
  const ctx = contextBuilder(options.elementId, notes.length * 25 + 100, 240);
190
190
  for (let h = 0; h < 2; ++h) {
191
- const stave = new Stave(10, 10 + h * 120, notes.length * 25 + 75).addClef('percussion').setContext(ctx).draw();
191
+ const stave = new Stave(10, 10 + h * 120, notes.length * 25 + 75)
192
+ .addClef('percussion')
193
+ .setContext(ctx)
194
+ .drawWithStyle();
192
195
  for (let i = 0; i < notes.length; ++i) {
193
196
  const note = notes[i];
194
197
  note.stemDirection = h === 0 ? -1 : 1;
@@ -202,7 +205,7 @@ function basicBoundingBoxes(options, contextBuilder) {
202
205
  const ctx = contextBuilder(options.elementId, 450, 250);
203
206
  setContextStyle(ctx);
204
207
  const stave = new Stave(10, 0, 250).addClef('treble');
205
- stave.setContext(ctx).draw();
208
+ stave.setContext(ctx).drawWithStyle();
206
209
  const formatter = new Formatter();
207
210
  const voice = new Voice(VexFlow.TIME4_4).setStrict(false);
208
211
  const nh1 = new StaveNote({ keys: ['b/4'], duration: '4' });
@@ -23,7 +23,7 @@ function simpleTest(assert) {
23
23
  const ctx = new CanvasContext(offscreenCtx);
24
24
  const stave = new Stave(10, 50, 200);
25
25
  stave.setEndBarType(BarlineType.END);
26
- stave.addClef('treble').setContext(ctx).draw();
26
+ stave.addClef('treble').setContext(ctx).drawWithStyle();
27
27
  const notes = [
28
28
  new StaveNote({ keys: ['c/4'], duration: 'q' }),
29
29
  new StaveNote({ keys: ['d/4'], duration: 'q' }),
@@ -27,7 +27,7 @@ function drawOrnaments(options, contextBuilder) {
27
27
  options.assert.expect(0);
28
28
  const ctx = contextBuilder(options.elementId, 750, 195);
29
29
  const stave = new Stave(10, 30, 700);
30
- stave.setContext(ctx).draw();
30
+ stave.setContext(ctx).drawWithStyle();
31
31
  const notes = [
32
32
  new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
33
33
  new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
@@ -62,7 +62,7 @@ function drawOrnamentsDisplaced(options, contextBuilder) {
62
62
  options.assert.expect(0);
63
63
  const ctx = contextBuilder(options.elementId, 750, 195);
64
64
  const stave = new Stave(10, 30, 700);
65
- stave.setContext(ctx).draw();
65
+ stave.setContext(ctx).drawWithStyle();
66
66
  const notes = [
67
67
  new StaveNote({ keys: ['a/5'], duration: '4', stemDirection: -1 }),
68
68
  new StaveNote({ keys: ['a/5'], duration: '4', stemDirection: -1 }),
@@ -97,7 +97,7 @@ function drawOrnamentsDisplaced(options, contextBuilder) {
97
97
  const addDelayedTurns = (f) => {
98
98
  const context = f.getContext();
99
99
  const stave = f.Stave({ x: 10, y: 30, width: 500 });
100
- stave.setContext(context).draw();
100
+ stave.setContext(context).drawWithStyle();
101
101
  const notes = [
102
102
  f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
103
103
  f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
@@ -150,7 +150,7 @@ function drawOrnamentsDelayedMultipleVoices(options, contextBuilder) {
150
150
  formatter.joinVoices([voice1]);
151
151
  formatter.joinVoices([voice2]);
152
152
  formatter.format([voice1, voice2], formatWidth);
153
- stave.setContext(ctx).draw();
153
+ stave.setContext(ctx).drawWithStyle();
154
154
  voice1.draw(ctx, stave);
155
155
  voice2.draw(ctx, stave);
156
156
  }
@@ -159,7 +159,7 @@ function drawOrnamentsStacked(options) {
159
159
  const f = VexFlowTests.makeFactory(options, 550, 195);
160
160
  const ctx = f.getContext();
161
161
  const stave = f.Stave({ x: 10, y: 30, width: 500 });
162
- stave.setContext(ctx).draw();
162
+ stave.setContext(ctx).drawWithStyle();
163
163
  const notes = [
164
164
  f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
165
165
  f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
@@ -181,7 +181,7 @@ function drawOrnamentsWithAccidentals(options) {
181
181
  const f = VexFlowTests.makeFactory(options, 650, 250);
182
182
  const ctx = f.getContext();
183
183
  const stave = f.Stave({ x: 10, y: 60, width: 600 });
184
- stave.setContext(ctx).draw();
184
+ stave.setContext(ctx).drawWithStyle();
185
185
  const notes = [
186
186
  f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
187
187
  f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
@@ -221,7 +221,7 @@ function jazzOrnaments(options) {
221
221
  }
222
222
  return n;
223
223
  };
224
- const stave = new Stave(x, y, width).addClef('treble').setContext(ctx).draw();
224
+ const stave = new Stave(x, y, width).addClef('treble').setContext(ctx).drawWithStyle();
225
225
  const notes = [
226
226
  note(keys, '4d', modifiers[0], stemDirection),
227
227
  note(keys, '8', modifiers[1], stemDirection),
@@ -239,7 +239,7 @@ function jazzOrnaments(options) {
239
239
  voice.addTickables(notes);
240
240
  const formatter = new Formatter().joinVoices([voice]);
241
241
  formatter.format([voice], width - Stave.defaultPadding - clefWidth);
242
- stave.setContext(ctx).draw();
242
+ stave.setContext(ctx).drawWithStyle();
243
243
  voice.draw(ctx, stave);
244
244
  }
245
245
  options.assert.expect(0);
@@ -4,9 +4,14 @@ const PedalMarkingTests = {
4
4
  QUnit.module('PedalMarking');
5
5
  const run = VexFlowTests.runTests;
6
6
  run('Simple Pedal 1', simple1);
7
+ run('Simple Pedal 1b', simple1b);
7
8
  run('Simple Pedal 2', simple2);
9
+ run('Simple Pedal 2b', simple2b);
8
10
  run('Simple Pedal 3', simple3);
11
+ run('Simple Pedal 3b', simple3b);
12
+ run('Release and Depress on Same Note 1b', releaseDepress1b);
9
13
  run('Release and Depress on Same Note 1', releaseDepress1);
14
+ run('Release and Depress on Same Note 2b', releaseDepress2b);
10
15
  run('Release and Depress on Same Note 2', releaseDepress2);
11
16
  run('Custom Text 1', customTest1);
12
17
  run('Custom Text 2', customTest2);
@@ -27,6 +32,23 @@ function createTest(makePedal) {
27
32
  options.assert.ok(true, 'Must render');
28
33
  };
29
34
  }
35
+ function createTest2(makePedal) {
36
+ return (options) => {
37
+ const f = VexFlowTests.makeFactory(options, 550, 200);
38
+ const score = f.EasyScore();
39
+ const stave0 = f.Stave({ width: 250 }).addClef('treble');
40
+ const voice0 = score.voice(score.notes('b4/4, b4, b4, b4', { stem: 'down' }));
41
+ const voice0b = score.voice(score.notes('b5/4, b5, b5, b5', { stem: 'up' }));
42
+ f.Formatter().joinVoices([voice0, voice0b]).formatToStave([voice0, voice0b], stave0);
43
+ const stave1 = f.Stave({ width: 260, x: 250 });
44
+ const voice1 = score.voice(score.notes('c4/4, c4, c4, c4', { stem: 'down' }));
45
+ const voice1b = score.voice(score.notes('c5/4, c5, c5, c5/16, c5/16, c5/16, c5/16', { stem: 'up' }));
46
+ f.Formatter().joinVoices([voice1, voice1b]).formatToStave([voice1, voice1b], stave1);
47
+ makePedal(f, voice0.getTickables(), voice1.getTickables());
48
+ f.draw();
49
+ options.assert.ok(true, 'Must render');
50
+ };
51
+ }
30
52
  function withSimplePedal(style) {
31
53
  return (factory, notes0, notes1) => factory.PedalMarking({
32
54
  notes: [notes0[0], notes0[2], notes0[3], notes1[3]],
@@ -44,6 +66,11 @@ const simple2 = createTest(withSimplePedal('bracket'));
44
66
  const simple3 = createTest(withSimplePedal('mixed'));
45
67
  const releaseDepress1 = createTest(withReleaseAndDepressedPedal('bracket'));
46
68
  const releaseDepress2 = createTest(withReleaseAndDepressedPedal('mixed'));
69
+ const simple1b = createTest2(withSimplePedal('text'));
70
+ const simple2b = createTest2(withSimplePedal('bracket'));
71
+ const simple3b = createTest2(withSimplePedal('mixed'));
72
+ const releaseDepress1b = createTest2(withReleaseAndDepressedPedal('bracket'));
73
+ const releaseDepress2b = createTest2(withReleaseAndDepressedPedal('mixed'));
47
74
  const customTest1 = createTest((factory, notes0, notes1) => {
48
75
  const pedal = factory.PedalMarking({
49
76
  notes: [notes0[0], notes1[3]],
@@ -18,13 +18,13 @@ const PercussionTests = {
18
18
  };
19
19
  function draw(options, contextBuilder) {
20
20
  const ctx = contextBuilder(options.elementId, 400, 120);
21
- new Stave(10, 10, 300).addClef('percussion').setContext(ctx).draw();
21
+ new Stave(10, 10, 300).addClef('percussion').setContext(ctx).drawWithStyle();
22
22
  options.assert.ok(true);
23
23
  }
24
24
  function showNote(struct, stave, ctx, x) {
25
25
  const staveNote = new StaveNote(struct).setStave(stave);
26
26
  new TickContext().addTickable(staveNote).preFormat().setX(x);
27
- staveNote.setContext(ctx).draw();
27
+ staveNote.setContext(ctx).drawWithStyle();
28
28
  return staveNote;
29
29
  }
30
30
  function drawNotes(options, contextBuilder) {
@@ -46,7 +46,10 @@ function drawNotes(options, contextBuilder) {
46
46
  ];
47
47
  const ctx = contextBuilder(options.elementId, notes.length * 25 + 100, 240);
48
48
  for (let h = 0; h < 2; ++h) {
49
- const stave = new Stave(10, 10 + h * 120, notes.length * 25 + 75).addClef('percussion').setContext(ctx).draw();
49
+ const stave = new Stave(10, 10 + h * 120, notes.length * 25 + 75)
50
+ .addClef('percussion')
51
+ .setContext(ctx)
52
+ .drawWithStyle();
50
53
  for (let i = 0; i < notes.length; ++i) {
51
54
  const note = notes[i];
52
55
  note.stemDirection = h === 0 ? -1 : 1;
@@ -18,7 +18,7 @@ const RendererTests = {
18
18
  },
19
19
  };
20
20
  function drawStave(stave, context) {
21
- stave.addClef('bass').addTimeSignature('3/4').draw();
21
+ stave.addClef('bass').addTimeSignature('3/4').drawWithStyle();
22
22
  Formatter.FormatAndDraw(context, stave, [
23
23
  new StaveNote({ keys: ['C/4'], duration: '4' }),
24
24
  new StaveNote({ keys: ['E/4'], duration: '4' }),