vexflow 4.0.1-beta.1 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -65
- 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 +724 -697
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +550 -610
- 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 +10 -0
- package/build/esm/entry/vexflow-core.js +53 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +11 -0
- package/build/esm/entry/vexflow-debug.js +8 -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 +10 -0
- package/build/esm/entry/vexflow-petaluma.js +10 -0
- package/build/esm/entry/vexflow.js +8 -0
- package/build/esm/src/accidental.js +348 -0
- package/build/esm/src/annotation.js +238 -0
- package/build/esm/src/articulation.js +267 -0
- package/build/esm/src/barnote.js +58 -0
- package/build/esm/src/beam.js +644 -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 +445 -0
- package/build/esm/src/flow.js +288 -0
- package/build/esm/src/font.js +262 -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 +585 -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 +337 -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 +89 -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 +215 -0
- package/build/esm/src/stavemodifier.js +77 -0
- package/build/esm/src/stavenote.js +860 -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 +109 -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 +174 -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 +390 -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 +614 -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 +462 -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 +670 -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 +2 -0
- package/build/types/entry/vexflow-core.d.ts +2 -0
- package/build/types/entry/vexflow-debug.d.ts +2 -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 +2 -0
- package/build/types/entry/vexflow-petaluma.d.ts +2 -0
- package/build/types/entry/vexflow.d.ts +2 -0
- package/build/types/src/accidental.d.ts +66 -0
- package/build/types/src/annotation.d.ts +61 -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 +153 -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 +152 -0
- package/build/types/src/element.d.ts +202 -0
- package/build/types/src/factory.d.ts +274 -0
- package/build/types/src/flow.d.ts +260 -0
- package/build/types/src/font.d.ts +180 -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 +141 -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 +89 -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 +232 -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 +54 -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/entry/vexflow-bravura.ts +3 -3
- package/entry/vexflow-core.ts +3 -3
- package/entry/vexflow-debug-with-tests.ts +16 -2
- package/entry/vexflow-debug.ts +11 -3
- package/entry/vexflow-gonville.ts +3 -3
- package/entry/vexflow-petaluma.ts +3 -3
- package/entry/vexflow.ts +3 -3
- package/package.json +1 -1
- package/src/annotation.ts +38 -6
- package/src/articulation.ts +8 -2
- package/src/beam.ts +53 -6
- package/src/easyscore.ts +11 -1
- package/src/factory.ts +16 -2
- package/src/flow.ts +35 -20
- package/src/font.ts +0 -4
- package/src/fonts/gonville_glyphs.ts +4 -4
- package/src/formatter.ts +24 -8
- package/src/glyph.ts +8 -0
- package/src/index.ts +2 -7
- package/src/note.ts +2 -1
- package/src/staveline.ts +2 -5
- package/src/stavenote.ts +13 -9
- package/src/stavetext.ts +3 -3
- package/src/system.ts +1 -7
- package/src/textnote.ts +9 -11
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { StaveModifier, StaveModifierPosition } from './stavemodifier.js';
|
|
2
|
+
import { Tables } from './tables.js';
|
|
3
|
+
export var BarlineType;
|
|
4
|
+
(function (BarlineType) {
|
|
5
|
+
BarlineType[BarlineType["SINGLE"] = 1] = "SINGLE";
|
|
6
|
+
BarlineType[BarlineType["DOUBLE"] = 2] = "DOUBLE";
|
|
7
|
+
BarlineType[BarlineType["END"] = 3] = "END";
|
|
8
|
+
BarlineType[BarlineType["REPEAT_BEGIN"] = 4] = "REPEAT_BEGIN";
|
|
9
|
+
BarlineType[BarlineType["REPEAT_END"] = 5] = "REPEAT_END";
|
|
10
|
+
BarlineType[BarlineType["REPEAT_BOTH"] = 6] = "REPEAT_BOTH";
|
|
11
|
+
BarlineType[BarlineType["NONE"] = 7] = "NONE";
|
|
12
|
+
})(BarlineType || (BarlineType = {}));
|
|
13
|
+
export class Barline extends StaveModifier {
|
|
14
|
+
constructor(type) {
|
|
15
|
+
super();
|
|
16
|
+
this.thickness = Tables.STAVE_LINE_THICKNESS;
|
|
17
|
+
const TYPE = BarlineType;
|
|
18
|
+
this.widths = {};
|
|
19
|
+
this.widths[TYPE.SINGLE] = 5;
|
|
20
|
+
this.widths[TYPE.DOUBLE] = 5;
|
|
21
|
+
this.widths[TYPE.END] = 5;
|
|
22
|
+
this.widths[TYPE.REPEAT_BEGIN] = 5;
|
|
23
|
+
this.widths[TYPE.REPEAT_END] = 5;
|
|
24
|
+
this.widths[TYPE.REPEAT_BOTH] = 5;
|
|
25
|
+
this.widths[TYPE.NONE] = 5;
|
|
26
|
+
this.paddings = {};
|
|
27
|
+
this.paddings[TYPE.SINGLE] = 0;
|
|
28
|
+
this.paddings[TYPE.DOUBLE] = 0;
|
|
29
|
+
this.paddings[TYPE.END] = 0;
|
|
30
|
+
this.paddings[TYPE.REPEAT_BEGIN] = 15;
|
|
31
|
+
this.paddings[TYPE.REPEAT_END] = 15;
|
|
32
|
+
this.paddings[TYPE.REPEAT_BOTH] = 15;
|
|
33
|
+
this.paddings[TYPE.NONE] = 0;
|
|
34
|
+
this.layoutMetricsMap = {};
|
|
35
|
+
this.layoutMetricsMap[TYPE.SINGLE] = {
|
|
36
|
+
xMin: 0,
|
|
37
|
+
xMax: 1,
|
|
38
|
+
paddingLeft: 5,
|
|
39
|
+
paddingRight: 5,
|
|
40
|
+
};
|
|
41
|
+
this.layoutMetricsMap[TYPE.DOUBLE] = {
|
|
42
|
+
xMin: -3,
|
|
43
|
+
xMax: 1,
|
|
44
|
+
paddingLeft: 5,
|
|
45
|
+
paddingRight: 5,
|
|
46
|
+
};
|
|
47
|
+
this.layoutMetricsMap[TYPE.END] = {
|
|
48
|
+
xMin: -5,
|
|
49
|
+
xMax: 1,
|
|
50
|
+
paddingLeft: 5,
|
|
51
|
+
paddingRight: 5,
|
|
52
|
+
};
|
|
53
|
+
this.layoutMetricsMap[TYPE.REPEAT_END] = {
|
|
54
|
+
xMin: -10,
|
|
55
|
+
xMax: 1,
|
|
56
|
+
paddingLeft: 5,
|
|
57
|
+
paddingRight: 5,
|
|
58
|
+
};
|
|
59
|
+
this.layoutMetricsMap[TYPE.REPEAT_BEGIN] = {
|
|
60
|
+
xMin: -2,
|
|
61
|
+
xMax: 10,
|
|
62
|
+
paddingLeft: 5,
|
|
63
|
+
paddingRight: 5,
|
|
64
|
+
};
|
|
65
|
+
this.layoutMetricsMap[TYPE.REPEAT_BOTH] = {
|
|
66
|
+
xMin: -10,
|
|
67
|
+
xMax: 10,
|
|
68
|
+
paddingLeft: 5,
|
|
69
|
+
paddingRight: 5,
|
|
70
|
+
};
|
|
71
|
+
this.layoutMetricsMap[TYPE.NONE] = {
|
|
72
|
+
xMin: 0,
|
|
73
|
+
xMax: 0,
|
|
74
|
+
paddingLeft: 5,
|
|
75
|
+
paddingRight: 5,
|
|
76
|
+
};
|
|
77
|
+
this.setPosition(StaveModifierPosition.BEGIN);
|
|
78
|
+
this.setType(type);
|
|
79
|
+
}
|
|
80
|
+
static get CATEGORY() {
|
|
81
|
+
return "Barline";
|
|
82
|
+
}
|
|
83
|
+
static get type() {
|
|
84
|
+
return BarlineType;
|
|
85
|
+
}
|
|
86
|
+
static get typeString() {
|
|
87
|
+
return {
|
|
88
|
+
single: BarlineType.SINGLE,
|
|
89
|
+
double: BarlineType.DOUBLE,
|
|
90
|
+
end: BarlineType.END,
|
|
91
|
+
repeatBegin: BarlineType.REPEAT_BEGIN,
|
|
92
|
+
repeatEnd: BarlineType.REPEAT_END,
|
|
93
|
+
repeatBoth: BarlineType.REPEAT_BOTH,
|
|
94
|
+
none: BarlineType.NONE,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
getType() {
|
|
98
|
+
return this.type;
|
|
99
|
+
}
|
|
100
|
+
setType(type) {
|
|
101
|
+
this.type = typeof type === 'string' ? Barline.typeString[type] : type;
|
|
102
|
+
this.setWidth(this.widths[this.type]);
|
|
103
|
+
this.setPadding(this.paddings[this.type]);
|
|
104
|
+
this.setLayoutMetrics(this.layoutMetricsMap[this.type]);
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
draw(stave) {
|
|
108
|
+
stave.checkContext();
|
|
109
|
+
this.setRendered();
|
|
110
|
+
switch (this.type) {
|
|
111
|
+
case BarlineType.SINGLE:
|
|
112
|
+
this.drawVerticalBar(stave, this.x, false);
|
|
113
|
+
break;
|
|
114
|
+
case BarlineType.DOUBLE:
|
|
115
|
+
this.drawVerticalBar(stave, this.x, true);
|
|
116
|
+
break;
|
|
117
|
+
case BarlineType.END:
|
|
118
|
+
this.drawVerticalEndBar(stave, this.x);
|
|
119
|
+
break;
|
|
120
|
+
case BarlineType.REPEAT_BEGIN:
|
|
121
|
+
this.drawRepeatBar(stave, this.x, true);
|
|
122
|
+
if (stave.getX() !== this.x) {
|
|
123
|
+
this.drawVerticalBar(stave, stave.getX());
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
case BarlineType.REPEAT_END:
|
|
127
|
+
this.drawRepeatBar(stave, this.x, false);
|
|
128
|
+
break;
|
|
129
|
+
case BarlineType.REPEAT_BOTH:
|
|
130
|
+
this.drawRepeatBar(stave, this.x, false);
|
|
131
|
+
this.drawRepeatBar(stave, this.x, true);
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
drawVerticalBar(stave, x, double_bar) {
|
|
138
|
+
const staveCtx = stave.checkContext();
|
|
139
|
+
const topY = stave.getTopLineTopY();
|
|
140
|
+
const botY = stave.getBottomLineBottomY();
|
|
141
|
+
if (double_bar) {
|
|
142
|
+
staveCtx.fillRect(x - 3, topY, 1, botY - topY);
|
|
143
|
+
}
|
|
144
|
+
staveCtx.fillRect(x, topY, 1, botY - topY);
|
|
145
|
+
}
|
|
146
|
+
drawVerticalEndBar(stave, x) {
|
|
147
|
+
const staveCtx = stave.checkContext();
|
|
148
|
+
const topY = stave.getTopLineTopY();
|
|
149
|
+
const botY = stave.getBottomLineBottomY();
|
|
150
|
+
staveCtx.fillRect(x - 5, topY, 1, botY - topY);
|
|
151
|
+
staveCtx.fillRect(x - 2, topY, 3, botY - topY);
|
|
152
|
+
}
|
|
153
|
+
drawRepeatBar(stave, x, begin) {
|
|
154
|
+
const staveCtx = stave.checkContext();
|
|
155
|
+
const topY = stave.getTopLineTopY();
|
|
156
|
+
const botY = stave.getBottomLineBottomY();
|
|
157
|
+
let x_shift = 3;
|
|
158
|
+
if (!begin) {
|
|
159
|
+
x_shift = -5;
|
|
160
|
+
}
|
|
161
|
+
staveCtx.fillRect(x + x_shift, topY, 1, botY - topY);
|
|
162
|
+
staveCtx.fillRect(x - 2, topY, 3, botY - topY);
|
|
163
|
+
const dot_radius = 2;
|
|
164
|
+
if (begin) {
|
|
165
|
+
x_shift += 4;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
x_shift -= 4;
|
|
169
|
+
}
|
|
170
|
+
const dot_x = x + x_shift + dot_radius / 2;
|
|
171
|
+
let y_offset = (stave.getNumLines() - 1) * stave.getSpacingBetweenLines();
|
|
172
|
+
y_offset = y_offset / 2 - stave.getSpacingBetweenLines() / 2;
|
|
173
|
+
let dot_y = topY + y_offset + dot_radius / 2;
|
|
174
|
+
staveCtx.beginPath();
|
|
175
|
+
staveCtx.arc(dot_x, dot_y, dot_radius, 0, Math.PI * 2, false);
|
|
176
|
+
staveCtx.fill();
|
|
177
|
+
dot_y += stave.getSpacingBetweenLines();
|
|
178
|
+
staveCtx.beginPath();
|
|
179
|
+
staveCtx.arc(dot_x, dot_y, dot_radius, 0, Math.PI * 2, false);
|
|
180
|
+
staveCtx.fill();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Element } from './element.js';
|
|
2
|
+
import { Font, FontStyle, FontWeight } from './font.js';
|
|
3
|
+
import { Glyph } from './glyph.js';
|
|
4
|
+
import { Tables } from './tables.js';
|
|
5
|
+
import { RuntimeError } from './util.js';
|
|
6
|
+
function drawBoldDoubleLine(ctx, type, topX, topY, botY) {
|
|
7
|
+
if (type !== StaveConnector.type.BOLD_DOUBLE_LEFT && type !== StaveConnector.type.BOLD_DOUBLE_RIGHT) {
|
|
8
|
+
throw new RuntimeError('InvalidConnector', 'A REPEAT_BEGIN or REPEAT_END type must be provided.');
|
|
9
|
+
}
|
|
10
|
+
let x_shift = 3;
|
|
11
|
+
let variableWidth = 3.5;
|
|
12
|
+
const thickLineOffset = 2;
|
|
13
|
+
if (type === StaveConnector.type.BOLD_DOUBLE_RIGHT) {
|
|
14
|
+
x_shift = -5;
|
|
15
|
+
variableWidth = 3;
|
|
16
|
+
}
|
|
17
|
+
ctx.fillRect(topX + x_shift, topY, 1, botY - topY);
|
|
18
|
+
ctx.fillRect(topX - thickLineOffset, topY, variableWidth, botY - topY);
|
|
19
|
+
}
|
|
20
|
+
export class StaveConnector extends Element {
|
|
21
|
+
constructor(top_stave, bottom_stave) {
|
|
22
|
+
super();
|
|
23
|
+
this.thickness = Tables.STAVE_LINE_THICKNESS;
|
|
24
|
+
this.width = 3;
|
|
25
|
+
this.top_stave = top_stave;
|
|
26
|
+
this.bottom_stave = bottom_stave;
|
|
27
|
+
this.type = StaveConnector.type.DOUBLE;
|
|
28
|
+
this.resetFont();
|
|
29
|
+
this.x_shift = 0;
|
|
30
|
+
this.texts = [];
|
|
31
|
+
}
|
|
32
|
+
static get CATEGORY() {
|
|
33
|
+
return "StaveConnector";
|
|
34
|
+
}
|
|
35
|
+
setType(type) {
|
|
36
|
+
type = typeof type === 'string' ? StaveConnector.typeString[type] : type;
|
|
37
|
+
if (type >= StaveConnector.type.SINGLE_RIGHT && type <= StaveConnector.type.NONE) {
|
|
38
|
+
this.type = type;
|
|
39
|
+
}
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
setText(text, options = {}) {
|
|
43
|
+
this.texts.push({
|
|
44
|
+
content: text,
|
|
45
|
+
options: Object.assign({ shift_x: 0, shift_y: 0 }, options),
|
|
46
|
+
});
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
setXShift(x_shift) {
|
|
50
|
+
if (typeof x_shift !== 'number') {
|
|
51
|
+
throw new RuntimeError('InvalidType', 'x_shift must be a Number');
|
|
52
|
+
}
|
|
53
|
+
this.x_shift = x_shift;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
getXShift() {
|
|
57
|
+
return this.x_shift;
|
|
58
|
+
}
|
|
59
|
+
draw() {
|
|
60
|
+
const ctx = this.checkContext();
|
|
61
|
+
this.setRendered();
|
|
62
|
+
let topY = this.top_stave.getYForLine(0);
|
|
63
|
+
let botY = this.bottom_stave.getYForLine(this.bottom_stave.getNumLines() - 1) + this.thickness;
|
|
64
|
+
let width = this.width;
|
|
65
|
+
let topX = this.top_stave.getX();
|
|
66
|
+
const isRightSidedConnector = this.type === StaveConnector.type.SINGLE_RIGHT ||
|
|
67
|
+
this.type === StaveConnector.type.BOLD_DOUBLE_RIGHT ||
|
|
68
|
+
this.type === StaveConnector.type.THIN_DOUBLE;
|
|
69
|
+
if (isRightSidedConnector) {
|
|
70
|
+
topX = this.top_stave.getX() + this.top_stave.getWidth();
|
|
71
|
+
}
|
|
72
|
+
let attachment_height = botY - topY;
|
|
73
|
+
switch (this.type) {
|
|
74
|
+
case StaveConnector.type.SINGLE:
|
|
75
|
+
width = 1;
|
|
76
|
+
break;
|
|
77
|
+
case StaveConnector.type.SINGLE_LEFT:
|
|
78
|
+
width = 1;
|
|
79
|
+
break;
|
|
80
|
+
case StaveConnector.type.SINGLE_RIGHT:
|
|
81
|
+
width = 1;
|
|
82
|
+
break;
|
|
83
|
+
case StaveConnector.type.DOUBLE:
|
|
84
|
+
topX -= this.width + 2;
|
|
85
|
+
topY -= this.thickness;
|
|
86
|
+
attachment_height += 0.5;
|
|
87
|
+
break;
|
|
88
|
+
case StaveConnector.type.BRACE: {
|
|
89
|
+
width = 12;
|
|
90
|
+
const x1 = this.top_stave.getX() - 2 + this.x_shift;
|
|
91
|
+
const y1 = topY;
|
|
92
|
+
const x3 = x1;
|
|
93
|
+
const y3 = botY;
|
|
94
|
+
const x2 = x1 - width;
|
|
95
|
+
const y2 = y1 + attachment_height / 2.0;
|
|
96
|
+
const cpx1 = x2 - 0.9 * width;
|
|
97
|
+
const cpy1 = y1 + 0.2 * attachment_height;
|
|
98
|
+
const cpx2 = x1 + 1.1 * width;
|
|
99
|
+
const cpy2 = y2 - 0.135 * attachment_height;
|
|
100
|
+
const cpx3 = cpx2;
|
|
101
|
+
const cpy3 = y2 + 0.135 * attachment_height;
|
|
102
|
+
const cpx4 = cpx1;
|
|
103
|
+
const cpy4 = y3 - 0.2 * attachment_height;
|
|
104
|
+
const cpx5 = x2 - width;
|
|
105
|
+
const cpy5 = cpy4;
|
|
106
|
+
const cpx6 = x1 + 0.4 * width;
|
|
107
|
+
const cpy6 = y2 + 0.135 * attachment_height;
|
|
108
|
+
const cpx7 = cpx6;
|
|
109
|
+
const cpy7 = y2 - 0.135 * attachment_height;
|
|
110
|
+
const cpx8 = cpx5;
|
|
111
|
+
const cpy8 = cpy1;
|
|
112
|
+
ctx.beginPath();
|
|
113
|
+
ctx.moveTo(x1, y1);
|
|
114
|
+
ctx.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, x2, y2);
|
|
115
|
+
ctx.bezierCurveTo(cpx3, cpy3, cpx4, cpy4, x3, y3);
|
|
116
|
+
ctx.bezierCurveTo(cpx5, cpy5, cpx6, cpy6, x2, y2);
|
|
117
|
+
ctx.bezierCurveTo(cpx7, cpy7, cpx8, cpy8, x1, y1);
|
|
118
|
+
ctx.fill();
|
|
119
|
+
ctx.stroke();
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case StaveConnector.type.BRACKET:
|
|
123
|
+
topY -= 6;
|
|
124
|
+
botY += 6;
|
|
125
|
+
attachment_height = botY - topY;
|
|
126
|
+
Glyph.renderGlyph(ctx, topX - 5, topY, 40, 'bracketTop');
|
|
127
|
+
Glyph.renderGlyph(ctx, topX - 5, botY, 40, 'bracketBottom');
|
|
128
|
+
topX -= this.width + 2;
|
|
129
|
+
break;
|
|
130
|
+
case StaveConnector.type.BOLD_DOUBLE_LEFT:
|
|
131
|
+
drawBoldDoubleLine(ctx, this.type, topX + this.x_shift, topY, botY - this.thickness);
|
|
132
|
+
break;
|
|
133
|
+
case StaveConnector.type.BOLD_DOUBLE_RIGHT:
|
|
134
|
+
drawBoldDoubleLine(ctx, this.type, topX, topY, botY - this.thickness);
|
|
135
|
+
break;
|
|
136
|
+
case StaveConnector.type.THIN_DOUBLE:
|
|
137
|
+
width = 1;
|
|
138
|
+
attachment_height -= this.thickness;
|
|
139
|
+
break;
|
|
140
|
+
case StaveConnector.type.NONE:
|
|
141
|
+
break;
|
|
142
|
+
default:
|
|
143
|
+
throw new RuntimeError('InvalidType', `The provided StaveConnector.type (${this.type}) is invalid.`);
|
|
144
|
+
}
|
|
145
|
+
if (this.type !== StaveConnector.type.BRACE &&
|
|
146
|
+
this.type !== StaveConnector.type.BOLD_DOUBLE_LEFT &&
|
|
147
|
+
this.type !== StaveConnector.type.BOLD_DOUBLE_RIGHT &&
|
|
148
|
+
this.type !== StaveConnector.type.NONE) {
|
|
149
|
+
ctx.fillRect(topX, topY, width, attachment_height);
|
|
150
|
+
}
|
|
151
|
+
if (this.type === StaveConnector.type.THIN_DOUBLE) {
|
|
152
|
+
ctx.fillRect(topX - 3, topY, width, attachment_height);
|
|
153
|
+
}
|
|
154
|
+
ctx.save();
|
|
155
|
+
ctx.setLineWidth(2);
|
|
156
|
+
ctx.setFont(this.textFont);
|
|
157
|
+
for (let i = 0; i < this.texts.length; i++) {
|
|
158
|
+
const text = this.texts[i];
|
|
159
|
+
const text_width = ctx.measureText('' + text.content).width;
|
|
160
|
+
const x = this.top_stave.getX() - text_width - 24 + text.options.shift_x;
|
|
161
|
+
const y = (this.top_stave.getYForLine(0) + this.bottom_stave.getBottomLineY()) / 2 + text.options.shift_y;
|
|
162
|
+
ctx.fillText('' + text.content, x, y + 4);
|
|
163
|
+
}
|
|
164
|
+
ctx.restore();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
StaveConnector.TEXT_FONT = {
|
|
168
|
+
family: Font.SERIF,
|
|
169
|
+
size: 16,
|
|
170
|
+
weight: FontWeight.NORMAL,
|
|
171
|
+
style: FontStyle.NORMAL,
|
|
172
|
+
};
|
|
173
|
+
StaveConnector.type = {
|
|
174
|
+
SINGLE_RIGHT: 0,
|
|
175
|
+
SINGLE_LEFT: 1,
|
|
176
|
+
SINGLE: 1,
|
|
177
|
+
DOUBLE: 2,
|
|
178
|
+
BRACE: 3,
|
|
179
|
+
BRACKET: 4,
|
|
180
|
+
BOLD_DOUBLE_LEFT: 5,
|
|
181
|
+
BOLD_DOUBLE_RIGHT: 6,
|
|
182
|
+
THIN_DOUBLE: 7,
|
|
183
|
+
NONE: 8,
|
|
184
|
+
};
|
|
185
|
+
StaveConnector.typeString = {
|
|
186
|
+
singleRight: StaveConnector.type.SINGLE_RIGHT,
|
|
187
|
+
singleLeft: StaveConnector.type.SINGLE_LEFT,
|
|
188
|
+
single: StaveConnector.type.SINGLE,
|
|
189
|
+
double: StaveConnector.type.DOUBLE,
|
|
190
|
+
brace: StaveConnector.type.BRACE,
|
|
191
|
+
bracket: StaveConnector.type.BRACKET,
|
|
192
|
+
boldDoubleLeft: StaveConnector.type.BOLD_DOUBLE_LEFT,
|
|
193
|
+
boldDoubleRight: StaveConnector.type.BOLD_DOUBLE_RIGHT,
|
|
194
|
+
thinDouble: StaveConnector.type.THIN_DOUBLE,
|
|
195
|
+
none: StaveConnector.type.NONE,
|
|
196
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Element } from './element.js';
|
|
2
|
+
import { Modifier } from './modifier.js';
|
|
3
|
+
import { RuntimeError } from './util.js';
|
|
4
|
+
export class StaveHairpin extends Element {
|
|
5
|
+
constructor(notes, type) {
|
|
6
|
+
super();
|
|
7
|
+
this.setNotes(notes);
|
|
8
|
+
this.hairpin = type;
|
|
9
|
+
this.position = Modifier.Position.BELOW;
|
|
10
|
+
this.render_options = {
|
|
11
|
+
height: 10,
|
|
12
|
+
y_shift: 0,
|
|
13
|
+
left_shift_px: 0,
|
|
14
|
+
right_shift_px: 0,
|
|
15
|
+
right_shift_ticks: 0,
|
|
16
|
+
left_shift_ticks: 0,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static get CATEGORY() {
|
|
20
|
+
return "StaveHairpin";
|
|
21
|
+
}
|
|
22
|
+
static FormatByTicksAndDraw(ctx, formatter, notes, type, position, options) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const ppt = formatter.pixelsPerTick;
|
|
25
|
+
if (ppt == null) {
|
|
26
|
+
throw new RuntimeError('BadArguments', 'A valid Formatter must be provide to draw offsets by ticks.');
|
|
27
|
+
}
|
|
28
|
+
const l_shift_px = ppt * ((_a = options.left_shift_ticks) !== null && _a !== void 0 ? _a : 0);
|
|
29
|
+
const r_shift_px = ppt * ((_b = options.right_shift_ticks) !== null && _b !== void 0 ? _b : 0);
|
|
30
|
+
const hairpin_options = {
|
|
31
|
+
height: options.height,
|
|
32
|
+
y_shift: options.y_shift,
|
|
33
|
+
left_shift_px: l_shift_px,
|
|
34
|
+
right_shift_px: r_shift_px,
|
|
35
|
+
right_shift_ticks: 0,
|
|
36
|
+
left_shift_ticks: 0,
|
|
37
|
+
};
|
|
38
|
+
new StaveHairpin({
|
|
39
|
+
first_note: notes.first_note,
|
|
40
|
+
last_note: notes.last_note,
|
|
41
|
+
}, type)
|
|
42
|
+
.setContext(ctx)
|
|
43
|
+
.setRenderOptions(hairpin_options)
|
|
44
|
+
.setPosition(position)
|
|
45
|
+
.draw();
|
|
46
|
+
}
|
|
47
|
+
setPosition(position) {
|
|
48
|
+
if (position === Modifier.Position.ABOVE || position === Modifier.Position.BELOW) {
|
|
49
|
+
this.position = position;
|
|
50
|
+
}
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
setRenderOptions(options) {
|
|
54
|
+
if (options.height != null &&
|
|
55
|
+
options.y_shift != null &&
|
|
56
|
+
options.left_shift_px != null &&
|
|
57
|
+
options.right_shift_px != null) {
|
|
58
|
+
this.render_options = options;
|
|
59
|
+
}
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
setNotes(notes) {
|
|
63
|
+
if (!notes.first_note && !notes.last_note) {
|
|
64
|
+
throw new RuntimeError('BadArguments', 'Hairpin needs to have either first_note or last_note set.');
|
|
65
|
+
}
|
|
66
|
+
this.notes = notes;
|
|
67
|
+
this.first_note = notes.first_note;
|
|
68
|
+
this.last_note = notes.last_note;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
renderHairpin(params) {
|
|
72
|
+
const ctx = this.checkContext();
|
|
73
|
+
let dis = this.render_options.y_shift + 20;
|
|
74
|
+
let y_shift = params.first_y;
|
|
75
|
+
if (this.position === Modifier.Position.ABOVE) {
|
|
76
|
+
dis = -dis + 30;
|
|
77
|
+
y_shift = params.first_y - params.staff_height;
|
|
78
|
+
}
|
|
79
|
+
const l_shift = this.render_options.left_shift_px;
|
|
80
|
+
const r_shift = this.render_options.right_shift_px;
|
|
81
|
+
ctx.beginPath();
|
|
82
|
+
switch (this.hairpin) {
|
|
83
|
+
case StaveHairpin.type.CRESC:
|
|
84
|
+
ctx.moveTo(params.last_x + r_shift, y_shift + dis);
|
|
85
|
+
ctx.lineTo(params.first_x + l_shift, y_shift + this.render_options.height / 2 + dis);
|
|
86
|
+
ctx.lineTo(params.last_x + r_shift, y_shift + this.render_options.height + dis);
|
|
87
|
+
break;
|
|
88
|
+
case StaveHairpin.type.DECRESC:
|
|
89
|
+
ctx.moveTo(params.first_x + l_shift, y_shift + dis);
|
|
90
|
+
ctx.lineTo(params.last_x + r_shift, y_shift + this.render_options.height / 2 + dis);
|
|
91
|
+
ctx.lineTo(params.first_x + l_shift, y_shift + this.render_options.height + dis);
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
ctx.stroke();
|
|
97
|
+
ctx.closePath();
|
|
98
|
+
}
|
|
99
|
+
draw() {
|
|
100
|
+
this.checkContext();
|
|
101
|
+
this.setRendered();
|
|
102
|
+
const firstNote = this.first_note;
|
|
103
|
+
const lastNote = this.last_note;
|
|
104
|
+
if (!firstNote || !lastNote)
|
|
105
|
+
throw new RuntimeError('NoNote', 'Notes required to draw');
|
|
106
|
+
const start = firstNote.getModifierStartXY(this.position, 0);
|
|
107
|
+
const end = lastNote.getModifierStartXY(this.position, 0);
|
|
108
|
+
this.renderHairpin({
|
|
109
|
+
first_x: start.x,
|
|
110
|
+
last_x: end.x,
|
|
111
|
+
first_y: firstNote.checkStave().getY() + firstNote.checkStave().getHeight(),
|
|
112
|
+
last_y: lastNote.checkStave().getY() + lastNote.checkStave().getHeight(),
|
|
113
|
+
staff_height: firstNote.checkStave().getHeight(),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
StaveHairpin.type = {
|
|
118
|
+
CRESC: 1,
|
|
119
|
+
DECRESC: 2,
|
|
120
|
+
};
|