vexflow 4.0.1-beta.1 → 4.0.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +92 -24
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +38 -16
- package/build/cjs/vexflow-debug.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-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/entry/vexflow-bravura.js +11 -0
- package/build/esm/entry/vexflow-core.js +54 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +4 -0
- package/build/esm/entry/vexflow-debug.js +3 -0
- package/build/esm/entry/vexflow-font-bravura.js +7 -0
- package/build/esm/entry/vexflow-font-custom.js +7 -0
- package/build/esm/entry/vexflow-font-gonville.js +7 -0
- package/build/esm/entry/vexflow-font-petaluma.js +7 -0
- package/build/esm/entry/vexflow-gonville.js +11 -0
- package/build/esm/entry/vexflow-petaluma.js +11 -0
- package/build/esm/entry/vexflow.js +9 -0
- package/build/esm/src/accidental.js +348 -0
- package/build/esm/src/annotation.js +232 -0
- package/build/esm/src/articulation.js +267 -0
- package/build/esm/src/barnote.js +58 -0
- package/build/esm/src/beam.js +632 -0
- package/build/esm/src/bend.js +202 -0
- package/build/esm/src/boundingbox.js +59 -0
- package/build/esm/src/boundingboxcomputation.js +107 -0
- package/build/esm/src/canvascontext.js +202 -0
- package/build/esm/src/chordsymbol.js +578 -0
- package/build/esm/src/clef.js +153 -0
- package/build/esm/src/clefnote.js +65 -0
- package/build/esm/src/crescendo.js +77 -0
- package/build/esm/src/curve.js +118 -0
- package/build/esm/src/dot.js +137 -0
- package/build/esm/src/easyscore.js +374 -0
- package/build/esm/src/element.js +216 -0
- package/build/esm/src/factory.js +440 -0
- package/build/esm/src/flow.js +275 -0
- package/build/esm/src/font.js +264 -0
- package/build/esm/src/fonts/bravura_glyphs.js +3239 -0
- package/build/esm/src/fonts/bravura_metrics.js +507 -0
- package/build/esm/src/fonts/custom_glyphs.js +78 -0
- package/build/esm/src/fonts/custom_metrics.js +5 -0
- package/build/esm/src/fonts/gonville_glyphs.js +828 -0
- package/build/esm/src/fonts/gonville_metrics.js +421 -0
- package/build/esm/src/fonts/load_all.js +10 -0
- package/build/esm/src/fonts/load_bravura.js +6 -0
- package/build/esm/src/fonts/load_custom.js +6 -0
- package/build/esm/src/fonts/load_gonville.js +6 -0
- package/build/esm/src/fonts/load_petaluma.js +6 -0
- package/build/esm/src/fonts/petaluma_glyphs.js +1335 -0
- package/build/esm/src/fonts/petaluma_metrics.js +536 -0
- package/build/esm/src/fonts/petalumascript_glyphs.js +863 -0
- package/build/esm/src/fonts/robotoslab_glyphs.js +863 -0
- package/build/esm/src/fonts/textfonts.js +44 -0
- package/build/esm/src/formatter.js +568 -0
- package/build/esm/src/fraction.js +171 -0
- package/build/esm/src/frethandfinger.js +156 -0
- package/build/esm/src/ghostnote.js +50 -0
- package/build/esm/src/glyph.js +331 -0
- package/build/esm/src/glyphnote.js +55 -0
- package/build/esm/src/gracenote.js +133 -0
- package/build/esm/src/gracenotegroup.js +128 -0
- package/build/esm/src/gracetabnote.js +12 -0
- package/build/esm/src/index.js +91 -0
- package/build/esm/src/keymanager.js +99 -0
- package/build/esm/src/keysignature.js +250 -0
- package/build/esm/src/keysignote.js +28 -0
- package/build/esm/src/modifier.js +128 -0
- package/build/esm/src/modifiercontext.js +110 -0
- package/build/esm/src/multimeasurerest.js +173 -0
- package/build/esm/src/music.js +322 -0
- package/build/esm/src/note.js +371 -0
- package/build/esm/src/notehead.js +169 -0
- package/build/esm/src/notesubgroup.js +59 -0
- package/build/esm/src/ornament.js +206 -0
- package/build/esm/src/parenthesis.js +76 -0
- package/build/esm/src/parser.js +164 -0
- package/build/esm/src/pedalmarking.js +192 -0
- package/build/esm/src/registry.js +81 -0
- package/build/esm/src/rendercontext.js +24 -0
- package/build/esm/src/renderer.js +112 -0
- package/build/esm/src/repeatnote.js +22 -0
- package/build/esm/src/stave.js +547 -0
- package/build/esm/src/stavebarline.js +182 -0
- package/build/esm/src/staveconnector.js +196 -0
- package/build/esm/src/stavehairpin.js +120 -0
- package/build/esm/src/staveline.js +218 -0
- package/build/esm/src/stavemodifier.js +77 -0
- package/build/esm/src/stavenote.js +855 -0
- package/build/esm/src/staverepetition.js +155 -0
- package/build/esm/src/stavesection.js +58 -0
- package/build/esm/src/stavetempo.js +91 -0
- package/build/esm/src/stavetext.js +82 -0
- package/build/esm/src/stavetie.js +141 -0
- package/build/esm/src/stavevolta.js +67 -0
- package/build/esm/src/stem.js +131 -0
- package/build/esm/src/stemmablenote.js +193 -0
- package/build/esm/src/stringnumber.js +231 -0
- package/build/esm/src/strokes.js +200 -0
- package/build/esm/src/svgcontext.js +414 -0
- package/build/esm/src/system.js +116 -0
- package/build/esm/src/tables.js +1102 -0
- package/build/esm/src/tabnote.js +299 -0
- package/build/esm/src/tabslide.js +76 -0
- package/build/esm/src/tabstave.js +17 -0
- package/build/esm/src/tabtie.js +19 -0
- package/build/esm/src/textbracket.js +144 -0
- package/build/esm/src/textdynamics.js +81 -0
- package/build/esm/src/textformatter.js +177 -0
- package/build/esm/src/textnote.js +176 -0
- package/build/esm/src/tickable.js +214 -0
- package/build/esm/src/tickcontext.js +170 -0
- package/build/esm/src/timesigglyph.js +85 -0
- package/build/esm/src/timesignature.js +89 -0
- package/build/esm/src/timesignote.js +32 -0
- package/build/esm/src/tremolo.js +47 -0
- package/build/esm/src/tuning.js +54 -0
- package/build/esm/src/tuplet.js +240 -0
- package/build/esm/src/typeguard.js +30 -0
- package/build/esm/src/util.js +58 -0
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vex.js +51 -0
- package/build/esm/src/vibrato.js +100 -0
- package/build/esm/src/vibratobracket.js +50 -0
- package/build/esm/src/voice.js +187 -0
- package/build/esm/src/web.js +15 -0
- package/build/esm/tests/accidental_tests.js +974 -0
- package/build/esm/tests/annotation_tests.js +377 -0
- package/build/esm/tests/articulation_tests.js +365 -0
- package/build/esm/tests/auto_beam_formatting_tests.js +548 -0
- package/build/esm/tests/bach_tests.js +335 -0
- package/build/esm/tests/barline_tests.js +52 -0
- package/build/esm/tests/beam_tests.js +595 -0
- package/build/esm/tests/bend_tests.js +215 -0
- package/build/esm/tests/boundingbox_tests.js +53 -0
- package/build/esm/tests/boundingboxcomputation_tests.js +183 -0
- package/build/esm/tests/chordsymbol_tests.js +320 -0
- package/build/esm/tests/clef_tests.js +131 -0
- package/build/esm/tests/curve_tests.js +118 -0
- package/build/esm/tests/dot_tests.js +123 -0
- package/build/esm/tests/easyscore_tests.js +459 -0
- package/build/esm/tests/factory_tests.js +44 -0
- package/build/esm/tests/font_tests.js +135 -0
- package/build/esm/tests/formatter/framestack.js +61 -0
- package/build/esm/tests/formatter/tests.js +203 -0
- package/build/esm/tests/formatter_tests.js +669 -0
- package/build/esm/tests/fraction_tests.js +72 -0
- package/build/esm/tests/ghostnote_tests.js +77 -0
- package/build/esm/tests/glyphnote_tests.js +113 -0
- package/build/esm/tests/gracenote_tests.js +413 -0
- package/build/esm/tests/gracetabnote_tests.js +79 -0
- package/build/esm/tests/index.js +68 -0
- package/build/esm/tests/key_clef_tests.js +103 -0
- package/build/esm/tests/keymanager_tests.js +68 -0
- package/build/esm/tests/keysignature_tests.js +308 -0
- package/build/esm/tests/mocks.js +71 -0
- package/build/esm/tests/modifier_tests.js +24 -0
- package/build/esm/tests/multimeasurerest_tests.js +141 -0
- package/build/esm/tests/music_tests.js +161 -0
- package/build/esm/tests/notehead_tests.js +137 -0
- package/build/esm/tests/notesubgroup_tests.js +149 -0
- package/build/esm/tests/offscreencanvas_tests.js +47 -0
- package/build/esm/tests/ornament_tests.js +298 -0
- package/build/esm/tests/parser_tests.js +122 -0
- package/build/esm/tests/pedalmarking_tests.js +64 -0
- package/build/esm/tests/percussion_tests.js +180 -0
- package/build/esm/tests/registry_tests.js +64 -0
- package/build/esm/tests/renderer_tests.js +113 -0
- package/build/esm/tests/rests_tests.js +248 -0
- package/build/esm/tests/rhythm_tests.js +357 -0
- package/build/esm/tests/stave_tests.js +560 -0
- package/build/esm/tests/staveconnector_tests.js +402 -0
- package/build/esm/tests/stavehairpin_tests.js +90 -0
- package/build/esm/tests/staveline_tests.js +122 -0
- package/build/esm/tests/stavemodifier_tests.js +51 -0
- package/build/esm/tests/stavenote_tests.js +867 -0
- package/build/esm/tests/stavetie_tests.js +108 -0
- package/build/esm/tests/stringnumber_tests.js +259 -0
- package/build/esm/tests/strokes_tests.js +275 -0
- package/build/esm/tests/style_tests.js +98 -0
- package/build/esm/tests/support/qunit.js +2765 -0
- package/build/esm/tests/tabnote_tests.js +474 -0
- package/build/esm/tests/tabslide_tests.js +135 -0
- package/build/esm/tests/tabstave_tests.js +23 -0
- package/build/esm/tests/tabtie_tests.js +173 -0
- package/build/esm/tests/textbracket_tests.js +100 -0
- package/build/esm/tests/textformatter_tests.js +24 -0
- package/build/esm/tests/textnote_tests.js +215 -0
- package/build/esm/tests/threevoice_tests.js +132 -0
- package/build/esm/tests/tickcontext_tests.js +36 -0
- package/build/esm/tests/timesignature_tests.js +134 -0
- package/build/esm/tests/tremolo_tests.js +75 -0
- package/build/esm/tests/tuning_tests.js +56 -0
- package/build/esm/tests/tuplet_tests.js +450 -0
- package/build/esm/tests/typeguard_tests.js +82 -0
- package/build/esm/tests/vexflow_test_helpers.js +266 -0
- package/build/esm/tests/vf_prefix_tests.js +115 -0
- package/build/esm/tests/vibrato_tests.js +92 -0
- package/build/esm/tests/vibratobracket_tests.js +45 -0
- package/build/esm/tests/voice_tests.js +69 -0
- package/build/types/entry/vexflow-bravura.d.ts +3 -0
- package/build/types/entry/vexflow-core.d.ts +3 -0
- package/build/types/entry/vexflow-debug.d.ts +3 -0
- package/build/types/entry/vexflow-font-bravura.d.ts +3771 -0
- package/build/types/entry/vexflow-font-custom.d.ts +86 -0
- package/build/types/entry/vexflow-font-gonville.d.ts +1267 -0
- package/build/types/entry/vexflow-font-petaluma.d.ts +1896 -0
- package/build/types/entry/vexflow-gonville.d.ts +3 -0
- package/build/types/entry/vexflow-petaluma.d.ts +3 -0
- package/build/types/entry/vexflow.d.ts +3 -0
- package/build/types/src/accidental.d.ts +66 -0
- package/build/types/src/annotation.d.ts +60 -0
- package/build/types/src/articulation.d.ts +62 -0
- package/build/types/src/barnote.d.ts +29 -0
- package/build/types/src/beam.d.ts +124 -0
- package/build/types/src/bend.d.ts +73 -0
- package/build/types/src/boundingbox.d.ts +42 -0
- package/build/types/src/boundingboxcomputation.d.ts +33 -0
- package/build/types/src/canvascontext.d.ts +89 -0
- package/build/types/src/chordsymbol.d.ts +149 -0
- package/build/types/src/clef.d.ts +48 -0
- package/build/types/src/clefnote.d.ts +25 -0
- package/build/types/src/crescendo.d.ts +27 -0
- package/build/types/src/curve.d.ts +41 -0
- package/build/types/src/dot.d.ts +20 -0
- package/build/types/src/easyscore.d.ts +148 -0
- package/build/types/src/element.d.ts +202 -0
- package/build/types/src/factory.d.ts +271 -0
- package/build/types/src/flow.d.ts +245 -0
- package/build/types/src/font.d.ts +181 -0
- package/build/types/src/fonts/bravura_glyphs.d.ts +3239 -0
- package/build/types/src/fonts/bravura_metrics.d.ts +533 -0
- package/build/types/src/fonts/custom_glyphs.d.ts +78 -0
- package/build/types/src/fonts/custom_metrics.d.ts +5 -0
- package/build/types/src/fonts/gonville_glyphs.d.ts +828 -0
- package/build/types/src/fonts/gonville_metrics.d.ts +440 -0
- package/build/types/src/fonts/load_all.d.ts +1 -0
- package/build/types/src/fonts/load_bravura.d.ts +1 -0
- package/build/types/src/fonts/load_custom.d.ts +1 -0
- package/build/types/src/fonts/load_gonville.d.ts +1 -0
- package/build/types/src/fonts/load_petaluma.d.ts +1 -0
- package/build/types/src/fonts/petaluma_glyphs.d.ts +1335 -0
- package/build/types/src/fonts/petaluma_metrics.d.ts +562 -0
- package/build/types/src/fonts/petalumascript_glyphs.d.ts +863 -0
- package/build/types/src/fonts/robotoslab_glyphs.d.ts +863 -0
- package/build/types/src/fonts/textfonts.d.ts +1 -0
- package/build/types/src/formatter.d.ts +203 -0
- package/build/types/src/fraction.d.ts +62 -0
- package/build/types/src/frethandfinger.d.ts +22 -0
- package/build/types/src/ghostnote.d.ts +16 -0
- package/build/types/src/glyph.d.ts +139 -0
- package/build/types/src/glyphnote.d.ts +17 -0
- package/build/types/src/gracenote.d.ts +19 -0
- package/build/types/src/gracenotegroup.d.ts +33 -0
- package/build/types/src/gracetabnote.d.ts +5 -0
- package/build/types/src/index.d.ts +91 -0
- package/build/types/src/keymanager.d.ts +25 -0
- package/build/types/src/keysignature.d.ts +50 -0
- package/build/types/src/keysignote.d.ts +11 -0
- package/build/types/src/modifier.d.ts +97 -0
- package/build/types/src/modifiercontext.d.ts +45 -0
- package/build/types/src/multimeasurerest.d.ts +61 -0
- package/build/types/src/music.d.ts +91 -0
- package/build/types/src/note.d.ts +231 -0
- package/build/types/src/notehead.d.ts +70 -0
- package/build/types/src/notesubgroup.d.ts +18 -0
- package/build/types/src/ornament.d.ts +76 -0
- package/build/types/src/parenthesis.d.ts +22 -0
- package/build/types/src/parser.d.ts +45 -0
- package/build/types/src/pedalmarking.d.ts +69 -0
- package/build/types/src/registry.d.ts +40 -0
- package/build/types/src/rendercontext.d.ts +64 -0
- package/build/types/src/renderer.d.ts +35 -0
- package/build/types/src/repeatnote.d.ts +6 -0
- package/build/types/src/stave.d.ts +186 -0
- package/build/types/src/stavebarline.d.ts +28 -0
- package/build/types/src/staveconnector.d.ts +67 -0
- package/build/types/src/stavehairpin.d.ts +56 -0
- package/build/types/src/staveline.d.ts +57 -0
- package/build/types/src/stavemodifier.d.ts +44 -0
- package/build/types/src/stavenote.d.ts +154 -0
- package/build/types/src/staverepetition.d.ts +32 -0
- package/build/types/src/stavesection.d.ts +15 -0
- package/build/types/src/stavetempo.d.ts +25 -0
- package/build/types/src/stavetext.d.ts +25 -0
- package/build/types/src/stavetie.d.ts +59 -0
- package/build/types/src/stavevolta.d.ts +21 -0
- package/build/types/src/stem.d.ts +58 -0
- package/build/types/src/stemmablenote.d.ts +39 -0
- package/build/types/src/stringnumber.d.ts +27 -0
- package/build/types/src/strokes.d.ts +33 -0
- package/build/types/src/svgcontext.d.ts +131 -0
- package/build/types/src/system.d.ts +92 -0
- package/build/types/src/tables.d.ts +96 -0
- package/build/types/src/tabnote.d.ts +44 -0
- package/build/types/src/tabslide.d.ts +34 -0
- package/build/types/src/tabstave.d.ts +7 -0
- package/build/types/src/tabtie.d.ts +18 -0
- package/build/types/src/textbracket.d.ts +55 -0
- package/build/types/src/textdynamics.d.ts +39 -0
- package/build/types/src/textformatter.d.ts +109 -0
- package/build/types/src/textnote.d.ts +49 -0
- package/build/types/src/tickable.d.ts +140 -0
- package/build/types/src/tickcontext.d.ts +82 -0
- package/build/types/src/timesigglyph.d.ts +14 -0
- package/build/types/src/timesignature.d.ts +26 -0
- package/build/types/src/timesignote.d.ts +11 -0
- package/build/types/src/tremolo.d.ts +17 -0
- package/build/types/src/tuning.d.ts +23 -0
- package/build/types/src/tuplet.d.ts +105 -0
- package/build/types/src/typeguard.d.ts +99 -0
- package/build/types/src/util.d.ts +27 -0
- package/build/types/src/version.d.ts +3 -0
- package/build/types/src/vex.d.ts +18 -0
- package/build/types/src/vibrato.d.ts +29 -0
- package/build/types/src/vibratobracket.d.ts +33 -0
- package/build/types/src/voice.d.ts +108 -0
- package/build/types/src/web.d.ts +2 -0
- package/package.json +1 -1
- package/src/annotation.ts +27 -6
- package/src/articulation.ts +8 -2
- package/src/fonts/gonville_glyphs.ts +4 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { EasyScore, Factory, Registry, StaveNote } from '../src/index.js';
|
|
3
|
+
const RegistryTests = {
|
|
4
|
+
Start() {
|
|
5
|
+
QUnit.module('Registry');
|
|
6
|
+
test('Register and Clear', registerAndClear);
|
|
7
|
+
test('Default Registry', defaultRegistry);
|
|
8
|
+
test('Multiple Classes', classes);
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
function registerAndClear() {
|
|
12
|
+
const registry = new Registry();
|
|
13
|
+
const score = new EasyScore({ factory: Factory.newFromElementId(null) });
|
|
14
|
+
registry.register(score.notes('C4')[0], 'foobar');
|
|
15
|
+
const foobar = registry.getElementById('foobar');
|
|
16
|
+
ok(foobar);
|
|
17
|
+
equal(foobar.getAttribute('id'), 'foobar');
|
|
18
|
+
registry.clear();
|
|
19
|
+
notOk(registry.getElementById('foobar'));
|
|
20
|
+
throws(() => registry.register(score.notes('C4')));
|
|
21
|
+
registry.clear();
|
|
22
|
+
ok(registry.register(score.notes('C4[id="boobar"]')[0]).getElementById('boobar'));
|
|
23
|
+
}
|
|
24
|
+
function defaultRegistry() {
|
|
25
|
+
const registry = new Registry();
|
|
26
|
+
const score = new EasyScore({ factory: Factory.newFromElementId(null) });
|
|
27
|
+
Registry.enableDefaultRegistry(registry);
|
|
28
|
+
score.notes('C4[id="foobar"]');
|
|
29
|
+
const note = registry.getElementById('foobar');
|
|
30
|
+
ok(note);
|
|
31
|
+
note.setAttribute('id', 'boobar');
|
|
32
|
+
ok(registry.getElementById('boobar'));
|
|
33
|
+
notOk(registry.getElementById('foobar'));
|
|
34
|
+
registry.clear();
|
|
35
|
+
equal(registry.getElementsByType(StaveNote.CATEGORY).length, 0);
|
|
36
|
+
score.notes('C5');
|
|
37
|
+
const elements = registry.getElementsByType(StaveNote.CATEGORY);
|
|
38
|
+
equal(elements.length, 1);
|
|
39
|
+
}
|
|
40
|
+
function classes() {
|
|
41
|
+
const registry = new Registry();
|
|
42
|
+
const score = new EasyScore({ factory: Factory.newFromElementId(null) });
|
|
43
|
+
Registry.enableDefaultRegistry(registry);
|
|
44
|
+
score.notes('C4[id="foobar"]');
|
|
45
|
+
const note = registry.getElementById('foobar');
|
|
46
|
+
note.addClass('foo');
|
|
47
|
+
ok(note.hasClass('foo'));
|
|
48
|
+
notOk(note.hasClass('boo'));
|
|
49
|
+
equal(registry.getElementsByClass('foo').length, 1);
|
|
50
|
+
equal(registry.getElementsByClass('boo').length, 0);
|
|
51
|
+
note.addClass('boo');
|
|
52
|
+
ok(note.hasClass('foo'));
|
|
53
|
+
ok(note.hasClass('boo'));
|
|
54
|
+
equal(registry.getElementsByClass('foo').length, 1);
|
|
55
|
+
equal(registry.getElementsByClass('boo').length, 1);
|
|
56
|
+
note.removeClass('boo');
|
|
57
|
+
note.removeClass('foo');
|
|
58
|
+
notOk(note.hasClass('foo'));
|
|
59
|
+
notOk(note.hasClass('boo'));
|
|
60
|
+
equal(registry.getElementsByClass('foo').length, 0);
|
|
61
|
+
equal(registry.getElementsByClass('boo').length, 0);
|
|
62
|
+
}
|
|
63
|
+
VexFlowTests.register(RegistryTests);
|
|
64
|
+
export { RegistryTests };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { CanvasContext, Factory, Formatter, isHTMLCanvas, Renderer, RuntimeError, Stave, StaveNote, SVGContext, } from '../src/index.js';
|
|
3
|
+
const STAVE_WIDTH = 700;
|
|
4
|
+
const STAVE_HEIGHT = 100;
|
|
5
|
+
const STAVE_RIGHT_MARGIN = 10;
|
|
6
|
+
const USE_RENDERER = { useRendererAPI: true };
|
|
7
|
+
const USE_FACTORY = { useRendererAPI: false };
|
|
8
|
+
const RendererTests = {
|
|
9
|
+
Start() {
|
|
10
|
+
QUnit.module('Renderer');
|
|
11
|
+
const run = VexFlowTests.runTests;
|
|
12
|
+
run('Random', random);
|
|
13
|
+
run('Renderer API with element ID string', stringElementId, USE_RENDERER);
|
|
14
|
+
run('Renderer API with canvas or div', canvasOrDivElement, USE_RENDERER);
|
|
15
|
+
run('Renderer API with context', passRenderContext);
|
|
16
|
+
run('Factory API with element ID string', stringElementId, USE_FACTORY);
|
|
17
|
+
run('Factory API with canvas or div', canvasOrDivElement, USE_FACTORY);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
function drawStave(stave, context) {
|
|
21
|
+
stave.addClef('bass').addTimeSignature('3/4').draw();
|
|
22
|
+
Formatter.FormatAndDraw(context, stave, [
|
|
23
|
+
new StaveNote({ keys: ['C/4'], duration: '4' }),
|
|
24
|
+
new StaveNote({ keys: ['E/4'], duration: '4' }),
|
|
25
|
+
new StaveNote({ keys: ['G/4'], duration: '4' }),
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
function random(options) {
|
|
29
|
+
const useElementIDString = Math.random() > 0.5;
|
|
30
|
+
const useRendererAPI = Math.random() > 0.5;
|
|
31
|
+
options.params = { useRendererAPI };
|
|
32
|
+
if (useElementIDString) {
|
|
33
|
+
stringElementId(options);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
canvasOrDivElement(options);
|
|
37
|
+
}
|
|
38
|
+
const element = document.getElementById(options.elementId);
|
|
39
|
+
const colorForElementType = useElementIDString ? '#CCCCCC' : '#0074d9';
|
|
40
|
+
const lineStyleForWhichAPI = useRendererAPI ? 'solid' : 'dashed';
|
|
41
|
+
const borderStyle = `3px ${lineStyleForWhichAPI} ${colorForElementType}`;
|
|
42
|
+
let elementType;
|
|
43
|
+
if (options.backend === Renderer.Backends.CANVAS) {
|
|
44
|
+
element.style.border = borderStyle;
|
|
45
|
+
elementType = '<canvas> element object';
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
element.children[0].style.border = borderStyle;
|
|
49
|
+
elementType = '<svg> element object';
|
|
50
|
+
}
|
|
51
|
+
if (useElementIDString) {
|
|
52
|
+
elementType = 'elementID string';
|
|
53
|
+
}
|
|
54
|
+
const whichAPI = useRendererAPI ? 'Renderer API' : 'Factory API';
|
|
55
|
+
element.parentElement.insertAdjacentHTML('beforeend', `<div style='position:relative; bottom: 100px; font-size: 12pt;'>` +
|
|
56
|
+
`<span style="border-bottom: ${borderStyle}; padding-bottom: 3px; ${lineStyleForWhichAPI}">${whichAPI}</span>` +
|
|
57
|
+
` with ` +
|
|
58
|
+
`<span style="background-color:${colorForElementType}; padding: 3px; color:white;">${elementType}</span>` +
|
|
59
|
+
`</div><br>`);
|
|
60
|
+
}
|
|
61
|
+
function useRendererAPI(e, backend) {
|
|
62
|
+
const renderer = new Renderer(e, backend);
|
|
63
|
+
renderer.resize(STAVE_WIDTH, STAVE_HEIGHT);
|
|
64
|
+
const context = renderer.getContext();
|
|
65
|
+
drawStave(new Stave(0, 0, STAVE_WIDTH - STAVE_RIGHT_MARGIN).setContext(context), context);
|
|
66
|
+
}
|
|
67
|
+
function useFactoryAPI(e, backend) {
|
|
68
|
+
const opts = {
|
|
69
|
+
renderer: { elementId: e, width: STAVE_WIDTH, height: STAVE_HEIGHT, backend },
|
|
70
|
+
};
|
|
71
|
+
const factory = new Factory(opts);
|
|
72
|
+
drawStave(factory.Stave(), factory.getContext());
|
|
73
|
+
}
|
|
74
|
+
function stringElementId(options) {
|
|
75
|
+
const elementId = options.elementId;
|
|
76
|
+
if (options.params.useRendererAPI) {
|
|
77
|
+
useRendererAPI(elementId, options.backend);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
useFactoryAPI(elementId, options.backend);
|
|
81
|
+
}
|
|
82
|
+
ok(true);
|
|
83
|
+
}
|
|
84
|
+
function canvasOrDivElement(options) {
|
|
85
|
+
const element = document.getElementById(options.elementId);
|
|
86
|
+
if (options.params.useRendererAPI) {
|
|
87
|
+
useRendererAPI(element, options.backend);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
useFactoryAPI(element, options.backend);
|
|
91
|
+
}
|
|
92
|
+
ok(true);
|
|
93
|
+
}
|
|
94
|
+
function passRenderContext(options) {
|
|
95
|
+
let context;
|
|
96
|
+
const element = document.getElementById(options.elementId);
|
|
97
|
+
if (isHTMLCanvas(element)) {
|
|
98
|
+
const ctx = element.getContext('2d');
|
|
99
|
+
if (!ctx) {
|
|
100
|
+
throw new RuntimeError(`Couldn't get context from element "${options.elementId}"`);
|
|
101
|
+
}
|
|
102
|
+
context = new CanvasContext(ctx);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
context = new SVGContext(element);
|
|
106
|
+
}
|
|
107
|
+
const renderer = new Renderer(context);
|
|
108
|
+
renderer.resize(STAVE_WIDTH, STAVE_HEIGHT);
|
|
109
|
+
drawStave(new Stave(0, 0, STAVE_WIDTH - STAVE_RIGHT_MARGIN).setContext(context), context);
|
|
110
|
+
ok(true);
|
|
111
|
+
}
|
|
112
|
+
VexFlowTests.register(RendererTests);
|
|
113
|
+
export { RendererTests };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Beam } from '../src/beam.js';
|
|
3
|
+
import { Dot } from '../src/dot.js';
|
|
4
|
+
import { Flow } from '../src/flow.js';
|
|
5
|
+
import { Formatter } from '../src/formatter.js';
|
|
6
|
+
import { Stave } from '../src/stave.js';
|
|
7
|
+
import { StaveNote } from '../src/stavenote.js';
|
|
8
|
+
import { Tuplet } from '../src/tuplet.js';
|
|
9
|
+
import { Voice } from '../src/voice.js';
|
|
10
|
+
const RestsTests = {
|
|
11
|
+
Start() {
|
|
12
|
+
QUnit.module('Rests');
|
|
13
|
+
const run = VexFlowTests.runTests;
|
|
14
|
+
run('Rests - Dotted', basic);
|
|
15
|
+
run('Auto Align Rests - Beamed Notes Stems Up', beamsUp);
|
|
16
|
+
run('Auto Align Rests - Beamed Notes Stems Down', beamsDown);
|
|
17
|
+
run('Auto Align Rests - Tuplets Stems Up', tupletsUp);
|
|
18
|
+
run('Auto Align Rests - Tuplets Stems Down', tupletsDown);
|
|
19
|
+
run('Auto Align Rests - Single Voice (Default)', singleVoiceDefaultAlignment);
|
|
20
|
+
run('Auto Align Rests - Single Voice (Align All)', singleVoiceAlignAll);
|
|
21
|
+
run('Auto Align Rests - Multi Voice', multiVoice);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
function setupContext(options, contextBuilder, width = 350, height = 150) {
|
|
25
|
+
const context = contextBuilder(options.elementId, width, height);
|
|
26
|
+
context.scale(0.9, 0.9);
|
|
27
|
+
context.fillStyle = '#221';
|
|
28
|
+
context.strokeStyle = '#221';
|
|
29
|
+
context.font = '10pt Arial';
|
|
30
|
+
const stave = new Stave(10, 30, width).addClef('treble').addTimeSignature('4/4').setContext(context).draw();
|
|
31
|
+
return { context, stave };
|
|
32
|
+
}
|
|
33
|
+
function basic(options, contextBuilder) {
|
|
34
|
+
const { context, stave } = setupContext(options, contextBuilder, 700);
|
|
35
|
+
const notes = [
|
|
36
|
+
new StaveNote({ keys: ['b/4'], stem_direction: 1, duration: 'wr' }),
|
|
37
|
+
new StaveNote({ keys: ['b/4'], stem_direction: 1, duration: 'hr' }),
|
|
38
|
+
new StaveNote({ keys: ['b/4'], stem_direction: 1, duration: '4r' }),
|
|
39
|
+
new StaveNote({ keys: ['b/4'], stem_direction: 1, duration: '8r' }),
|
|
40
|
+
new StaveNote({ keys: ['b/4'], stem_direction: 1, duration: '16r' }),
|
|
41
|
+
new StaveNote({ keys: ['b/4'], stem_direction: 1, duration: '32r' }),
|
|
42
|
+
new StaveNote({ keys: ['b/4'], stem_direction: 1, duration: '64r' }),
|
|
43
|
+
new StaveNote({ keys: ['b/4'], stem_direction: 1, duration: '128r' }),
|
|
44
|
+
];
|
|
45
|
+
Dot.buildAndAttach(notes, { all: true });
|
|
46
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
47
|
+
ok(true, 'Dotted Rest Test');
|
|
48
|
+
}
|
|
49
|
+
const note = (noteStruct) => new StaveNote(noteStruct);
|
|
50
|
+
function beamsUp(options, contextBuilder) {
|
|
51
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
52
|
+
const notes = [
|
|
53
|
+
note({ keys: ['e/5'], stem_direction: 1, duration: '8' }),
|
|
54
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '8r' }),
|
|
55
|
+
note({ keys: ['b/5'], stem_direction: 1, duration: '8' }),
|
|
56
|
+
note({ keys: ['c/5'], stem_direction: 1, duration: '8' }),
|
|
57
|
+
note({ keys: ['b/4', 'd/5', 'a/5'], stem_direction: 1, duration: '8' }),
|
|
58
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '8r' }),
|
|
59
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '8r' }),
|
|
60
|
+
note({ keys: ['c/4'], stem_direction: 1, duration: '8' }),
|
|
61
|
+
note({ keys: ['b/4', 'd/5', 'a/5'], stem_direction: 1, duration: '8' }),
|
|
62
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '8' }),
|
|
63
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '8r' }),
|
|
64
|
+
note({ keys: ['c/4'], stem_direction: 1, duration: '8' }),
|
|
65
|
+
];
|
|
66
|
+
const beam1 = new Beam(notes.slice(0, 4));
|
|
67
|
+
const beam2 = new Beam(notes.slice(4, 8));
|
|
68
|
+
const beam3 = new Beam(notes.slice(8, 12));
|
|
69
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
70
|
+
beam1.setContext(context).draw();
|
|
71
|
+
beam2.setContext(context).draw();
|
|
72
|
+
beam3.setContext(context).draw();
|
|
73
|
+
ok(true, 'Auto Align Rests - Beams Up Test');
|
|
74
|
+
}
|
|
75
|
+
function beamsDown(options, contextBuilder) {
|
|
76
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
77
|
+
const notes = [
|
|
78
|
+
note({ keys: ['a/5'], stem_direction: -1, duration: '8' }),
|
|
79
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
80
|
+
note({ keys: ['b/5'], stem_direction: -1, duration: '8' }),
|
|
81
|
+
note({ keys: ['c/5'], stem_direction: -1, duration: '8' }),
|
|
82
|
+
note({ keys: ['b/4', 'd/5', 'a/5'], stem_direction: -1, duration: '8' }),
|
|
83
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
84
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
85
|
+
note({ keys: ['e/4'], stem_direction: -1, duration: '8' }),
|
|
86
|
+
note({ keys: ['b/4', 'd/5', 'a/5'], stem_direction: -1, duration: '8' }),
|
|
87
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8' }),
|
|
88
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
89
|
+
note({ keys: ['e/4'], stem_direction: -1, duration: '8' }),
|
|
90
|
+
];
|
|
91
|
+
const beam1 = new Beam(notes.slice(0, 4));
|
|
92
|
+
const beam2 = new Beam(notes.slice(4, 8));
|
|
93
|
+
const beam3 = new Beam(notes.slice(8, 12));
|
|
94
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
95
|
+
beam1.setContext(context).draw();
|
|
96
|
+
beam2.setContext(context).draw();
|
|
97
|
+
beam3.setContext(context).draw();
|
|
98
|
+
ok(true, 'Auto Align Rests - Beams Down Test');
|
|
99
|
+
}
|
|
100
|
+
function tupletsUp(options, contextBuilder) {
|
|
101
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
102
|
+
const notes = [
|
|
103
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '4' }),
|
|
104
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '4' }),
|
|
105
|
+
note({ keys: ['a/5'], stem_direction: 1, duration: '4r' }),
|
|
106
|
+
note({ keys: ['a/5'], stem_direction: 1, duration: '4r' }),
|
|
107
|
+
note({ keys: ['g/5'], stem_direction: 1, duration: '4r' }),
|
|
108
|
+
note({ keys: ['b/5'], stem_direction: 1, duration: '4' }),
|
|
109
|
+
note({ keys: ['a/5'], stem_direction: 1, duration: '4' }),
|
|
110
|
+
note({ keys: ['g/5'], stem_direction: 1, duration: '4r' }),
|
|
111
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '4' }),
|
|
112
|
+
note({ keys: ['a/5'], stem_direction: 1, duration: '4' }),
|
|
113
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '4r' }),
|
|
114
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '4r' }),
|
|
115
|
+
];
|
|
116
|
+
const tuplet1 = new Tuplet(notes.slice(0, 3)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
117
|
+
const tuplet2 = new Tuplet(notes.slice(3, 6)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
118
|
+
const tuplet3 = new Tuplet(notes.slice(6, 9)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
119
|
+
const tuplet4 = new Tuplet(notes.slice(9, 12)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
120
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
121
|
+
tuplet1.setContext(context).draw();
|
|
122
|
+
tuplet2.setContext(context).draw();
|
|
123
|
+
tuplet3.setContext(context).draw();
|
|
124
|
+
tuplet4.setContext(context).draw();
|
|
125
|
+
ok(true, 'Auto Align Rests - Tuplets Stem Up Test');
|
|
126
|
+
}
|
|
127
|
+
function tupletsDown(options, contextBuilder) {
|
|
128
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
129
|
+
const notes = [
|
|
130
|
+
note({ keys: ['a/5'], stem_direction: -1, duration: '8r' }),
|
|
131
|
+
note({ keys: ['g/5'], stem_direction: -1, duration: '8r' }),
|
|
132
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8' }),
|
|
133
|
+
note({ keys: ['a/5'], stem_direction: -1, duration: '8r' }),
|
|
134
|
+
note({ keys: ['g/5'], stem_direction: -1, duration: '8' }),
|
|
135
|
+
note({ keys: ['b/5'], stem_direction: -1, duration: '8' }),
|
|
136
|
+
note({ keys: ['a/5'], stem_direction: -1, duration: '8' }),
|
|
137
|
+
note({ keys: ['g/5'], stem_direction: -1, duration: '8r' }),
|
|
138
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8' }),
|
|
139
|
+
note({ keys: ['a/5'], stem_direction: -1, duration: '8' }),
|
|
140
|
+
note({ keys: ['g/5'], stem_direction: -1, duration: '8r' }),
|
|
141
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
142
|
+
];
|
|
143
|
+
const beam1 = new Beam(notes.slice(0, 3));
|
|
144
|
+
const beam2 = new Beam(notes.slice(3, 6));
|
|
145
|
+
const beam3 = new Beam(notes.slice(6, 9));
|
|
146
|
+
const beam4 = new Beam(notes.slice(9, 12));
|
|
147
|
+
const tuplet1 = new Tuplet(notes.slice(0, 3)).setTupletLocation(Tuplet.LOCATION_BOTTOM);
|
|
148
|
+
const tuplet2 = new Tuplet(notes.slice(3, 6)).setTupletLocation(Tuplet.LOCATION_BOTTOM);
|
|
149
|
+
const tuplet3 = new Tuplet(notes.slice(6, 9)).setTupletLocation(Tuplet.LOCATION_BOTTOM);
|
|
150
|
+
const tuplet4 = new Tuplet(notes.slice(9, 12)).setTupletLocation(Tuplet.LOCATION_BOTTOM);
|
|
151
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
152
|
+
tuplet1.setContext(context).draw();
|
|
153
|
+
tuplet2.setContext(context).draw();
|
|
154
|
+
tuplet3.setContext(context).draw();
|
|
155
|
+
tuplet4.setContext(context).draw();
|
|
156
|
+
beam1.setContext(context).draw();
|
|
157
|
+
beam2.setContext(context).draw();
|
|
158
|
+
beam3.setContext(context).draw();
|
|
159
|
+
beam4.setContext(context).draw();
|
|
160
|
+
ok(true, 'Auto Align Rests - Tuplets Stem Down Test');
|
|
161
|
+
}
|
|
162
|
+
function singleVoiceDefaultAlignment(options, contextBuilder) {
|
|
163
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
164
|
+
const notes = [
|
|
165
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '4r' }),
|
|
166
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '4r' }),
|
|
167
|
+
note({ keys: ['f/4'], stem_direction: -1, duration: '4' }),
|
|
168
|
+
note({ keys: ['e/5'], stem_direction: -1, duration: '8' }),
|
|
169
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
170
|
+
note({ keys: ['a/5'], stem_direction: -1, duration: '8' }),
|
|
171
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
172
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8' }),
|
|
173
|
+
note({ keys: ['e/5'], stem_direction: -1, duration: '8' }),
|
|
174
|
+
note({ keys: ['a/5'], stem_direction: 1, duration: '4' }),
|
|
175
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '4r' }),
|
|
176
|
+
note({ keys: ['b/5'], stem_direction: 1, duration: '4' }),
|
|
177
|
+
note({ keys: ['d/5'], stem_direction: -1, duration: '4' }),
|
|
178
|
+
note({ keys: ['g/5'], stem_direction: -1, duration: '4' }),
|
|
179
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '4r' }),
|
|
180
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '4r' }),
|
|
181
|
+
];
|
|
182
|
+
const beam = new Beam(notes.slice(5, 9));
|
|
183
|
+
const tuplet = new Tuplet(notes.slice(9, 12)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
184
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
185
|
+
tuplet.setContext(context).draw();
|
|
186
|
+
beam.setContext(context).draw();
|
|
187
|
+
ok(true, 'Auto Align Rests - Default Test');
|
|
188
|
+
}
|
|
189
|
+
function singleVoiceAlignAll(options, contextBuilder) {
|
|
190
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
191
|
+
const notes = [
|
|
192
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '4r' }),
|
|
193
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '4r' }),
|
|
194
|
+
note({ keys: ['f/4'], stem_direction: -1, duration: '4' }),
|
|
195
|
+
note({ keys: ['e/5'], stem_direction: -1, duration: '8' }),
|
|
196
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
197
|
+
note({ keys: ['a/5'], stem_direction: -1, duration: '8' }),
|
|
198
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
199
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '8' }),
|
|
200
|
+
note({ keys: ['e/5'], stem_direction: -1, duration: '8' }),
|
|
201
|
+
note({ keys: ['a/5'], stem_direction: 1, duration: '4' }),
|
|
202
|
+
note({ keys: ['b/4'], stem_direction: 1, duration: '4r' }),
|
|
203
|
+
note({ keys: ['b/5'], stem_direction: 1, duration: '4' }),
|
|
204
|
+
note({ keys: ['d/5'], stem_direction: -1, duration: '4' }),
|
|
205
|
+
note({ keys: ['g/5'], stem_direction: -1, duration: '4' }),
|
|
206
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '4r' }),
|
|
207
|
+
note({ keys: ['b/4'], stem_direction: -1, duration: '4r' }),
|
|
208
|
+
];
|
|
209
|
+
const beam = new Beam(notes.slice(5, 9));
|
|
210
|
+
const tuplet = new Tuplet(notes.slice(9, 12)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
211
|
+
Formatter.FormatAndDraw(context, stave, notes, { align_rests: true });
|
|
212
|
+
tuplet.setContext(context).draw();
|
|
213
|
+
beam.setContext(context).draw();
|
|
214
|
+
ok(true, 'Auto Align Rests - Align All Test');
|
|
215
|
+
}
|
|
216
|
+
function multiVoice(options, contextBuilder) {
|
|
217
|
+
const ctx = contextBuilder(options.elementId, 600, 200);
|
|
218
|
+
const stave = new Stave(50, 10, 500).addClef('treble').setContext(ctx).addTimeSignature('4/4').draw();
|
|
219
|
+
const noteOnStave = (noteStruct) => new StaveNote(noteStruct).setStave(stave);
|
|
220
|
+
const notes1 = [
|
|
221
|
+
noteOnStave({ keys: ['c/4', 'e/4', 'g/4'], duration: '4' }),
|
|
222
|
+
noteOnStave({ keys: ['b/4'], duration: '4r' }),
|
|
223
|
+
noteOnStave({ keys: ['c/4', 'd/4', 'a/4'], duration: '4' }),
|
|
224
|
+
noteOnStave({ keys: ['b/4'], duration: '4r' }),
|
|
225
|
+
];
|
|
226
|
+
const notes2 = [
|
|
227
|
+
noteOnStave({ keys: ['e/3'], stem_direction: -1, duration: '8' }),
|
|
228
|
+
noteOnStave({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
229
|
+
noteOnStave({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
230
|
+
noteOnStave({ keys: ['e/3'], stem_direction: -1, duration: '8' }),
|
|
231
|
+
noteOnStave({ keys: ['e/3'], stem_direction: -1, duration: '8' }),
|
|
232
|
+
noteOnStave({ keys: ['b/4'], stem_direction: -1, duration: '8r' }),
|
|
233
|
+
noteOnStave({ keys: ['e/3'], stem_direction: -1, duration: '8' }),
|
|
234
|
+
noteOnStave({ keys: ['e/3'], stem_direction: -1, duration: '8' }),
|
|
235
|
+
];
|
|
236
|
+
const voice1 = new Voice(Flow.TIME4_4).addTickables(notes1);
|
|
237
|
+
const voice2 = new Voice(Flow.TIME4_4).addTickables(notes2);
|
|
238
|
+
new Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave, { align_rests: true });
|
|
239
|
+
const beam2_1 = new Beam(notes2.slice(0, 4));
|
|
240
|
+
const beam2_2 = new Beam(notes2.slice(4, 8));
|
|
241
|
+
voice2.draw(ctx);
|
|
242
|
+
voice1.draw(ctx);
|
|
243
|
+
beam2_1.setContext(ctx).draw();
|
|
244
|
+
beam2_2.setContext(ctx).draw();
|
|
245
|
+
ok(true, 'Strokes Test Multi Voice');
|
|
246
|
+
}
|
|
247
|
+
VexFlowTests.register(RestsTests);
|
|
248
|
+
export { RestsTests };
|