@mcqj/vexflow 0.0.1-alpha.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/LICENSE +22 -0
- package/README.md +208 -0
- package/build/cjs/vexflow-bravura.js +2 -0
- package/build/cjs/vexflow-bravura.js.map +1 -0
- package/build/cjs/vexflow-core.js +2 -0
- package/build/cjs/vexflow-core.js.map +1 -0
- package/build/cjs/vexflow-debug-with-tests.js +43475 -0
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -0
- package/build/cjs/vexflow-debug.js +19194 -0
- package/build/cjs/vexflow-debug.js.map +1 -0
- package/build/cjs/vexflow.js +2 -0
- package/build/cjs/vexflow.js.map +1 -0
- package/build/esm/entry/vexflow-bravura.js +17 -0
- package/build/esm/entry/vexflow-core.js +4 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +38 -0
- package/build/esm/entry/vexflow-debug.js +31 -0
- package/build/esm/entry/vexflow.js +31 -0
- package/build/esm/package.json +3 -0
- package/build/esm/src/accidental.js +330 -0
- package/build/esm/src/annotation.js +231 -0
- package/build/esm/src/articulation.js +281 -0
- package/build/esm/src/barnote.js +56 -0
- package/build/esm/src/beam.js +644 -0
- package/build/esm/src/bend.js +186 -0
- package/build/esm/src/boundingbox.js +59 -0
- package/build/esm/src/canvascontext.js +216 -0
- package/build/esm/src/chordsymbol.js +325 -0
- package/build/esm/src/clef.js +120 -0
- package/build/esm/src/clefnote.js +35 -0
- package/build/esm/src/crescendo.js +78 -0
- package/build/esm/src/curve.js +126 -0
- package/build/esm/src/dot.js +129 -0
- package/build/esm/src/easyscore.js +374 -0
- package/build/esm/src/element.js +409 -0
- package/build/esm/src/factory.js +463 -0
- package/build/esm/src/flag.js +22 -0
- package/build/esm/src/font.js +237 -0
- package/build/esm/src/fonts/academico.js +1 -0
- package/build/esm/src/fonts/academicobold.js +1 -0
- package/build/esm/src/fonts/bravura.js +1 -0
- package/build/esm/src/fonts/gonville.js +1 -0
- package/build/esm/src/fonts/petaluma.js +1 -0
- package/build/esm/src/fonts/petalumascript.js +1 -0
- package/build/esm/src/formatter.js +610 -0
- package/build/esm/src/fraction.js +170 -0
- package/build/esm/src/frethandfinger.js +141 -0
- package/build/esm/src/ghostnote.js +50 -0
- package/build/esm/src/glyphnote.js +44 -0
- package/build/esm/src/glyphs.js +2936 -0
- package/build/esm/src/gracenote.js +106 -0
- package/build/esm/src/gracenotegroup.js +138 -0
- package/build/esm/src/gracetabnote.js +11 -0
- package/build/esm/src/index.js +86 -0
- package/build/esm/src/keymanager.js +99 -0
- package/build/esm/src/keysignature.js +220 -0
- package/build/esm/src/keysignote.js +28 -0
- package/build/esm/src/metrics.js +237 -0
- package/build/esm/src/modifier.js +121 -0
- package/build/esm/src/modifiercontext.js +110 -0
- package/build/esm/src/multimeasurerest.js +127 -0
- package/build/esm/src/music.js +322 -0
- package/build/esm/src/note.js +383 -0
- package/build/esm/src/notehead.js +89 -0
- package/build/esm/src/notesubgroup.js +59 -0
- package/build/esm/src/ornament.js +192 -0
- package/build/esm/src/parenthesis.js +61 -0
- package/build/esm/src/parser.js +164 -0
- package/build/esm/src/pedalmarking.js +168 -0
- package/build/esm/src/registry.js +81 -0
- package/build/esm/src/rendercontext.js +20 -0
- package/build/esm/src/renderer.js +112 -0
- package/build/esm/src/repeatnote.js +17 -0
- package/build/esm/src/stave.js +579 -0
- package/build/esm/src/stavebarline.js +237 -0
- package/build/esm/src/staveconnector.js +180 -0
- package/build/esm/src/stavehairpin.js +115 -0
- package/build/esm/src/staveline.js +199 -0
- package/build/esm/src/stavemodifier.js +56 -0
- package/build/esm/src/stavenote.js +861 -0
- package/build/esm/src/staverepetition.js +120 -0
- package/build/esm/src/stavesection.js +36 -0
- package/build/esm/src/stavetempo.js +110 -0
- package/build/esm/src/stavetext.js +55 -0
- package/build/esm/src/stavetie.js +186 -0
- package/build/esm/src/stavevolta.js +53 -0
- package/build/esm/src/stem.js +133 -0
- package/build/esm/src/stemmablenote.js +193 -0
- package/build/esm/src/stringnumber.js +228 -0
- package/build/esm/src/strokes.js +164 -0
- package/build/esm/src/svgcontext.js +402 -0
- package/build/esm/src/system.js +166 -0
- package/build/esm/src/tables.js +696 -0
- package/build/esm/src/tabnote.js +278 -0
- package/build/esm/src/tabslide.js +68 -0
- package/build/esm/src/tabstave.js +17 -0
- package/build/esm/src/tabtie.js +19 -0
- package/build/esm/src/textbracket.js +128 -0
- package/build/esm/src/textdynamics.js +53 -0
- package/build/esm/src/textnote.js +116 -0
- package/build/esm/src/tickable.js +224 -0
- package/build/esm/src/tickcontext.js +189 -0
- package/build/esm/src/timesignature.js +169 -0
- package/build/esm/src/timesignote.js +30 -0
- package/build/esm/src/tremolo.js +30 -0
- package/build/esm/src/tuning.js +55 -0
- package/build/esm/src/tuplet.js +258 -0
- package/build/esm/src/typeguard.js +30 -0
- package/build/esm/src/util.js +67 -0
- package/build/esm/src/version.js +3 -0
- package/build/esm/src/vexflow.js +309 -0
- package/build/esm/src/vibrato.js +68 -0
- package/build/esm/src/vibratobracket.js +44 -0
- package/build/esm/src/voice.js +178 -0
- package/build/esm/src/web.js +15 -0
- package/build/esm/tests/accidental_tests.js +1055 -0
- package/build/esm/tests/annotation_tests.js +381 -0
- package/build/esm/tests/articulation_tests.js +432 -0
- package/build/esm/tests/auto_beam_formatting_tests.js +551 -0
- package/build/esm/tests/barline_tests.js +52 -0
- package/build/esm/tests/beam_tests.js +669 -0
- package/build/esm/tests/bend_tests.js +223 -0
- package/build/esm/tests/boundingbox_tests.js +53 -0
- package/build/esm/tests/browser_test_runner.js +128 -0
- package/build/esm/tests/chordsymbol_tests.js +405 -0
- package/build/esm/tests/clef_tests.js +141 -0
- package/build/esm/tests/crossbeam_tests.js +306 -0
- package/build/esm/tests/curve_tests.js +152 -0
- package/build/esm/tests/demo_petzold_tests.js +335 -0
- package/build/esm/tests/dot_tests.js +119 -0
- package/build/esm/tests/easyscore_tests.js +488 -0
- package/build/esm/tests/factory_tests.js +44 -0
- package/build/esm/tests/font_tests.js +134 -0
- package/build/esm/tests/formatter/framestack.js +61 -0
- package/build/esm/tests/formatter/tests.js +251 -0
- package/build/esm/tests/formatter_tests.js +759 -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 +119 -0
- package/build/esm/tests/gracenote_tests.js +414 -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 +106 -0
- package/build/esm/tests/keymanager_tests.js +68 -0
- package/build/esm/tests/keysignature_tests.js +322 -0
- package/build/esm/tests/mocks.js +70 -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/node_test_runner.js +31 -0
- package/build/esm/tests/notehead_tests.js +224 -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 +333 -0
- package/build/esm/tests/parser_tests.js +122 -0
- package/build/esm/tests/pedalmarking_tests.js +91 -0
- package/build/esm/tests/percussion_tests.js +184 -0
- package/build/esm/tests/playwright/flow.spec.js +127 -0
- package/build/esm/tests/playwright/visual_helpers.js +30 -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 +266 -0
- package/build/esm/tests/rhythm_tests.js +357 -0
- package/build/esm/tests/stave_tests.js +570 -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 +123 -0
- package/build/esm/tests/stavemodifier_tests.js +51 -0
- package/build/esm/tests/stavenote_tests.js +936 -0
- package/build/esm/tests/stavetie_tests.js +137 -0
- package/build/esm/tests/stringnumber_tests.js +283 -0
- package/build/esm/tests/strokes_tests.js +289 -0
- package/build/esm/tests/style_tests.js +96 -0
- package/build/esm/tests/tabnote_tests.js +462 -0
- package/build/esm/tests/tabslide_tests.js +133 -0
- package/build/esm/tests/tabstave_tests.js +24 -0
- package/build/esm/tests/tabtie_tests.js +171 -0
- package/build/esm/tests/test_runner.js +23 -0
- package/build/esm/tests/textbracket_tests.js +100 -0
- package/build/esm/tests/textnote_tests.js +216 -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 +173 -0
- package/build/esm/tests/tremolo_tests.js +34 -0
- package/build/esm/tests/tuning_tests.js +56 -0
- package/build/esm/tests/tuplet_tests.js +711 -0
- package/build/esm/tests/typeguard_tests.js +82 -0
- package/build/esm/tests/unison_tests.js +74 -0
- package/build/esm/tests/vexflow_test_helpers.js +318 -0
- package/build/esm/tests/vf_prefix_tests.js +101 -0
- package/build/esm/tests/vibrato_tests.js +93 -0
- package/build/esm/tests/vibratobracket_tests.js +45 -0
- package/build/esm/tests/vitest/job-0.test.js +2 -0
- package/build/esm/tests/vitest/job-1.test.js +2 -0
- package/build/esm/tests/vitest/job-2.test.js +2 -0
- package/build/esm/tests/vitest/job-3.test.js +2 -0
- package/build/esm/tests/vitest/run.js +5 -0
- package/build/esm/tests/vitest.setup.js +44 -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.d.ts +3 -0
- package/build/types/src/accidental.d.ts +60 -0
- package/build/types/src/annotation.d.ts +58 -0
- package/build/types/src/articulation.d.ts +78 -0
- package/build/types/src/barnote.d.ts +29 -0
- package/build/types/src/beam.d.ts +158 -0
- package/build/types/src/bend.d.ts +67 -0
- package/build/types/src/boundingbox.d.ts +42 -0
- package/build/types/src/canvascontext.d.ts +93 -0
- package/build/types/src/chordsymbol.d.ts +109 -0
- package/build/types/src/clef.d.ts +38 -0
- package/build/types/src/clefnote.d.ts +17 -0
- package/build/types/src/crescendo.d.ts +26 -0
- package/build/types/src/curve.d.ts +42 -0
- package/build/types/src/dot.d.ts +19 -0
- package/build/types/src/easyscore.d.ts +152 -0
- package/build/types/src/element.d.ts +278 -0
- package/build/types/src/factory.d.ts +273 -0
- package/build/types/src/flag.d.ts +12 -0
- package/build/types/src/font.d.ts +96 -0
- package/build/types/src/fonts/academico.d.ts +1 -0
- package/build/types/src/fonts/academicobold.d.ts +1 -0
- package/build/types/src/fonts/bravura.d.ts +1 -0
- package/build/types/src/fonts/gonville.d.ts +1 -0
- package/build/types/src/fonts/petaluma.d.ts +1 -0
- package/build/types/src/fonts/petalumascript.d.ts +1 -0
- package/build/types/src/formatter.d.ts +226 -0
- package/build/types/src/fraction.d.ts +65 -0
- package/build/types/src/frethandfinger.d.ts +19 -0
- package/build/types/src/ghostnote.d.ts +16 -0
- package/build/types/src/glyphnote.d.ts +14 -0
- package/build/types/src/glyphs.d.ts +2935 -0
- package/build/types/src/gracenote.d.ts +17 -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 +86 -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/metrics.d.ts +25 -0
- package/build/types/src/modifier.d.ts +90 -0
- package/build/types/src/modifiercontext.d.ts +48 -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 +50 -0
- package/build/types/src/notesubgroup.d.ts +18 -0
- package/build/types/src/ornament.d.ts +71 -0
- package/build/types/src/parenthesis.d.ts +21 -0
- package/build/types/src/parser.d.ts +45 -0
- package/build/types/src/pedalmarking.d.ts +63 -0
- package/build/types/src/registry.d.ts +40 -0
- package/build/types/src/rendercontext.d.ts +59 -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 +181 -0
- package/build/types/src/stavebarline.d.ts +38 -0
- package/build/types/src/staveconnector.d.ts +53 -0
- package/build/types/src/stavehairpin.d.ts +56 -0
- package/build/types/src/staveline.d.ts +49 -0
- package/build/types/src/stavemodifier.d.ts +35 -0
- package/build/types/src/stavenote.d.ts +150 -0
- package/build/types/src/staverepetition.d.ts +30 -0
- package/build/types/src/stavesection.d.ts +8 -0
- package/build/types/src/stavetempo.d.ts +43 -0
- package/build/types/src/stavetext.d.ts +11 -0
- package/build/types/src/stavetie.d.ts +104 -0
- package/build/types/src/stavevolta.d.ts +15 -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 +26 -0
- package/build/types/src/strokes.d.ts +35 -0
- package/build/types/src/svgcontext.d.ts +135 -0
- package/build/types/src/system.d.ts +121 -0
- package/build/types/src/tables.d.ts +86 -0
- package/build/types/src/tabnote.d.ts +45 -0
- package/build/types/src/tabslide.d.ts +36 -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 +45 -0
- package/build/types/src/textdynamics.d.ts +34 -0
- package/build/types/src/textnote.d.ts +48 -0
- package/build/types/src/tickable.d.ts +149 -0
- package/build/types/src/tickcontext.d.ts +112 -0
- package/build/types/src/timesignature.d.ts +75 -0
- package/build/types/src/timesignote.d.ts +11 -0
- package/build/types/src/tremolo.d.ts +12 -0
- package/build/types/src/tuning.d.ts +23 -0
- package/build/types/src/tuplet.d.ts +98 -0
- package/build/types/src/typeguard.d.ts +100 -0
- package/build/types/src/util.d.ts +42 -0
- package/build/types/src/version.d.ts +3 -0
- package/build/types/src/vexflow.d.ts +261 -0
- package/build/types/src/vibrato.d.ts +20 -0
- package/build/types/src/vibratobracket.d.ts +28 -0
- package/build/types/src/voice.d.ts +109 -0
- package/build/types/src/web.d.ts +2 -0
- package/package.json +145 -0
- package/tests/flow.html +256 -0
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
import { BoundingBox } from './boundingbox.js';
|
|
2
|
+
import { Clef } from './clef.js';
|
|
3
|
+
import { Element } from './element.js';
|
|
4
|
+
import { KeySignature } from './keysignature.js';
|
|
5
|
+
import { Metrics } from './metrics.js';
|
|
6
|
+
import { Barline, BarlineType, RepeatBracketType } from './stavebarline.js';
|
|
7
|
+
import { StaveModifierPosition } from './stavemodifier.js';
|
|
8
|
+
import { Repetition } from './staverepetition.js';
|
|
9
|
+
import { StaveSection } from './stavesection.js';
|
|
10
|
+
import { StaveTempo } from './stavetempo.js';
|
|
11
|
+
import { StaveText } from './stavetext.js';
|
|
12
|
+
import { Volta } from './stavevolta.js';
|
|
13
|
+
import { Tables } from './tables.js';
|
|
14
|
+
import { TimeSignature } from './timesignature.js';
|
|
15
|
+
import { isBarline } from './typeguard.js';
|
|
16
|
+
import { RuntimeError } from './util.js';
|
|
17
|
+
const SORT_ORDER_BEG_MODIFIERS = {
|
|
18
|
+
[Barline.CATEGORY]: 0,
|
|
19
|
+
[Clef.CATEGORY]: 1,
|
|
20
|
+
[KeySignature.CATEGORY]: 2,
|
|
21
|
+
[TimeSignature.CATEGORY]: 3,
|
|
22
|
+
};
|
|
23
|
+
const SORT_ORDER_END_MODIFIERS = {
|
|
24
|
+
[TimeSignature.CATEGORY]: 0,
|
|
25
|
+
[KeySignature.CATEGORY]: 1,
|
|
26
|
+
[Barline.CATEGORY]: 2,
|
|
27
|
+
[Clef.CATEGORY]: 3,
|
|
28
|
+
};
|
|
29
|
+
export class Stave extends Element {
|
|
30
|
+
static get CATEGORY() {
|
|
31
|
+
return "Stave";
|
|
32
|
+
}
|
|
33
|
+
static get defaultPadding() {
|
|
34
|
+
return Metrics.get('Stave.padding') + Metrics.get('Stave.endPaddingMax');
|
|
35
|
+
}
|
|
36
|
+
static get rightPadding() {
|
|
37
|
+
return Metrics.get('Stave.endPaddingMax');
|
|
38
|
+
}
|
|
39
|
+
constructor(x, y, width, options) {
|
|
40
|
+
super();
|
|
41
|
+
this.x = x;
|
|
42
|
+
this.y = y;
|
|
43
|
+
this.width = width;
|
|
44
|
+
this.formatted = false;
|
|
45
|
+
this.startX = x + 5;
|
|
46
|
+
this.endX = x + width;
|
|
47
|
+
this.modifiers = [];
|
|
48
|
+
this.measure = 0;
|
|
49
|
+
this.clef = 'treble';
|
|
50
|
+
this.endClef = undefined;
|
|
51
|
+
this.options = Object.assign({ verticalBarWidth: 10, numLines: 5, leftBar: true, rightBar: true, spacingBetweenLinesPx: Tables.STAVE_LINE_DISTANCE, spaceAboveStaffLn: 4, spaceBelowStaffLn: 4, topTextPosition: 1, bottomTextPosition: 4, lineConfig: [] }, options);
|
|
52
|
+
this.bounds = { x: this.x, y: this.y, w: this.width, h: 0 };
|
|
53
|
+
this.defaultLedgerLineStyle = { strokeStyle: '#444', lineWidth: 2 };
|
|
54
|
+
this.resetLines();
|
|
55
|
+
this.addModifier(new Barline(this.options.leftBar ? BarlineType.SINGLE : BarlineType.NONE));
|
|
56
|
+
this.addEndModifier(new Barline(this.options.rightBar ? BarlineType.SINGLE : BarlineType.NONE));
|
|
57
|
+
}
|
|
58
|
+
setDefaultLedgerLineStyle(style) {
|
|
59
|
+
this.defaultLedgerLineStyle = style;
|
|
60
|
+
}
|
|
61
|
+
getDefaultLedgerLineStyle() {
|
|
62
|
+
return Object.assign(Object.assign({}, this.getStyle()), this.defaultLedgerLineStyle);
|
|
63
|
+
}
|
|
64
|
+
space(spacing) {
|
|
65
|
+
return this.options.spacingBetweenLinesPx * spacing;
|
|
66
|
+
}
|
|
67
|
+
resetLines() {
|
|
68
|
+
this.options.lineConfig = [];
|
|
69
|
+
for (let i = 0; i < this.options.numLines; i++) {
|
|
70
|
+
this.options.lineConfig.push({ visible: true });
|
|
71
|
+
}
|
|
72
|
+
this.height = (this.options.numLines + this.options.spaceAboveStaffLn) * this.options.spacingBetweenLinesPx;
|
|
73
|
+
this.options.bottomTextPosition = this.options.numLines;
|
|
74
|
+
}
|
|
75
|
+
setNoteStartX(x) {
|
|
76
|
+
if (!this.formatted)
|
|
77
|
+
this.format();
|
|
78
|
+
this.startX = x;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
getNoteStartX() {
|
|
82
|
+
if (!this.formatted)
|
|
83
|
+
this.format();
|
|
84
|
+
return this.startX;
|
|
85
|
+
}
|
|
86
|
+
getNoteEndX() {
|
|
87
|
+
if (!this.formatted)
|
|
88
|
+
this.format();
|
|
89
|
+
return this.endX;
|
|
90
|
+
}
|
|
91
|
+
getTieStartX() {
|
|
92
|
+
return this.startX;
|
|
93
|
+
}
|
|
94
|
+
getTieEndX() {
|
|
95
|
+
return this.endX;
|
|
96
|
+
}
|
|
97
|
+
getNumLines() {
|
|
98
|
+
return this.options.numLines;
|
|
99
|
+
}
|
|
100
|
+
setNumLines(n) {
|
|
101
|
+
this.options.numLines = n;
|
|
102
|
+
this.resetLines();
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
getTopLineTopY() {
|
|
106
|
+
return this.getYForLine(0);
|
|
107
|
+
}
|
|
108
|
+
getBottomLineBottomY() {
|
|
109
|
+
var _a;
|
|
110
|
+
return this.getYForLine(this.getNumLines() - 1) + ((_a = this.getStyle().lineWidth) !== null && _a !== void 0 ? _a : 1);
|
|
111
|
+
}
|
|
112
|
+
setX(x) {
|
|
113
|
+
const shift = x - this.x;
|
|
114
|
+
this.formatted = false;
|
|
115
|
+
this.x = x;
|
|
116
|
+
this.startX += shift;
|
|
117
|
+
this.endX += shift;
|
|
118
|
+
for (let i = 0; i < this.modifiers.length; i++) {
|
|
119
|
+
const mod = this.modifiers[i];
|
|
120
|
+
mod.setX(mod.getX() + shift);
|
|
121
|
+
}
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
setWidth(width) {
|
|
125
|
+
this.formatted = false;
|
|
126
|
+
this.width = width;
|
|
127
|
+
this.endX = this.x + width;
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
setMeasure(measure) {
|
|
131
|
+
this.measure = measure;
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
getMeasure() {
|
|
135
|
+
return this.measure;
|
|
136
|
+
}
|
|
137
|
+
getModifierXShift(index = 0) {
|
|
138
|
+
if (typeof index !== 'number') {
|
|
139
|
+
throw new RuntimeError('InvalidIndex', 'Must be of number type');
|
|
140
|
+
}
|
|
141
|
+
if (!this.formatted)
|
|
142
|
+
this.format();
|
|
143
|
+
if (this.getModifiers(StaveModifierPosition.BEGIN).length === 1) {
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
if (this.modifiers[index].getPosition() === StaveModifierPosition.RIGHT) {
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
let startX = this.startX - this.x;
|
|
150
|
+
const begBarline = this.modifiers[0];
|
|
151
|
+
if (begBarline.getType() === BarlineType.REPEAT_BEGIN && startX > begBarline.getWidth()) {
|
|
152
|
+
startX -= begBarline.getWidth();
|
|
153
|
+
}
|
|
154
|
+
return startX;
|
|
155
|
+
}
|
|
156
|
+
setRepetitionType(type, yShift = 0) {
|
|
157
|
+
this.modifiers.push(new Repetition(type, this.x, yShift));
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
setVoltaType(type, label, y) {
|
|
161
|
+
this.modifiers.push(new Volta(type, label, this.x, y));
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
setSection(section, y, xOffset = 0, fontSize, drawRect = true) {
|
|
165
|
+
const staveSection = new StaveSection(section).setYShift(y).setXShift(xOffset).setDrawRect(drawRect);
|
|
166
|
+
if (fontSize) {
|
|
167
|
+
staveSection.setFontSize(fontSize);
|
|
168
|
+
}
|
|
169
|
+
this.addModifier(staveSection);
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
setTempo(tempo, y) {
|
|
173
|
+
this.modifiers.push(new StaveTempo(tempo, this.x, y));
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
setStaveText(text, position, options = {}) {
|
|
177
|
+
this.modifiers.push(new StaveText(text, position, options));
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
getSpacingBetweenLines() {
|
|
181
|
+
return this.options.spacingBetweenLinesPx;
|
|
182
|
+
}
|
|
183
|
+
getBoundingBox() {
|
|
184
|
+
return new BoundingBox(this.x, this.y, this.width, this.getBottomY() - this.y);
|
|
185
|
+
}
|
|
186
|
+
getBottomY() {
|
|
187
|
+
const options = this.options;
|
|
188
|
+
const spacing = options.spacingBetweenLinesPx;
|
|
189
|
+
const scoreBottom = this.getYForLine(options.numLines) + options.spaceBelowStaffLn * spacing;
|
|
190
|
+
return scoreBottom;
|
|
191
|
+
}
|
|
192
|
+
getBottomLineY() {
|
|
193
|
+
return this.getYForLine(this.options.numLines);
|
|
194
|
+
}
|
|
195
|
+
getYForLine(line) {
|
|
196
|
+
const options = this.options;
|
|
197
|
+
const spacing = options.spacingBetweenLinesPx;
|
|
198
|
+
const headroom = options.spaceAboveStaffLn;
|
|
199
|
+
const y = this.y + line * spacing + headroom * spacing;
|
|
200
|
+
return y;
|
|
201
|
+
}
|
|
202
|
+
getLineForY(y) {
|
|
203
|
+
const options = this.options;
|
|
204
|
+
const spacing = options.spacingBetweenLinesPx;
|
|
205
|
+
const headroom = options.spaceAboveStaffLn;
|
|
206
|
+
return (y - this.y) / spacing - headroom;
|
|
207
|
+
}
|
|
208
|
+
getYForTopText(line = 0) {
|
|
209
|
+
return this.getYForLine(-line - this.options.topTextPosition);
|
|
210
|
+
}
|
|
211
|
+
getYForBottomText(line = 0) {
|
|
212
|
+
return this.getYForLine(this.options.bottomTextPosition + line);
|
|
213
|
+
}
|
|
214
|
+
getYForNote(line) {
|
|
215
|
+
const options = this.options;
|
|
216
|
+
const spacing = options.spacingBetweenLinesPx;
|
|
217
|
+
const headroom = options.spaceAboveStaffLn;
|
|
218
|
+
return this.y + headroom * spacing + 5 * spacing - line * spacing;
|
|
219
|
+
}
|
|
220
|
+
getYForGlyphs() {
|
|
221
|
+
return this.getYForLine(3);
|
|
222
|
+
}
|
|
223
|
+
addModifier(modifier, position) {
|
|
224
|
+
if (position !== undefined) {
|
|
225
|
+
modifier.setPosition(position);
|
|
226
|
+
}
|
|
227
|
+
modifier.setStave(this);
|
|
228
|
+
this.formatted = false;
|
|
229
|
+
this.modifiers.push(modifier);
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
232
|
+
addEndModifier(modifier) {
|
|
233
|
+
this.addModifier(modifier, StaveModifierPosition.END);
|
|
234
|
+
return this;
|
|
235
|
+
}
|
|
236
|
+
setBegBarType(type, repeatBracket = RepeatBracketType.NONE) {
|
|
237
|
+
const { SINGLE, REPEAT_BEGIN, NONE } = BarlineType;
|
|
238
|
+
if (type === SINGLE || type === REPEAT_BEGIN || type === NONE) {
|
|
239
|
+
this.modifiers[0].setType(type).setRepeatBracket(repeatBracket);
|
|
240
|
+
this.formatted = false;
|
|
241
|
+
}
|
|
242
|
+
return this;
|
|
243
|
+
}
|
|
244
|
+
setEndBarType(type, repeatBracket = RepeatBracketType.NONE) {
|
|
245
|
+
if (type !== BarlineType.REPEAT_BEGIN) {
|
|
246
|
+
this.modifiers[1].setType(type).setRepeatBracket(repeatBracket);
|
|
247
|
+
this.formatted = false;
|
|
248
|
+
}
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
setClef(clefSpec, size, annotation, position) {
|
|
252
|
+
if (position === undefined) {
|
|
253
|
+
position = StaveModifierPosition.BEGIN;
|
|
254
|
+
}
|
|
255
|
+
if (position === StaveModifierPosition.END) {
|
|
256
|
+
this.endClef = clefSpec;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
this.clef = clefSpec;
|
|
260
|
+
}
|
|
261
|
+
const clefs = this.getModifiers(position, Clef.CATEGORY);
|
|
262
|
+
if (clefs.length === 0) {
|
|
263
|
+
this.addClef(clefSpec, size, annotation, position);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
clefs[0].setType(clefSpec, size, annotation);
|
|
267
|
+
}
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
getClef() {
|
|
271
|
+
return this.clef;
|
|
272
|
+
}
|
|
273
|
+
setEndClef(clefSpec, size, annotation) {
|
|
274
|
+
this.setClef(clefSpec, size, annotation, StaveModifierPosition.END);
|
|
275
|
+
return this;
|
|
276
|
+
}
|
|
277
|
+
getEndClef() {
|
|
278
|
+
return this.endClef;
|
|
279
|
+
}
|
|
280
|
+
setKeySignature(keySpec, cancelKeySpec, position) {
|
|
281
|
+
if (position === undefined) {
|
|
282
|
+
position = StaveModifierPosition.BEGIN;
|
|
283
|
+
}
|
|
284
|
+
const keySignatures = this.getModifiers(position, KeySignature.CATEGORY);
|
|
285
|
+
if (keySignatures.length === 0) {
|
|
286
|
+
this.addKeySignature(keySpec, cancelKeySpec, position);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
keySignatures[0].setKeySig(keySpec, cancelKeySpec);
|
|
290
|
+
}
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
setEndKeySignature(keySpec, cancelKeySpec) {
|
|
294
|
+
this.setKeySignature(keySpec, cancelKeySpec, StaveModifierPosition.END);
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
setTimeSignature(timeSpec, customPadding, position) {
|
|
298
|
+
if (position === undefined) {
|
|
299
|
+
position = StaveModifierPosition.BEGIN;
|
|
300
|
+
}
|
|
301
|
+
const timeSignatures = this.getModifiers(position, TimeSignature.CATEGORY);
|
|
302
|
+
if (timeSignatures.length === 0) {
|
|
303
|
+
this.addTimeSignature(timeSpec, customPadding, position);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
timeSignatures[0].setTimeSig(timeSpec);
|
|
307
|
+
}
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
setEndTimeSignature(timeSpec, customPadding) {
|
|
311
|
+
this.setTimeSignature(timeSpec, customPadding, StaveModifierPosition.END);
|
|
312
|
+
return this;
|
|
313
|
+
}
|
|
314
|
+
addKeySignature(keySpec, cancelKeySpec, position) {
|
|
315
|
+
if (position === undefined) {
|
|
316
|
+
position = StaveModifierPosition.BEGIN;
|
|
317
|
+
}
|
|
318
|
+
this.addModifier(new KeySignature(keySpec, cancelKeySpec).setPosition(position), position);
|
|
319
|
+
return this;
|
|
320
|
+
}
|
|
321
|
+
addClef(clef, size, annotation, position) {
|
|
322
|
+
if (position === undefined || position === StaveModifierPosition.BEGIN) {
|
|
323
|
+
this.clef = clef;
|
|
324
|
+
}
|
|
325
|
+
else if (position === StaveModifierPosition.END) {
|
|
326
|
+
this.endClef = clef;
|
|
327
|
+
}
|
|
328
|
+
this.addModifier(new Clef(clef, size, annotation), position);
|
|
329
|
+
return this;
|
|
330
|
+
}
|
|
331
|
+
addEndClef(clef, size, annotation) {
|
|
332
|
+
this.addClef(clef, size, annotation, StaveModifierPosition.END);
|
|
333
|
+
return this;
|
|
334
|
+
}
|
|
335
|
+
addTimeSignature(timeSpec, customPadding, position) {
|
|
336
|
+
this.addModifier(new TimeSignature(timeSpec, customPadding), position);
|
|
337
|
+
return this;
|
|
338
|
+
}
|
|
339
|
+
addEndTimeSignature(timeSpec, customPadding) {
|
|
340
|
+
this.addTimeSignature(timeSpec, customPadding, StaveModifierPosition.END);
|
|
341
|
+
return this;
|
|
342
|
+
}
|
|
343
|
+
addTrebleGlyph() {
|
|
344
|
+
this.addClef('treble');
|
|
345
|
+
return this;
|
|
346
|
+
}
|
|
347
|
+
getModifiers(position, category) {
|
|
348
|
+
const noPosition = position === undefined;
|
|
349
|
+
const noCategory = category === undefined;
|
|
350
|
+
if (noPosition && noCategory) {
|
|
351
|
+
return this.modifiers;
|
|
352
|
+
}
|
|
353
|
+
else if (noPosition) {
|
|
354
|
+
return this.modifiers.filter((m) => category === m.getCategory());
|
|
355
|
+
}
|
|
356
|
+
else if (noCategory) {
|
|
357
|
+
return this.modifiers.filter((m) => position === m.getPosition());
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
return this.modifiers.filter((m) => position === m.getPosition() && category === m.getCategory());
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
sortByCategory(items, order) {
|
|
364
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
365
|
+
for (let j = 0; j < i; j++) {
|
|
366
|
+
if (order[items[j].getCategory()] > order[items[j + 1].getCategory()]) {
|
|
367
|
+
const temp = items[j];
|
|
368
|
+
items[j] = items[j + 1];
|
|
369
|
+
items[j + 1] = temp;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
format() {
|
|
375
|
+
var _a, _b, _c, _d;
|
|
376
|
+
const begBarline = this.modifiers[0];
|
|
377
|
+
const endBarline = this.modifiers[1];
|
|
378
|
+
const begModifiers = this.getModifiers(StaveModifierPosition.BEGIN);
|
|
379
|
+
const endModifiers = this.getModifiers(StaveModifierPosition.END);
|
|
380
|
+
this.sortByCategory(begModifiers, SORT_ORDER_BEG_MODIFIERS);
|
|
381
|
+
this.sortByCategory(endModifiers, SORT_ORDER_END_MODIFIERS);
|
|
382
|
+
if (begModifiers.length > 1 && begBarline.getType() === BarlineType.REPEAT_BEGIN) {
|
|
383
|
+
begModifiers.push(begModifiers.splice(0, 1)[0]);
|
|
384
|
+
begModifiers.splice(0, 0, new Barline(BarlineType.SINGLE));
|
|
385
|
+
}
|
|
386
|
+
if (endModifiers.indexOf(endBarline) > 0) {
|
|
387
|
+
endModifiers.splice(0, 0, new Barline(BarlineType.NONE));
|
|
388
|
+
}
|
|
389
|
+
let width;
|
|
390
|
+
let padding;
|
|
391
|
+
let modifier;
|
|
392
|
+
let offset = 0;
|
|
393
|
+
let x = this.x;
|
|
394
|
+
for (let i = 0; i < begModifiers.length; i++) {
|
|
395
|
+
modifier = begModifiers[i];
|
|
396
|
+
padding = modifier.getPadding(i + offset);
|
|
397
|
+
width = modifier.getWidth();
|
|
398
|
+
x += padding;
|
|
399
|
+
modifier.setX(x);
|
|
400
|
+
x += width;
|
|
401
|
+
if (padding + width === 0)
|
|
402
|
+
offset--;
|
|
403
|
+
}
|
|
404
|
+
this.startX = x;
|
|
405
|
+
x = this.x + this.width;
|
|
406
|
+
const widths = {
|
|
407
|
+
left: 0,
|
|
408
|
+
right: 0,
|
|
409
|
+
paddingRight: 0,
|
|
410
|
+
paddingLeft: 0,
|
|
411
|
+
};
|
|
412
|
+
let lastBarlineIdx = 0;
|
|
413
|
+
for (let i = 0; i < endModifiers.length; i++) {
|
|
414
|
+
modifier = endModifiers[i];
|
|
415
|
+
lastBarlineIdx = isBarline(modifier) ? i : lastBarlineIdx;
|
|
416
|
+
widths.right = 0;
|
|
417
|
+
widths.left = 0;
|
|
418
|
+
widths.paddingRight = 0;
|
|
419
|
+
widths.paddingLeft = 0;
|
|
420
|
+
const layoutMetrics = modifier.getLayoutMetrics();
|
|
421
|
+
if (layoutMetrics) {
|
|
422
|
+
if (i !== 0) {
|
|
423
|
+
widths.right = (_a = layoutMetrics.xMax) !== null && _a !== void 0 ? _a : 0;
|
|
424
|
+
widths.paddingRight = (_b = layoutMetrics.paddingRight) !== null && _b !== void 0 ? _b : 0;
|
|
425
|
+
}
|
|
426
|
+
widths.left = -((_c = layoutMetrics.xMin) !== null && _c !== void 0 ? _c : 0);
|
|
427
|
+
widths.paddingLeft = (_d = layoutMetrics.paddingLeft) !== null && _d !== void 0 ? _d : 0;
|
|
428
|
+
if (i === endModifiers.length - 1) {
|
|
429
|
+
widths.paddingLeft = 0;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
widths.paddingRight = modifier.getPadding(i - lastBarlineIdx);
|
|
434
|
+
if (i !== 0) {
|
|
435
|
+
widths.right = modifier.getWidth();
|
|
436
|
+
}
|
|
437
|
+
if (i === 0) {
|
|
438
|
+
widths.left = modifier.getWidth();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
x -= widths.paddingRight;
|
|
442
|
+
x -= widths.right;
|
|
443
|
+
modifier.setX(x);
|
|
444
|
+
x -= widths.left;
|
|
445
|
+
x -= widths.paddingLeft;
|
|
446
|
+
}
|
|
447
|
+
this.endX = endModifiers.length === 1 ? this.x + this.width : x;
|
|
448
|
+
this.formatted = true;
|
|
449
|
+
}
|
|
450
|
+
draw() {
|
|
451
|
+
var _a;
|
|
452
|
+
const ctx = this.checkContext();
|
|
453
|
+
this.setRendered();
|
|
454
|
+
const clsAttribute = this.getAttribute('class');
|
|
455
|
+
ctx.openGroup('stave' + (clsAttribute ? ' ' + clsAttribute : ''), this.getAttribute('id'));
|
|
456
|
+
if (!this.formatted)
|
|
457
|
+
this.format();
|
|
458
|
+
const numLines = this.options.numLines;
|
|
459
|
+
const width = this.width;
|
|
460
|
+
const x = this.x;
|
|
461
|
+
let y;
|
|
462
|
+
const lineWidth = (_a = this.getStyle().lineWidth) !== null && _a !== void 0 ? _a : 1;
|
|
463
|
+
const lineWidthCorrection = lineWidth % 2 === 0 ? 0 : 0.5;
|
|
464
|
+
for (let line = 0; line < numLines; line++) {
|
|
465
|
+
y = this.getYForLine(line);
|
|
466
|
+
if (this.options.lineConfig[line].visible) {
|
|
467
|
+
ctx.beginPath();
|
|
468
|
+
ctx.moveTo(x, y + lineWidthCorrection);
|
|
469
|
+
ctx.lineTo(x + width, y + lineWidthCorrection);
|
|
470
|
+
ctx.stroke();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
this.drawPointerRect();
|
|
474
|
+
ctx.closeGroup();
|
|
475
|
+
for (let i = 0; i < this.modifiers.length; i++) {
|
|
476
|
+
const modifier = this.modifiers[i];
|
|
477
|
+
modifier.setContext(ctx);
|
|
478
|
+
modifier.setStave(this);
|
|
479
|
+
modifier.drawWithStyle();
|
|
480
|
+
}
|
|
481
|
+
if (this.measure > 0) {
|
|
482
|
+
ctx.setFont(this.fontInfo);
|
|
483
|
+
const textWidth = ctx.measureText('' + this.measure).width;
|
|
484
|
+
y = this.getYForTopText(0) + 3;
|
|
485
|
+
ctx.fillText('' + this.measure, this.x - textWidth / 2, y);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
getVerticalBarWidth() {
|
|
489
|
+
return this.options.verticalBarWidth;
|
|
490
|
+
}
|
|
491
|
+
getConfigForLines() {
|
|
492
|
+
return this.options.lineConfig;
|
|
493
|
+
}
|
|
494
|
+
setConfigForLine(lineNumber, lineConfig) {
|
|
495
|
+
if (lineNumber >= this.options.numLines || lineNumber < 0) {
|
|
496
|
+
throw new RuntimeError('StaveConfigError', 'The line number must be within the range of the number of lines in the Stave.');
|
|
497
|
+
}
|
|
498
|
+
if (lineConfig.visible === undefined) {
|
|
499
|
+
throw new RuntimeError('StaveConfigError', "The line configuration object is missing the 'visible' property.");
|
|
500
|
+
}
|
|
501
|
+
if (typeof lineConfig.visible !== 'boolean') {
|
|
502
|
+
throw new RuntimeError('StaveConfigError', "The line configuration objects 'visible' property must be true or false.");
|
|
503
|
+
}
|
|
504
|
+
this.options.lineConfig[lineNumber] = lineConfig;
|
|
505
|
+
return this;
|
|
506
|
+
}
|
|
507
|
+
setConfigForLines(linesConfiguration) {
|
|
508
|
+
if (linesConfiguration.length !== this.options.numLines) {
|
|
509
|
+
throw new RuntimeError('StaveConfigError', 'The length of the lines configuration array must match the number of lines in the Stave');
|
|
510
|
+
}
|
|
511
|
+
for (const lineConfig in linesConfiguration) {
|
|
512
|
+
if (linesConfiguration[lineConfig].visible === undefined) {
|
|
513
|
+
linesConfiguration[lineConfig] = this.options.lineConfig[lineConfig];
|
|
514
|
+
}
|
|
515
|
+
this.options.lineConfig[lineConfig] = Object.assign(Object.assign({}, this.options.lineConfig[lineConfig]), linesConfiguration[lineConfig]);
|
|
516
|
+
}
|
|
517
|
+
this.options.lineConfig = linesConfiguration;
|
|
518
|
+
return this;
|
|
519
|
+
}
|
|
520
|
+
static formatBegModifiers(staves) {
|
|
521
|
+
const adjustCategoryStartX = (category) => {
|
|
522
|
+
let minStartX = 0;
|
|
523
|
+
staves.forEach((stave) => {
|
|
524
|
+
const modifiers = stave.getModifiers(StaveModifierPosition.BEGIN, category);
|
|
525
|
+
if (modifiers.length > 0 && modifiers[0].getX() > minStartX)
|
|
526
|
+
minStartX = modifiers[0].getX();
|
|
527
|
+
});
|
|
528
|
+
let adjustX = 0;
|
|
529
|
+
staves.forEach((stave) => {
|
|
530
|
+
adjustX = 0;
|
|
531
|
+
const modifiers = stave.getModifiers(StaveModifierPosition.BEGIN, category);
|
|
532
|
+
modifiers.forEach((modifier) => {
|
|
533
|
+
if (minStartX - modifier.getX() > adjustX)
|
|
534
|
+
adjustX = minStartX - modifier.getX();
|
|
535
|
+
});
|
|
536
|
+
const allModifiers = stave.getModifiers(StaveModifierPosition.BEGIN);
|
|
537
|
+
let bAdjust = false;
|
|
538
|
+
allModifiers.forEach((modifier) => {
|
|
539
|
+
if (modifier.getCategory() === category)
|
|
540
|
+
bAdjust = true;
|
|
541
|
+
if (bAdjust && adjustX > 0)
|
|
542
|
+
modifier.setX(modifier.getX() + adjustX);
|
|
543
|
+
});
|
|
544
|
+
stave.setNoteStartX(stave.getNoteStartX() + adjustX);
|
|
545
|
+
});
|
|
546
|
+
};
|
|
547
|
+
staves.forEach((stave) => {
|
|
548
|
+
if (!stave.formatted)
|
|
549
|
+
stave.format();
|
|
550
|
+
});
|
|
551
|
+
adjustCategoryStartX("Clef");
|
|
552
|
+
adjustCategoryStartX("KeySignature");
|
|
553
|
+
adjustCategoryStartX("TimeSignature");
|
|
554
|
+
let maxX = 0;
|
|
555
|
+
staves.forEach((stave) => {
|
|
556
|
+
if (stave.getNoteStartX() > maxX)
|
|
557
|
+
maxX = stave.getNoteStartX();
|
|
558
|
+
});
|
|
559
|
+
staves.forEach((stave) => {
|
|
560
|
+
stave.setNoteStartX(maxX);
|
|
561
|
+
});
|
|
562
|
+
maxX = 0;
|
|
563
|
+
staves.forEach((stave) => {
|
|
564
|
+
const modifiers = stave.getModifiers(StaveModifierPosition.BEGIN, "Barline");
|
|
565
|
+
modifiers.forEach((modifier) => {
|
|
566
|
+
if (modifier.getType() === BarlineType.REPEAT_BEGIN)
|
|
567
|
+
if (modifier.getX() > maxX)
|
|
568
|
+
maxX = modifier.getX();
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
staves.forEach((stave) => {
|
|
572
|
+
const modifiers = stave.getModifiers(StaveModifierPosition.BEGIN, "Barline");
|
|
573
|
+
modifiers.forEach((modifier) => {
|
|
574
|
+
if (modifier.getType() === BarlineType.REPEAT_BEGIN)
|
|
575
|
+
modifier.setX(maxX);
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
}
|