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,440 @@
|
|
|
1
|
+
import { Accidental } from './accidental.js';
|
|
2
|
+
import { Annotation, AnnotationHorizontalJustify, AnnotationVerticalJustify } from './annotation.js';
|
|
3
|
+
import { Articulation } from './articulation.js';
|
|
4
|
+
import { BarNote } from './barnote.js';
|
|
5
|
+
import { Beam } from './beam.js';
|
|
6
|
+
import { ChordSymbol } from './chordsymbol.js';
|
|
7
|
+
import { ClefNote } from './clefnote.js';
|
|
8
|
+
import { Curve } from './curve.js';
|
|
9
|
+
import { EasyScore } from './easyscore.js';
|
|
10
|
+
import { Element } from './element.js';
|
|
11
|
+
import { Formatter } from './formatter.js';
|
|
12
|
+
import { FretHandFinger } from './frethandfinger.js';
|
|
13
|
+
import { GhostNote } from './ghostnote.js';
|
|
14
|
+
import { GlyphNote } from './glyphnote.js';
|
|
15
|
+
import { GraceNote } from './gracenote.js';
|
|
16
|
+
import { GraceNoteGroup } from './gracenotegroup.js';
|
|
17
|
+
import { KeySigNote } from './keysignote.js';
|
|
18
|
+
import { ModifierContext } from './modifiercontext.js';
|
|
19
|
+
import { MultiMeasureRest } from './multimeasurerest.js';
|
|
20
|
+
import { NoteSubGroup } from './notesubgroup.js';
|
|
21
|
+
import { PedalMarking } from './pedalmarking.js';
|
|
22
|
+
import { Renderer } from './renderer.js';
|
|
23
|
+
import { RepeatNote } from './repeatnote.js';
|
|
24
|
+
import { Stave } from './stave.js';
|
|
25
|
+
import { StaveConnector } from './staveconnector.js';
|
|
26
|
+
import { StaveLine } from './staveline.js';
|
|
27
|
+
import { StaveNote } from './stavenote.js';
|
|
28
|
+
import { StaveTie } from './stavetie.js';
|
|
29
|
+
import { StringNumber } from './stringnumber.js';
|
|
30
|
+
import { System } from './system.js';
|
|
31
|
+
import { TabNote } from './tabnote.js';
|
|
32
|
+
import { TabStave } from './tabstave.js';
|
|
33
|
+
import { TextBracket } from './textbracket.js';
|
|
34
|
+
import { TextDynamics } from './textdynamics.js';
|
|
35
|
+
import { TextNote } from './textnote.js';
|
|
36
|
+
import { TickContext } from './tickcontext.js';
|
|
37
|
+
import { TimeSigNote } from './timesignote.js';
|
|
38
|
+
import { Tuplet } from './tuplet.js';
|
|
39
|
+
import { defined, log, RuntimeError } from './util.js';
|
|
40
|
+
import { VibratoBracket } from './vibratobracket.js';
|
|
41
|
+
import { Voice } from './voice.js';
|
|
42
|
+
import { isHTMLCanvas } from './web.js';
|
|
43
|
+
function L(...args) {
|
|
44
|
+
if (Factory.DEBUG)
|
|
45
|
+
log('Vex.Flow.Factory', args);
|
|
46
|
+
}
|
|
47
|
+
export class Factory {
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
L('New factory: ', options);
|
|
50
|
+
this.options = {
|
|
51
|
+
stave: {
|
|
52
|
+
space: 10,
|
|
53
|
+
},
|
|
54
|
+
renderer: {
|
|
55
|
+
elementId: '',
|
|
56
|
+
width: 500,
|
|
57
|
+
height: 200,
|
|
58
|
+
background: '#FFF',
|
|
59
|
+
},
|
|
60
|
+
font: Factory.TEXT_FONT,
|
|
61
|
+
};
|
|
62
|
+
this.setOptions(options);
|
|
63
|
+
}
|
|
64
|
+
static newFromElementId(elementId, width = 500, height = 200) {
|
|
65
|
+
return new Factory({ renderer: { elementId, width, height } });
|
|
66
|
+
}
|
|
67
|
+
reset() {
|
|
68
|
+
this.renderQ = [];
|
|
69
|
+
this.systems = [];
|
|
70
|
+
this.staves = [];
|
|
71
|
+
this.voices = [];
|
|
72
|
+
this.stave = undefined;
|
|
73
|
+
}
|
|
74
|
+
setOptions(options) {
|
|
75
|
+
this.options = Object.assign(Object.assign({}, this.options), options);
|
|
76
|
+
this.initRenderer();
|
|
77
|
+
this.reset();
|
|
78
|
+
}
|
|
79
|
+
initRenderer() {
|
|
80
|
+
const { elementId, width, height, background } = this.options.renderer;
|
|
81
|
+
if (elementId == null) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (elementId == '') {
|
|
85
|
+
L(this);
|
|
86
|
+
throw new RuntimeError('renderer.elementId not set in FactoryOptions');
|
|
87
|
+
}
|
|
88
|
+
let backend = this.options.renderer.backend;
|
|
89
|
+
if (backend === undefined) {
|
|
90
|
+
const elem = document.getElementById(elementId);
|
|
91
|
+
if (isHTMLCanvas(elem)) {
|
|
92
|
+
backend = Renderer.Backends.CANVAS;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
backend = Renderer.Backends.SVG;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
this.context = Renderer.buildContext(elementId, backend, width, height, background);
|
|
99
|
+
}
|
|
100
|
+
getContext() {
|
|
101
|
+
return this.context;
|
|
102
|
+
}
|
|
103
|
+
setContext(context) {
|
|
104
|
+
this.context = context;
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
getStave() {
|
|
108
|
+
return this.stave;
|
|
109
|
+
}
|
|
110
|
+
getVoices() {
|
|
111
|
+
return this.voices;
|
|
112
|
+
}
|
|
113
|
+
Stave(params) {
|
|
114
|
+
const staveSpace = this.options.stave.space;
|
|
115
|
+
const p = Object.assign({ x: 0, y: 0, width: this.options.renderer.width - staveSpace * 1.0, options: { spacing_between_lines_px: staveSpace * 1.0 } }, params);
|
|
116
|
+
const stave = new Stave(p.x, p.y, p.width, p.options);
|
|
117
|
+
this.staves.push(stave);
|
|
118
|
+
stave.setContext(this.context);
|
|
119
|
+
this.stave = stave;
|
|
120
|
+
return stave;
|
|
121
|
+
}
|
|
122
|
+
TabStave(params) {
|
|
123
|
+
const staveSpace = this.options.stave.space;
|
|
124
|
+
const p = Object.assign({ x: 0, y: 0, width: this.options.renderer.width - staveSpace * 1.0, options: { spacing_between_lines_px: staveSpace * 1.3 } }, params);
|
|
125
|
+
const stave = new TabStave(p.x, p.y, p.width, p.options);
|
|
126
|
+
this.staves.push(stave);
|
|
127
|
+
stave.setContext(this.context);
|
|
128
|
+
this.stave = stave;
|
|
129
|
+
return stave;
|
|
130
|
+
}
|
|
131
|
+
StaveNote(noteStruct) {
|
|
132
|
+
const note = new StaveNote(noteStruct);
|
|
133
|
+
if (this.stave)
|
|
134
|
+
note.setStave(this.stave);
|
|
135
|
+
note.setContext(this.context);
|
|
136
|
+
this.renderQ.push(note);
|
|
137
|
+
return note;
|
|
138
|
+
}
|
|
139
|
+
GlyphNote(glyph, noteStruct, options) {
|
|
140
|
+
const note = new GlyphNote(glyph, noteStruct, options);
|
|
141
|
+
if (this.stave)
|
|
142
|
+
note.setStave(this.stave);
|
|
143
|
+
note.setContext(this.context);
|
|
144
|
+
this.renderQ.push(note);
|
|
145
|
+
return note;
|
|
146
|
+
}
|
|
147
|
+
RepeatNote(type, noteStruct, options) {
|
|
148
|
+
const note = new RepeatNote(type, noteStruct, options);
|
|
149
|
+
if (this.stave)
|
|
150
|
+
note.setStave(this.stave);
|
|
151
|
+
note.setContext(this.context);
|
|
152
|
+
this.renderQ.push(note);
|
|
153
|
+
return note;
|
|
154
|
+
}
|
|
155
|
+
GhostNote(noteStruct) {
|
|
156
|
+
const ghostNote = new GhostNote(noteStruct);
|
|
157
|
+
if (this.stave)
|
|
158
|
+
ghostNote.setStave(this.stave);
|
|
159
|
+
ghostNote.setContext(this.context);
|
|
160
|
+
this.renderQ.push(ghostNote);
|
|
161
|
+
return ghostNote;
|
|
162
|
+
}
|
|
163
|
+
TextNote(noteStruct) {
|
|
164
|
+
const textNote = new TextNote(noteStruct);
|
|
165
|
+
if (this.stave)
|
|
166
|
+
textNote.setStave(this.stave);
|
|
167
|
+
textNote.setContext(this.context);
|
|
168
|
+
this.renderQ.push(textNote);
|
|
169
|
+
return textNote;
|
|
170
|
+
}
|
|
171
|
+
BarNote(params = {}) {
|
|
172
|
+
const barNote = new BarNote(params.type);
|
|
173
|
+
if (this.stave)
|
|
174
|
+
barNote.setStave(this.stave);
|
|
175
|
+
barNote.setContext(this.context);
|
|
176
|
+
this.renderQ.push(barNote);
|
|
177
|
+
return barNote;
|
|
178
|
+
}
|
|
179
|
+
ClefNote(params) {
|
|
180
|
+
const p = Object.assign({ type: 'treble', options: {
|
|
181
|
+
size: 'default',
|
|
182
|
+
annotation: undefined,
|
|
183
|
+
} }, params);
|
|
184
|
+
const clefNote = new ClefNote(p.type, p.options.size, p.options.annotation);
|
|
185
|
+
if (this.stave)
|
|
186
|
+
clefNote.setStave(this.stave);
|
|
187
|
+
clefNote.setContext(this.context);
|
|
188
|
+
this.renderQ.push(clefNote);
|
|
189
|
+
return clefNote;
|
|
190
|
+
}
|
|
191
|
+
TimeSigNote(params) {
|
|
192
|
+
const p = Object.assign({ time: '4/4' }, params);
|
|
193
|
+
const timeSigNote = new TimeSigNote(p.time);
|
|
194
|
+
if (this.stave)
|
|
195
|
+
timeSigNote.setStave(this.stave);
|
|
196
|
+
timeSigNote.setContext(this.context);
|
|
197
|
+
this.renderQ.push(timeSigNote);
|
|
198
|
+
return timeSigNote;
|
|
199
|
+
}
|
|
200
|
+
KeySigNote(params) {
|
|
201
|
+
const keySigNote = new KeySigNote(params.key, params.cancelKey, params.alterKey);
|
|
202
|
+
if (this.stave)
|
|
203
|
+
keySigNote.setStave(this.stave);
|
|
204
|
+
keySigNote.setContext(this.context);
|
|
205
|
+
this.renderQ.push(keySigNote);
|
|
206
|
+
return keySigNote;
|
|
207
|
+
}
|
|
208
|
+
TabNote(noteStruct) {
|
|
209
|
+
const note = new TabNote(noteStruct);
|
|
210
|
+
if (this.stave)
|
|
211
|
+
note.setStave(this.stave);
|
|
212
|
+
note.setContext(this.context);
|
|
213
|
+
this.renderQ.push(note);
|
|
214
|
+
return note;
|
|
215
|
+
}
|
|
216
|
+
GraceNote(noteStruct) {
|
|
217
|
+
const note = new GraceNote(noteStruct);
|
|
218
|
+
if (this.stave)
|
|
219
|
+
note.setStave(this.stave);
|
|
220
|
+
note.setContext(this.context);
|
|
221
|
+
return note;
|
|
222
|
+
}
|
|
223
|
+
GraceNoteGroup(params) {
|
|
224
|
+
const group = new GraceNoteGroup(params.notes, params.slur);
|
|
225
|
+
group.setContext(this.context);
|
|
226
|
+
return group;
|
|
227
|
+
}
|
|
228
|
+
Accidental(params) {
|
|
229
|
+
const accid = new Accidental(params.type);
|
|
230
|
+
accid.setContext(this.context);
|
|
231
|
+
return accid;
|
|
232
|
+
}
|
|
233
|
+
Annotation(params) {
|
|
234
|
+
const p = Object.assign({ text: 'p', hJustify: AnnotationHorizontalJustify.CENTER, vJustify: AnnotationVerticalJustify.BOTTOM }, params);
|
|
235
|
+
const annotation = new Annotation(p.text);
|
|
236
|
+
annotation.setJustification(p.hJustify);
|
|
237
|
+
annotation.setVerticalJustification(p.vJustify);
|
|
238
|
+
annotation.setFont(p.font);
|
|
239
|
+
annotation.setContext(this.context);
|
|
240
|
+
return annotation;
|
|
241
|
+
}
|
|
242
|
+
ChordSymbol(params) {
|
|
243
|
+
const p = Object.assign({ vJustify: 'top', hJustify: 'center', kerning: true, reportWidth: true }, params);
|
|
244
|
+
const chordSymbol = new ChordSymbol();
|
|
245
|
+
chordSymbol.setHorizontal(p.hJustify);
|
|
246
|
+
chordSymbol.setVertical(p.vJustify);
|
|
247
|
+
chordSymbol.setEnableKerning(p.kerning);
|
|
248
|
+
chordSymbol.setReportWidth(p.reportWidth);
|
|
249
|
+
if (typeof p.fontFamily === 'string' && typeof p.fontSize === 'number') {
|
|
250
|
+
if (typeof p.fontWeight === 'string')
|
|
251
|
+
chordSymbol.setFont(p.fontFamily, p.fontSize, p.fontWeight);
|
|
252
|
+
else
|
|
253
|
+
chordSymbol.setFont(p.fontFamily, p.fontSize, '');
|
|
254
|
+
}
|
|
255
|
+
else if (typeof p.fontSize === 'number') {
|
|
256
|
+
chordSymbol.setFontSize(p.fontSize);
|
|
257
|
+
}
|
|
258
|
+
chordSymbol.setContext(this.context);
|
|
259
|
+
return chordSymbol;
|
|
260
|
+
}
|
|
261
|
+
Articulation(params) {
|
|
262
|
+
const p = Object.assign({ type: 'a.', position: 'above' }, params);
|
|
263
|
+
const articulation = new Articulation(p.type);
|
|
264
|
+
articulation.setPosition(p.position);
|
|
265
|
+
articulation.setContext(this.context);
|
|
266
|
+
return articulation;
|
|
267
|
+
}
|
|
268
|
+
TextDynamics(params) {
|
|
269
|
+
const p = Object.assign({ text: 'p', duration: 'q', dots: 0, line: 0 }, params);
|
|
270
|
+
const text = new TextDynamics({
|
|
271
|
+
text: p.text,
|
|
272
|
+
line: p.line,
|
|
273
|
+
duration: p.duration,
|
|
274
|
+
dots: p.dots,
|
|
275
|
+
});
|
|
276
|
+
if (this.stave)
|
|
277
|
+
text.setStave(this.stave);
|
|
278
|
+
text.setContext(this.context);
|
|
279
|
+
this.renderQ.push(text);
|
|
280
|
+
return text;
|
|
281
|
+
}
|
|
282
|
+
Fingering(params) {
|
|
283
|
+
const p = Object.assign({ number: '0', position: 'left' }, params);
|
|
284
|
+
const fingering = new FretHandFinger(p.number);
|
|
285
|
+
fingering.setPosition(p.position);
|
|
286
|
+
fingering.setContext(this.context);
|
|
287
|
+
return fingering;
|
|
288
|
+
}
|
|
289
|
+
StringNumber(params) {
|
|
290
|
+
const stringNumber = new StringNumber(params.number);
|
|
291
|
+
stringNumber.setPosition(params.position);
|
|
292
|
+
stringNumber.setContext(this.context);
|
|
293
|
+
return stringNumber;
|
|
294
|
+
}
|
|
295
|
+
TickContext() {
|
|
296
|
+
return new TickContext();
|
|
297
|
+
}
|
|
298
|
+
ModifierContext() {
|
|
299
|
+
return new ModifierContext();
|
|
300
|
+
}
|
|
301
|
+
MultiMeasureRest(params) {
|
|
302
|
+
const numMeasures = defined(params.number_of_measures, 'NoNumberOfMeasures');
|
|
303
|
+
const multiMeasureRest = new MultiMeasureRest(numMeasures, params);
|
|
304
|
+
multiMeasureRest.setContext(this.context);
|
|
305
|
+
this.renderQ.push(multiMeasureRest);
|
|
306
|
+
return multiMeasureRest;
|
|
307
|
+
}
|
|
308
|
+
Voice(params) {
|
|
309
|
+
const p = Object.assign({ time: '4/4' }, params);
|
|
310
|
+
const voice = new Voice(p.time, p.options);
|
|
311
|
+
this.voices.push(voice);
|
|
312
|
+
return voice;
|
|
313
|
+
}
|
|
314
|
+
StaveConnector(params) {
|
|
315
|
+
const connector = new StaveConnector(params.top_stave, params.bottom_stave);
|
|
316
|
+
connector.setType(params.type).setContext(this.context);
|
|
317
|
+
this.renderQ.push(connector);
|
|
318
|
+
return connector;
|
|
319
|
+
}
|
|
320
|
+
Formatter(options) {
|
|
321
|
+
return new Formatter(options);
|
|
322
|
+
}
|
|
323
|
+
Tuplet(params) {
|
|
324
|
+
const p = Object.assign({ notes: [], options: {} }, params);
|
|
325
|
+
const tuplet = new Tuplet(p.notes, p.options).setContext(this.context);
|
|
326
|
+
this.renderQ.push(tuplet);
|
|
327
|
+
return tuplet;
|
|
328
|
+
}
|
|
329
|
+
Beam(params) {
|
|
330
|
+
var _a, _b, _c;
|
|
331
|
+
const beam = new Beam(params.notes, (_a = params.options) === null || _a === void 0 ? void 0 : _a.autoStem).setContext(this.context);
|
|
332
|
+
beam.breakSecondaryAt((_c = (_b = params.options) === null || _b === void 0 ? void 0 : _b.secondaryBeamBreaks) !== null && _c !== void 0 ? _c : []);
|
|
333
|
+
this.renderQ.push(beam);
|
|
334
|
+
return beam;
|
|
335
|
+
}
|
|
336
|
+
Curve(params) {
|
|
337
|
+
const curve = new Curve(params.from, params.to, params.options).setContext(this.context);
|
|
338
|
+
this.renderQ.push(curve);
|
|
339
|
+
return curve;
|
|
340
|
+
}
|
|
341
|
+
StaveTie(params) {
|
|
342
|
+
var _a;
|
|
343
|
+
const tie = new StaveTie({
|
|
344
|
+
first_note: params.from,
|
|
345
|
+
last_note: params.to,
|
|
346
|
+
first_indices: params.first_indices,
|
|
347
|
+
last_indices: params.last_indices,
|
|
348
|
+
}, params.text);
|
|
349
|
+
if ((_a = params.options) === null || _a === void 0 ? void 0 : _a.direction)
|
|
350
|
+
tie.setDirection(params.options.direction);
|
|
351
|
+
tie.setContext(this.context);
|
|
352
|
+
this.renderQ.push(tie);
|
|
353
|
+
return tie;
|
|
354
|
+
}
|
|
355
|
+
StaveLine(params) {
|
|
356
|
+
var _a, _b;
|
|
357
|
+
const line = new StaveLine({
|
|
358
|
+
first_note: params.from,
|
|
359
|
+
last_note: params.to,
|
|
360
|
+
first_indices: params.first_indices,
|
|
361
|
+
last_indices: params.last_indices,
|
|
362
|
+
});
|
|
363
|
+
if ((_a = params.options) === null || _a === void 0 ? void 0 : _a.text)
|
|
364
|
+
line.setText(params.options.text);
|
|
365
|
+
if ((_b = params.options) === null || _b === void 0 ? void 0 : _b.font)
|
|
366
|
+
line.setFont(params.options.font);
|
|
367
|
+
line.setContext(this.context);
|
|
368
|
+
this.renderQ.push(line);
|
|
369
|
+
return line;
|
|
370
|
+
}
|
|
371
|
+
VibratoBracket(params) {
|
|
372
|
+
const vibratoBracket = new VibratoBracket({
|
|
373
|
+
start: params.from,
|
|
374
|
+
stop: params.to,
|
|
375
|
+
});
|
|
376
|
+
if (params.options.line)
|
|
377
|
+
vibratoBracket.setLine(params.options.line);
|
|
378
|
+
if (params.options.harsh)
|
|
379
|
+
vibratoBracket.setHarsh(params.options.harsh);
|
|
380
|
+
vibratoBracket.setContext(this.context);
|
|
381
|
+
this.renderQ.push(vibratoBracket);
|
|
382
|
+
return vibratoBracket;
|
|
383
|
+
}
|
|
384
|
+
TextBracket(params) {
|
|
385
|
+
const textBracket = new TextBracket({
|
|
386
|
+
start: params.from,
|
|
387
|
+
stop: params.to,
|
|
388
|
+
text: params.text,
|
|
389
|
+
superscript: params.options.superscript,
|
|
390
|
+
position: params.options.position,
|
|
391
|
+
});
|
|
392
|
+
if (params.options.line)
|
|
393
|
+
textBracket.setLine(params.options.line);
|
|
394
|
+
if (params.options.font)
|
|
395
|
+
textBracket.setFont(params.options.font);
|
|
396
|
+
textBracket.setContext(this.context);
|
|
397
|
+
this.renderQ.push(textBracket);
|
|
398
|
+
return textBracket;
|
|
399
|
+
}
|
|
400
|
+
System(params = {}) {
|
|
401
|
+
params.factory = this;
|
|
402
|
+
const system = new System(params).setContext(this.context);
|
|
403
|
+
this.systems.push(system);
|
|
404
|
+
return system;
|
|
405
|
+
}
|
|
406
|
+
EasyScore(options = {}) {
|
|
407
|
+
options.factory = this;
|
|
408
|
+
return new EasyScore(options);
|
|
409
|
+
}
|
|
410
|
+
PedalMarking(params) {
|
|
411
|
+
const p = Object.assign({ notes: [], options: {
|
|
412
|
+
style: 'mixed',
|
|
413
|
+
} }, params);
|
|
414
|
+
const pedal = new PedalMarking(p.notes);
|
|
415
|
+
pedal.setType(PedalMarking.typeString[p.options.style]);
|
|
416
|
+
pedal.setContext(this.context);
|
|
417
|
+
this.renderQ.push(pedal);
|
|
418
|
+
return pedal;
|
|
419
|
+
}
|
|
420
|
+
NoteSubGroup(params) {
|
|
421
|
+
const p = Object.assign({ notes: [] }, params);
|
|
422
|
+
const group = new NoteSubGroup(p.notes);
|
|
423
|
+
group.setContext(this.context);
|
|
424
|
+
return group;
|
|
425
|
+
}
|
|
426
|
+
draw() {
|
|
427
|
+
const ctx = this.context;
|
|
428
|
+
this.systems.forEach((s) => s.setContext(ctx).format());
|
|
429
|
+
this.staves.forEach((s) => s.setContext(ctx).draw());
|
|
430
|
+
this.voices.forEach((v) => v.setContext(ctx).draw());
|
|
431
|
+
this.renderQ.forEach((e) => {
|
|
432
|
+
if (!e.isRendered())
|
|
433
|
+
e.setContext(ctx).draw();
|
|
434
|
+
});
|
|
435
|
+
this.systems.forEach((s) => s.setContext(ctx).draw());
|
|
436
|
+
this.reset();
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
Factory.DEBUG = false;
|
|
440
|
+
Factory.TEXT_FONT = Object.assign({}, Element.TEXT_FONT);
|