vexflow 5.0.0-alpha.3 → 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 (152) 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 +2066 -1877
  7. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  8. package/build/cjs/vexflow-debug.js +1052 -993
  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/accidental.js +22 -28
  13. package/build/esm/src/annotation.js +0 -2
  14. package/build/esm/src/barnote.js +3 -3
  15. package/build/esm/src/beam.js +26 -46
  16. package/build/esm/src/bend.js +11 -3
  17. package/build/esm/src/chordsymbol.js +0 -4
  18. package/build/esm/src/clef.js +0 -2
  19. package/build/esm/src/clefnote.js +6 -1
  20. package/build/esm/src/curve.js +8 -5
  21. package/build/esm/src/element.js +94 -118
  22. package/build/esm/src/factory.js +4 -4
  23. package/build/esm/src/flag.js +20 -0
  24. package/build/esm/src/fonts/gonville.js +1 -1
  25. package/build/esm/src/formatter.js +13 -21
  26. package/build/esm/src/fraction.js +15 -22
  27. package/build/esm/src/glyphnote.js +3 -4
  28. package/build/esm/src/gracenote.js +0 -2
  29. package/build/esm/src/gracenotegroup.js +17 -8
  30. package/build/esm/src/index.js +1 -0
  31. package/build/esm/src/keysignature.js +38 -31
  32. package/build/esm/src/keysignote.js +1 -1
  33. package/build/esm/src/metrics.js +58 -7
  34. package/build/esm/src/modifier.js +10 -23
  35. package/build/esm/src/multimeasurerest.js +16 -25
  36. package/build/esm/src/note.js +7 -0
  37. package/build/esm/src/notehead.js +6 -1
  38. package/build/esm/src/ornament.js +0 -2
  39. package/build/esm/src/pedalmarking.js +33 -41
  40. package/build/esm/src/registry.js +5 -19
  41. package/build/esm/src/stave.js +11 -19
  42. package/build/esm/src/stavebarline.js +2 -3
  43. package/build/esm/src/stavehairpin.js +1 -1
  44. package/build/esm/src/staveline.js +0 -4
  45. package/build/esm/src/stavemodifier.js +0 -2
  46. package/build/esm/src/stavenote.js +42 -68
  47. package/build/esm/src/staverepetition.js +3 -2
  48. package/build/esm/src/stavesection.js +13 -15
  49. package/build/esm/src/stavetempo.js +7 -13
  50. package/build/esm/src/stavetext.js +2 -2
  51. package/build/esm/src/stavetie.js +82 -40
  52. package/build/esm/src/stavevolta.js +3 -2
  53. package/build/esm/src/stem.js +0 -4
  54. package/build/esm/src/stemmablenote.js +5 -6
  55. package/build/esm/src/stringnumber.js +0 -2
  56. package/build/esm/src/svgcontext.js +5 -13
  57. package/build/esm/src/tabnote.js +2 -8
  58. package/build/esm/src/textbracket.js +0 -3
  59. package/build/esm/src/textnote.js +0 -2
  60. package/build/esm/src/tickable.js +13 -26
  61. package/build/esm/src/tickcontext.js +20 -2
  62. package/build/esm/src/timesignature.js +2 -4
  63. package/build/esm/src/timesignote.js +2 -0
  64. package/build/esm/src/tuplet.js +37 -30
  65. package/build/esm/src/version.js +3 -3
  66. package/build/esm/src/vexflow.js +6 -2
  67. package/build/esm/src/vibrato.js +6 -1
  68. package/build/esm/tests/accidental_tests.js +30 -17
  69. package/build/esm/tests/annotation_tests.js +12 -12
  70. package/build/esm/tests/articulation_tests.js +13 -13
  71. package/build/esm/tests/auto_beam_formatting_tests.js +33 -33
  72. package/build/esm/tests/beam_tests.js +1 -1
  73. package/build/esm/tests/bend_tests.js +7 -7
  74. package/build/esm/tests/chordsymbol_tests.js +8 -8
  75. package/build/esm/tests/clef_tests.js +5 -1
  76. package/build/esm/tests/curve_tests.js +34 -0
  77. package/build/esm/tests/{bach_tests.js → demo_petzold_tests.js} +7 -7
  78. package/build/esm/tests/dot_tests.js +4 -4
  79. package/build/esm/tests/formatter_tests.js +25 -25
  80. package/build/esm/tests/glyphnote_tests.js +6 -0
  81. package/build/esm/tests/gracenote_tests.js +2 -1
  82. package/build/esm/tests/gracetabnote_tests.js +1 -1
  83. package/build/esm/tests/index.js +1 -1
  84. package/build/esm/tests/key_clef_tests.js +6 -6
  85. package/build/esm/tests/keysignature_tests.js +20 -17
  86. package/build/esm/tests/notehead_tests.js +10 -7
  87. package/build/esm/tests/offscreencanvas_tests.js +1 -1
  88. package/build/esm/tests/ornament_tests.js +8 -8
  89. package/build/esm/tests/pedalmarking_tests.js +27 -0
  90. package/build/esm/tests/percussion_tests.js +6 -3
  91. package/build/esm/tests/renderer_tests.js +1 -1
  92. package/build/esm/tests/rests_tests.js +26 -26
  93. package/build/esm/tests/rhythm_tests.js +15 -15
  94. package/build/esm/tests/stave_tests.js +44 -43
  95. package/build/esm/tests/staveconnector_tests.js +73 -73
  96. package/build/esm/tests/stavehairpin_tests.js +1 -1
  97. package/build/esm/tests/stavemodifier_tests.js +3 -3
  98. package/build/esm/tests/stavenote_tests.js +29 -29
  99. package/build/esm/tests/stavetie_tests.js +29 -0
  100. package/build/esm/tests/stringnumber_tests.js +1 -1
  101. package/build/esm/tests/strokes_tests.js +1 -1
  102. package/build/esm/tests/style_tests.js +1 -1
  103. package/build/esm/tests/tabnote_tests.js +7 -7
  104. package/build/esm/tests/tabslide_tests.js +6 -6
  105. package/build/esm/tests/tabstave_tests.js +2 -1
  106. package/build/esm/tests/tabtie_tests.js +8 -8
  107. package/build/esm/tests/textnote_tests.js +1 -1
  108. package/build/esm/tests/threevoice_tests.js +2 -2
  109. package/build/esm/tests/timesignature_tests.js +23 -13
  110. package/build/esm/tests/vexflow_test_helpers.js +25 -39
  111. package/build/esm/tests/vibrato_tests.js +3 -3
  112. package/build/esm/tests/voice_tests.js +1 -1
  113. package/build/types/src/accidental.d.ts +19 -1
  114. package/build/types/src/annotation.d.ts +1 -1
  115. package/build/types/src/beam.d.ts +12 -1
  116. package/build/types/src/bend.d.ts +6 -0
  117. package/build/types/src/clefnote.d.ts +2 -0
  118. package/build/types/src/curve.d.ts +5 -4
  119. package/build/types/src/element.d.ts +23 -14
  120. package/build/types/src/factory.d.ts +2 -2
  121. package/build/types/src/flag.d.ts +12 -0
  122. package/build/types/src/fonts/gonville.d.ts +1 -1
  123. package/build/types/src/formatter.d.ts +5 -3
  124. package/build/types/src/fraction.d.ts +12 -7
  125. package/build/types/src/frethandfinger.d.ts +1 -1
  126. package/build/types/src/index.d.ts +1 -0
  127. package/build/types/src/keysignature.d.ts +7 -7
  128. package/build/types/src/metrics.d.ts +5 -0
  129. package/build/types/src/modifier.d.ts +3 -2
  130. package/build/types/src/multimeasurerest.d.ts +4 -1
  131. package/build/types/src/note.d.ts +2 -0
  132. package/build/types/src/pedalmarking.d.ts +2 -2
  133. package/build/types/src/registry.d.ts +1 -1
  134. package/build/types/src/stave.d.ts +1 -3
  135. package/build/types/src/stavebarline.d.ts +1 -1
  136. package/build/types/src/staveline.d.ts +1 -1
  137. package/build/types/src/stavemodifier.d.ts +0 -1
  138. package/build/types/src/stavenote.d.ts +2 -1
  139. package/build/types/src/staverepetition.d.ts +1 -1
  140. package/build/types/src/stavesection.d.ts +3 -4
  141. package/build/types/src/stavetempo.d.ts +4 -5
  142. package/build/types/src/stavetext.d.ts +1 -2
  143. package/build/types/src/stavetie.d.ts +39 -2
  144. package/build/types/src/stavevolta.d.ts +1 -2
  145. package/build/types/src/stemmablenote.d.ts +2 -3
  146. package/build/types/src/svgcontext.d.ts +1 -1
  147. package/build/types/src/tickable.d.ts +2 -1
  148. package/build/types/src/tickcontext.d.ts +30 -0
  149. package/build/types/src/tuplet.d.ts +2 -12
  150. package/build/types/src/typeguard.d.ts +1 -0
  151. package/package.json +33 -29
  152. package/tests/flow.html +2 -2
@@ -72,7 +72,7 @@ function draw(note, stave, context, x, drawBoundingBox = false, addModifierConte
72
72
  note.addToModifierContext(new ModifierContext());
73
73
  }
74
74
  new TickContext().addTickable(note).preFormat().setX(x);
75
- note.setContext(context).draw();
75
+ note.setContext(context).drawWithStyle();
76
76
  if (drawBoundingBox) {
77
77
  const bb = note.getBoundingBox();
78
78
  context.rect(bb.getX(), bb.getY(), bb.getW(), bb.getH());
@@ -239,7 +239,7 @@ function drawBasic(options, contextBuilder) {
239
239
  const stave = new Stave(10, 30, 750);
240
240
  stave.setContext(ctx);
241
241
  stave.addClef(clef);
242
- stave.draw();
242
+ stave.drawWithStyle();
243
243
  const lowerKeys = ['c/', 'e/', 'a/'];
244
244
  const higherKeys = ['c/', 'e/', 'a/'];
245
245
  for (let k = 0; k < lowerKeys.length; k++) {
@@ -303,7 +303,7 @@ function drawBoundingBoxes(options, contextBuilder) {
303
303
  const stave = new Stave(10, 30, 750);
304
304
  stave.setContext(ctx);
305
305
  stave.addClef(clef);
306
- stave.draw();
306
+ stave.drawWithStyle();
307
307
  const lowerKeys = ['c/', 'e/', 'a/'];
308
308
  const higherKeys = ['c/', 'e/', 'a/'];
309
309
  for (let k = 0; k < lowerKeys.length; k++) {
@@ -361,7 +361,7 @@ function drawBass(options, contextBuilder) {
361
361
  const stave = new Stave(10, 10, 650);
362
362
  stave.setContext(ctx);
363
363
  stave.addClef('bass');
364
- stave.draw();
364
+ stave.drawWithStyle();
365
365
  const noteStructs = [
366
366
  { clef: 'bass', keys: ['c/3', 'e/3', 'a/3'], duration: '1/2' },
367
367
  { clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: 'w' },
@@ -395,7 +395,7 @@ function displacements(options, contextBuilder) {
395
395
  ctx.scale(0.9, 0.9);
396
396
  const stave = new Stave(10, 10, 675);
397
397
  stave.setContext(ctx);
398
- stave.draw();
398
+ stave.drawWithStyle();
399
399
  const noteStructs = [
400
400
  { keys: ['g/3', 'a/3', 'c/4', 'd/4', 'e/4'], duration: '1/2' },
401
401
  { keys: ['g/3', 'a/3', 'c/4', 'd/4', 'e/4'], duration: 'w' },
@@ -427,7 +427,7 @@ function drawHarmonicAndMuted(options, contextBuilder) {
427
427
  const ctx = contextBuilder(options.elementId, 1000, 180);
428
428
  const stave = new Stave(10, 10, 950);
429
429
  stave.setContext(ctx);
430
- stave.draw();
430
+ stave.drawWithStyle();
431
431
  const noteStructs = [
432
432
  { keys: ['c/4', 'e/4', 'a/4'], duration: '1/2h' },
433
433
  { keys: ['c/4', 'e/4', 'a/4'], duration: 'wh' },
@@ -477,7 +477,7 @@ function drawSlash(options, contextBuilder) {
477
477
  const ctx = contextBuilder(options.elementId, 700, 180);
478
478
  const stave = new Stave(10, 10, 650);
479
479
  stave.setContext(ctx);
480
- stave.draw();
480
+ stave.drawWithStyle();
481
481
  const notes = [
482
482
  { keys: ['b/4'], duration: '1/2s', stemDirection: Stem.DOWN },
483
483
  { keys: ['b/4'], duration: 'ws', stemDirection: Stem.DOWN },
@@ -506,8 +506,8 @@ function drawSlash(options, contextBuilder) {
506
506
  const beam1 = new Beam([staveNotes[16], staveNotes[17]]);
507
507
  const beam2 = new Beam([staveNotes[18], staveNotes[19]]);
508
508
  Formatter.FormatAndDraw(ctx, stave, staveNotes, false);
509
- beam1.setContext(ctx).draw();
510
- beam2.setContext(ctx).draw();
509
+ beam1.setContext(ctx).drawWithStyle();
510
+ beam2.setContext(ctx).drawWithStyle();
511
511
  options.assert.ok('Slash Note Heads');
512
512
  }
513
513
  function drawKeyStyles(options, contextBuilder) {
@@ -519,8 +519,8 @@ function drawKeyStyles(options, contextBuilder) {
519
519
  .addModifier(new Accidental('b'), 1)
520
520
  .setKeyStyle(1, { shadowBlur: 2, shadowColor: 'blue', fillStyle: 'blue' });
521
521
  new TickContext().addTickable(note).preFormat().setX(25);
522
- stave.setContext(ctx).draw();
523
- note.setContext(ctx).draw();
522
+ stave.setContext(ctx).drawWithStyle();
523
+ note.setContext(ctx).drawWithStyle();
524
524
  options.assert.ok(note.getX() > 0, 'Note has X value');
525
525
  options.assert.ok(note.getYs().length > 0, 'Note has Y values');
526
526
  }
@@ -533,8 +533,8 @@ function drawNoteStyles(options, contextBuilder) {
533
533
  .addModifier(new Accidental('b'), 1);
534
534
  note.setStyle({ shadowBlur: 2, shadowColor: 'blue', fillStyle: 'blue', strokeStyle: 'blue' });
535
535
  new TickContext().addTickable(note).preFormat().setX(25);
536
- stave.setContext(ctx).draw();
537
- note.setContext(ctx).draw();
536
+ stave.setContext(ctx).drawWithStyle();
537
+ note.setContext(ctx).drawWithStyle();
538
538
  options.assert.ok(note.getX() > 0, 'Note has X value');
539
539
  options.assert.ok(note.getYs().length > 0, 'Note has Y values');
540
540
  }
@@ -547,14 +547,14 @@ function drawNoteStemStyles(options, contextBuilder) {
547
547
  .addModifier(new Accidental('b'), 1);
548
548
  note.setStemStyle({ shadowBlur: 2, shadowColor: 'blue', fillStyle: 'blue', strokeStyle: 'blue' });
549
549
  new TickContext().addTickable(note).preFormat().setX(25);
550
- stave.setContext(ctx).draw();
551
- note.setContext(ctx).draw();
550
+ stave.setContext(ctx).drawWithStyle();
551
+ note.setContext(ctx).drawWithStyle();
552
552
  options.assert.ok('Note Stem Style');
553
553
  }
554
554
  function drawNoteStemLengths(options, contextBuilder) {
555
555
  const ctx = contextBuilder(options.elementId, 975, 150);
556
556
  const stave = new Stave(10, 10, 975);
557
- stave.setContext(ctx).draw();
557
+ stave.setContext(ctx).drawWithStyle();
558
558
  const keys = [
559
559
  'e/3',
560
560
  'f/3',
@@ -609,8 +609,8 @@ function drawNoteStylesWithFlag(options, contextBuilder) {
609
609
  .addModifier(new Accidental('b'), 1);
610
610
  note.setFlagStyle({ shadowBlur: 2, shadowColor: 'blue', fillStyle: 'blue', strokeStyle: 'blue' });
611
611
  new TickContext().addTickable(note).preFormat().setX(25);
612
- stave.setContext(ctx).draw();
613
- note.setContext(ctx).draw();
612
+ stave.setContext(ctx).drawWithStyle();
613
+ note.setContext(ctx).drawWithStyle();
614
614
  options.assert.ok(note.getX() > 0, 'Note has X value');
615
615
  options.assert.ok(note.getYs().length > 0, 'Note has Y values');
616
616
  }
@@ -619,7 +619,7 @@ function drawBeamStyles(options, contextBuilder) {
619
619
  const stave = new Stave(10, 10, 380);
620
620
  stave.setStyle({ strokeStyle: '#EEAAEE', lineWidth: 3 });
621
621
  stave.setContext(ctx);
622
- stave.draw();
622
+ stave.drawWithStyle();
623
623
  const notes = [
624
624
  { keys: ['b/4'], duration: '8', stemDirection: Stem.DOWN },
625
625
  { keys: ['b/4'], duration: '8', stemDirection: Stem.DOWN },
@@ -648,10 +648,10 @@ function drawBeamStyles(options, contextBuilder) {
648
648
  staveNotes[9].setLedgerLineStyle({ fillStyle: 'lawngreen', strokeStyle: 'lawngreen', lineWidth: 1 });
649
649
  staveNotes[9].setFlagStyle({ fillStyle: 'orange', strokeStyle: 'orange' });
650
650
  Formatter.FormatAndDraw(ctx, stave, staveNotes, false);
651
- beam1.setContext(ctx).draw();
652
- beam2.setContext(ctx).draw();
653
- beam3.setContext(ctx).draw();
654
- beam4.setContext(ctx).draw();
651
+ beam1.setContext(ctx).drawWithStyle();
652
+ beam2.setContext(ctx).drawWithStyle();
653
+ beam3.setContext(ctx).drawWithStyle();
654
+ beam4.setContext(ctx).drawWithStyle();
655
655
  options.assert.ok('draw beam styles');
656
656
  }
657
657
  function dotsAndFlagsStemUp(options, contextBuilder) {
@@ -674,7 +674,7 @@ function dotsAndFlagsStemUp(options, contextBuilder) {
674
674
  ];
675
675
  Dot.buildAndAttach(notes, { all: true });
676
676
  Dot.buildAndAttach([notes[5], notes[11]], { all: true });
677
- stave.setContext(ctx).draw();
677
+ stave.setContext(ctx).drawWithStyle();
678
678
  for (let i = 0; i < notes.length; ++i) {
679
679
  draw(notes[i], stave, ctx, i * 65);
680
680
  }
@@ -699,7 +699,7 @@ function dotsAndFlagsStemDown(options, contextBuilder) {
699
699
  staveNote({ keys: ['d/5'], duration: '128', stemDirection: Stem.DOWN }),
700
700
  ];
701
701
  Dot.buildAndAttach(staveNotes, { all: true });
702
- stave.setContext(ctx).draw();
702
+ stave.setContext(ctx).drawWithStyle();
703
703
  for (let i = 0; i < staveNotes.length; ++i) {
704
704
  draw(staveNotes[i], stave, ctx, i * 65);
705
705
  }
@@ -724,11 +724,11 @@ function dotsAndBeamsUp(options, contextBuilder) {
724
724
  Dot.buildAndAttach(staveNotes, { all: true });
725
725
  Dot.buildAndAttach([staveNotes[4], staveNotes[9]], { all: true });
726
726
  const beam = new Beam(staveNotes);
727
- stave.setContext(ctx).draw();
727
+ stave.setContext(ctx).drawWithStyle();
728
728
  for (let i = 0; i < staveNotes.length; ++i) {
729
729
  draw(staveNotes[i], stave, ctx, i * 65);
730
730
  }
731
- beam.setContext(ctx).draw();
731
+ beam.setContext(ctx).drawWithStyle();
732
732
  options.assert.ok(true, 'Full Dot');
733
733
  }
734
734
  function dotsAndBeamsDown(options, contextBuilder) {
@@ -749,11 +749,11 @@ function dotsAndBeamsDown(options, contextBuilder) {
749
749
  ];
750
750
  Dot.buildAndAttach(staveNotes, { all: true });
751
751
  const beam = new Beam(staveNotes);
752
- stave.setContext(ctx).draw();
752
+ stave.setContext(ctx).drawWithStyle();
753
753
  for (let i = 0; i < staveNotes.length; ++i) {
754
754
  draw(staveNotes[i], stave, ctx, i * 65);
755
755
  }
756
- beam.setContext(ctx).draw();
756
+ beam.setContext(ctx).drawWithStyle();
757
757
  options.assert.ok(true, 'Full Dot');
758
758
  }
759
759
  function noteHeadsSimple(options) {
@@ -13,6 +13,7 @@ const StaveTieTests = {
13
13
  run('No Start Note', noStartNote2);
14
14
  run('Set Direction Down', setDirectionDown);
15
15
  run('Set Direction Up', setDirectionUp);
16
+ run('Tie Algorithms', tieAlgorithms);
16
17
  },
17
18
  };
18
19
  function createTest(notesData, setupTies) {
@@ -104,5 +105,33 @@ const setDirectionUp = createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down'
104
105
  options: { direction: Stem.UP },
105
106
  });
106
107
  });
108
+ function tieAlgorithms(options) {
109
+ const factory = VexFlowTests.makeFactory(options, 300);
110
+ const stave = factory.Stave();
111
+ const score = factory.EasyScore();
112
+ const [n0, n1] = score.notes('(c4 e4 g4)/2, (c4 e4 g4)', { stem: 'up' });
113
+ const voice = score.voice([n0, n1]);
114
+ const tie1 = factory.StaveTie({
115
+ from: n0,
116
+ to: n1,
117
+ firstIndexes: [0],
118
+ lastIndexes: [0],
119
+ });
120
+ const tie2 = factory.StaveTie({
121
+ from: n0,
122
+ to: n1,
123
+ firstIndexes: [1, 2],
124
+ lastIndexes: [1, 2],
125
+ options: { direction: Stem.DOWN },
126
+ });
127
+ factory.Formatter().joinVoices([voice]).formatToStave([voice], stave);
128
+ factory.draw();
129
+ options.assert.equal(tie1.getDirection(), Stem.UP);
130
+ options.assert.equal(tie2.getDirection(), Stem.DOWN);
131
+ options.assert.ok(tie1.getFirstX() < tie1.getLastX());
132
+ n1.setStemDirection(Stem.DOWN);
133
+ options.assert.equal(tie1.getDirection(), Stem.DOWN);
134
+ options.assert.equal(tie2.getDirection(), Stem.DOWN);
135
+ }
107
136
  VexFlowTests.register(StaveTieTests);
108
137
  export { StaveTieTests };
@@ -257,7 +257,7 @@ function drawAccidentals(options) {
257
257
  .setContext(ctx)
258
258
  .setEndBarType(BarlineType.DOUBLE)
259
259
  .addClef('treble')
260
- .draw();
260
+ .drawWithStyle();
261
261
  voice.draw(ctx, stave);
262
262
  options.assert.ok(true, 'String Number');
263
263
  }
@@ -267,7 +267,7 @@ function notesWithTab(options) {
267
267
  f.Formatter().joinVoices([voice]).joinVoices([tabVoice]).formatToStave([voice, tabVoice], stave);
268
268
  f.draw();
269
269
  beams.forEach(function (beam) {
270
- beam.setContext(f.getContext()).draw();
270
+ beam.setContext(f.getContext()).drawWithStyle();
271
271
  });
272
272
  options.assert.ok(true);
273
273
  }
@@ -69,7 +69,7 @@ function tab(options, contextBuilder) {
69
69
  ctx.font = '10pt Arial';
70
70
  const stave = new TabStave(10, 10, 450).addTabGlyph();
71
71
  stave.getModifiers()[2].setStyle(FS('blue'));
72
- stave.setContext(ctx).draw();
72
+ stave.setContext(ctx).drawWithStyle();
73
73
  const tabNote = (noteStruct) => new TabNote(noteStruct);
74
74
  const notes = [
75
75
  tabNote({
@@ -66,7 +66,7 @@ function draw(options, contextBuilder) {
66
66
  ctx.font = '10pt Arial';
67
67
  const stave = new TabStave(10, 10, 550);
68
68
  stave.setContext(ctx);
69
- stave.draw();
69
+ stave.drawWithStyle();
70
70
  const notes = [
71
71
  { positions: [{ str: 6, fret: 6 }], duration: '4' },
72
72
  {
@@ -121,7 +121,7 @@ function draw(options, contextBuilder) {
121
121
  const tickContext = new TickContext();
122
122
  tickContext.addTickable(tabNote).preFormat().setX(x);
123
123
  tabNote.setContext(ctx).setStave(stave);
124
- tabNote.draw();
124
+ tabNote.drawWithStyle();
125
125
  return tabNote;
126
126
  }
127
127
  for (let i = 0; i < notes.length; ++i) {
@@ -136,7 +136,7 @@ function drawStemsUp(options, contextBuilder) {
136
136
  ctx.font = '10pt Arial';
137
137
  const stave = new TabStave(10, 30, 550);
138
138
  stave.setContext(ctx);
139
- stave.draw();
139
+ stave.drawWithStyle();
140
140
  const specs = [
141
141
  {
142
142
  positions: [
@@ -204,7 +204,7 @@ function drawStemsDown(options, contextBuilder) {
204
204
  ctx.font = '10pt Arial';
205
205
  const stave = new TabStave(10, 10, 550);
206
206
  stave.setContext(ctx);
207
- stave.draw();
207
+ stave.drawWithStyle();
208
208
  const specs = [
209
209
  {
210
210
  positions: [
@@ -273,7 +273,7 @@ function drawStemsUpThrough(options, contextBuilder) {
273
273
  ctx.font = '10pt Arial';
274
274
  const stave = new TabStave(10, 30, 550);
275
275
  stave.setContext(ctx);
276
- stave.draw();
276
+ stave.drawWithStyle();
277
277
  const specs = [
278
278
  {
279
279
  positions: [
@@ -343,7 +343,7 @@ function drawStemsDownThrough(options, contextBuilder) {
343
343
  ctx.font = '10pt Arial';
344
344
  const stave = new TabStave(10, 10, 550, { numLines: 8 });
345
345
  stave.setContext(ctx);
346
- stave.draw();
346
+ stave.drawWithStyle();
347
347
  const specs = [
348
348
  {
349
349
  positions: [
@@ -417,7 +417,7 @@ function drawStemsDotted(options, contextBuilder) {
417
417
  ctx.font = '10pt Arial';
418
418
  const stave = new TabStave(10, 10, 550);
419
419
  stave.setContext(ctx);
420
- stave.draw();
420
+ stave.drawWithStyle();
421
421
  const specs = [
422
422
  {
423
423
  positions: [
@@ -26,13 +26,13 @@ function tieNotes(notes, indexes, stave, ctx) {
26
26
  lastIndexes: indexes,
27
27
  }, TabSlide.SLIDE_UP);
28
28
  tie.setContext(ctx);
29
- tie.draw();
29
+ tie.drawWithStyle();
30
30
  }
31
31
  function setupContext(options, width) {
32
32
  const context = options.contextBuilder(options.elementId, 350, 140);
33
33
  context.scale(0.9, 0.9);
34
34
  context.font = '10pt Arial';
35
- const stave = new TabStave(10, 10, width || 350).addTabGlyph().setContext(context).draw();
35
+ const stave = new TabStave(10, 10, width || 350).addTabGlyph().setContext(context).drawWithStyle();
36
36
  return { context, stave };
37
37
  }
38
38
  const tabNote = (noteStruct) => new TabNote(noteStruct);
@@ -91,7 +91,7 @@ function multiTest(options, buildTabSlide) {
91
91
  lastIndexes: [0],
92
92
  })
93
93
  .setContext(context)
94
- .draw();
94
+ .drawWithStyle();
95
95
  options.assert.ok(true, 'Single note');
96
96
  buildTabSlide({
97
97
  firstNote: notes[2],
@@ -100,7 +100,7 @@ function multiTest(options, buildTabSlide) {
100
100
  lastIndexes: [0, 1],
101
101
  })
102
102
  .setContext(context)
103
- .draw();
103
+ .drawWithStyle();
104
104
  options.assert.ok(true, 'Chord');
105
105
  buildTabSlide({
106
106
  firstNote: notes[4],
@@ -109,7 +109,7 @@ function multiTest(options, buildTabSlide) {
109
109
  lastIndexes: [0],
110
110
  })
111
111
  .setContext(context)
112
- .draw();
112
+ .drawWithStyle();
113
113
  options.assert.ok(true, 'Single note high-fret');
114
114
  buildTabSlide({
115
115
  firstNote: notes[6],
@@ -118,7 +118,7 @@ function multiTest(options, buildTabSlide) {
118
118
  lastIndexes: [0, 1],
119
119
  })
120
120
  .setContext(context)
121
- .draw();
121
+ .drawWithStyle();
122
122
  options.assert.ok(true, 'Chord high-fret');
123
123
  }
124
124
  function slideUp(options, contextBuilder) {
@@ -10,9 +10,10 @@ const TabStaveTests = {
10
10
  function draw(options, contextBuilder) {
11
11
  const ctx = contextBuilder(options.elementId, 400, 160);
12
12
  const stave = new TabStave(10, 10, 300);
13
+ stave.setMeasure(1);
13
14
  stave.setNumLines(6);
14
15
  stave.setContext(ctx);
15
- stave.draw();
16
+ stave.drawWithStyle();
16
17
  options.assert.equal(stave.getYForNote(0), 127, 'getYForNote(0)');
17
18
  options.assert.equal(stave.getYForLine(5), 127, 'getYForLine(5)');
18
19
  options.assert.equal(stave.getYForLine(0), 62, 'getYForLine(0) - Top Line');
@@ -21,7 +21,7 @@ const tabNote = (noteStruct) => new TabNote(noteStruct);
21
21
  function setupContext(options, w = 0, h = 0) {
22
22
  const context = options.contextBuilder(options.elementId, w || 350, h || 160);
23
23
  context.setFont('Arial', VexFlowTests.Font.size);
24
- const stave = new TabStave(10, 10, w || 350).addTabGlyph().setContext(context).draw();
24
+ const stave = new TabStave(10, 10, w || 350).addTabGlyph().setContext(context).drawWithStyle();
25
25
  return { context, stave };
26
26
  }
27
27
  function tieNotes(notes, indexes, stave, ctx, text) {
@@ -36,7 +36,7 @@ function tieNotes(notes, indexes, stave, ctx, text) {
36
36
  lastIndexes: indexes,
37
37
  }, text !== null && text !== void 0 ? text : 'Annotation');
38
38
  tie.setContext(ctx);
39
- tie.draw();
39
+ tie.drawWithStyle();
40
40
  }
41
41
  function simple(options, contextBuilder) {
42
42
  options.contextBuilder = contextBuilder;
@@ -100,7 +100,7 @@ function multiTest(options, createTabTie) {
100
100
  lastIndexes: [0],
101
101
  })
102
102
  .setContext(context)
103
- .draw();
103
+ .drawWithStyle();
104
104
  options.assert.ok(true, 'Single note');
105
105
  createTabTie({
106
106
  firstNote: notes[2],
@@ -109,7 +109,7 @@ function multiTest(options, createTabTie) {
109
109
  lastIndexes: [0, 1],
110
110
  })
111
111
  .setContext(context)
112
- .draw();
112
+ .drawWithStyle();
113
113
  options.assert.ok(true, 'Chord');
114
114
  createTabTie({
115
115
  firstNote: notes[4],
@@ -118,7 +118,7 @@ function multiTest(options, createTabTie) {
118
118
  lastIndexes: [0],
119
119
  })
120
120
  .setContext(context)
121
- .draw();
121
+ .drawWithStyle();
122
122
  options.assert.ok(true, 'Single note high-fret');
123
123
  createTabTie({
124
124
  firstNote: notes[6],
@@ -127,7 +127,7 @@ function multiTest(options, createTabTie) {
127
127
  lastIndexes: [0, 1],
128
128
  })
129
129
  .setContext(context)
130
- .draw();
130
+ .drawWithStyle();
131
131
  options.assert.ok(true, 'Chord high-fret');
132
132
  }
133
133
  function tap(options, contextBuilder) {
@@ -156,7 +156,7 @@ function continuous(options, contextBuilder) {
156
156
  lastIndexes: [0],
157
157
  })
158
158
  .setContext(context)
159
- .draw();
159
+ .drawWithStyle();
160
160
  TabTie.createPulloff({
161
161
  firstNote: notes[1],
162
162
  lastNote: notes[2],
@@ -164,7 +164,7 @@ function continuous(options, contextBuilder) {
164
164
  lastIndexes: [0],
165
165
  })
166
166
  .setContext(context)
167
- .draw();
167
+ .drawWithStyle();
168
168
  options.assert.ok(true, 'Continuous Hammeron');
169
169
  }
170
170
  VexFlowTests.register(TabTieTests);
@@ -208,7 +208,7 @@ function textDynamics(options) {
208
208
  const width = formatter.preCalculateMinTotalWidth([voice]);
209
209
  formatter.format([voice]);
210
210
  const stave = f.Stave({ y: 40, width: width + Stave.defaultPadding });
211
- stave.draw();
211
+ stave.drawWithStyle();
212
212
  voice.draw(f.getContext(), stave);
213
213
  options.assert.ok(true);
214
214
  }
@@ -28,7 +28,7 @@ function createThreeVoicesTest(noteGroup1, noteGroup2, noteGroup3, setup) {
28
28
  factory.Formatter().joinVoices(voices).formatToStave(voices, stave);
29
29
  factory.draw();
30
30
  for (let i = 0; i < beams.length; i++) {
31
- beams[i].setContext(factory.getContext()).draw();
31
+ beams[i].setContext(factory.getContext()).drawWithStyle();
32
32
  }
33
33
  options.assert.ok(true);
34
34
  };
@@ -81,7 +81,7 @@ function autoRestTwoVoices(options) {
81
81
  createMeasure('Rests Repositioned To Avoid Collisions', 400, true);
82
82
  f.draw();
83
83
  for (let i = 0; i < beams.length; i++) {
84
- beams[i].setContext(f.getContext()).draw();
84
+ beams[i].setContext(f.getContext()).drawWithStyle();
85
85
  }
86
86
  options.assert.ok(true, 'Auto Adjust Rests - Two Voices');
87
87
  }
@@ -54,7 +54,7 @@ function basic(options, contextBuilder) {
54
54
  .addEndTimeSignature('C')
55
55
  .addEndTimeSignature('C|')
56
56
  .setContext(ctx)
57
- .draw();
57
+ .drawWithStyle();
58
58
  options.assert.ok(true, 'all pass');
59
59
  }
60
60
  function big(options, contextBuilder) {
@@ -65,22 +65,32 @@ function big(options, contextBuilder) {
65
65
  .addTimeSignature('1234567/890')
66
66
  .addTimeSignature('987/654321')
67
67
  .setContext(ctx)
68
- .draw();
68
+ .drawWithStyle();
69
69
  options.assert.ok(true, 'all pass');
70
70
  }
71
71
  function additive(options, contextBuilder) {
72
72
  const ctx = contextBuilder(options.elementId, 400, 120);
73
- new Stave(10, 10, 300).addTimeSignature('2+3+2/8').setContext(ctx).draw();
73
+ new Stave(10, 10, 300).addTimeSignature('2+3+2/8').setContext(ctx).drawWithStyle();
74
74
  options.assert.ok(true, 'all pass');
75
75
  }
76
76
  function alternating(options, contextBuilder) {
77
77
  const ctx = contextBuilder(options.elementId, 400, 120);
78
- new Stave(10, 10, 300).addTimeSignature('6/8').addTimeSignature('+').addTimeSignature('3/4').setContext(ctx).draw();
78
+ new Stave(10, 10, 300)
79
+ .addTimeSignature('6/8')
80
+ .addTimeSignature('+')
81
+ .addTimeSignature('3/4')
82
+ .setContext(ctx)
83
+ .drawWithStyle();
79
84
  options.assert.ok(true, 'all pass');
80
85
  }
81
86
  function interchangeable(options, contextBuilder) {
82
87
  const ctx = contextBuilder(options.elementId, 400, 120);
83
- new Stave(10, 10, 300).addTimeSignature('3/4').addTimeSignature('-').addTimeSignature('2/4').setContext(ctx).draw();
88
+ new Stave(10, 10, 300)
89
+ .addTimeSignature('3/4')
90
+ .addTimeSignature('-')
91
+ .addTimeSignature('2/4')
92
+ .setContext(ctx)
93
+ .drawWithStyle();
84
94
  options.assert.ok(true, 'all pass');
85
95
  }
86
96
  function agregate(options, contextBuilder) {
@@ -92,7 +102,7 @@ function agregate(options, contextBuilder) {
92
102
  .addTimeSignature('+')
93
103
  .addTimeSignature('5/4')
94
104
  .setContext(ctx)
95
- .draw();
105
+ .drawWithStyle();
96
106
  options.assert.ok(true, 'all pass');
97
107
  }
98
108
  function complex(options, contextBuilder) {
@@ -102,7 +112,7 @@ function complex(options, contextBuilder) {
102
112
  .addTimeSignature('+')
103
113
  .addTimeSignature('3/8')
104
114
  .setContext(ctx)
105
- .draw();
115
+ .drawWithStyle();
106
116
  options.assert.ok(true, 'all pass');
107
117
  }
108
118
  function multiple(options, contextBuilder) {
@@ -113,13 +123,13 @@ function multiple(options, contextBuilder) {
113
123
  .addClef('percussion')
114
124
  .addTimeSignature('4/4', 25)
115
125
  .setContext(ctx)
116
- .draw();
117
- const stave2 = new Stave(15, 110, 300).addClef('treble').addTimeSignature('4/4').setContext(ctx).draw();
118
- const stave3 = new Stave(15, 220, 300).addClef('bass').addTimeSignature('4/4').setContext(ctx).draw();
126
+ .drawWithStyle();
127
+ const stave2 = new Stave(15, 110, 300).addClef('treble').addTimeSignature('4/4').setContext(ctx).drawWithStyle();
128
+ const stave3 = new Stave(15, 220, 300).addClef('bass').addTimeSignature('4/4').setContext(ctx).drawWithStyle();
119
129
  Stave.formatBegModifiers([stave1, stave2, stave3]);
120
- new StaveConnector(stave1, stave2).setType('single').setContext(ctx).draw();
121
- new StaveConnector(stave2, stave3).setType('single').setContext(ctx).draw();
122
- new StaveConnector(stave2, stave3).setType('brace').setContext(ctx).draw();
130
+ new StaveConnector(stave1, stave2).setType('single').setContext(ctx).drawWithStyle();
131
+ new StaveConnector(stave2, stave3).setType('single').setContext(ctx).drawWithStyle();
132
+ new StaveConnector(stave2, stave3).setType('brace').setContext(ctx).drawWithStyle();
123
133
  options.assert.ok(true, 'all pass');
124
134
  }
125
135
  function change(options) {