vexflow 5.3.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- 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 +4189 -772
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +4323 -906
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/src/alternatingtremolo.js +68 -0
- package/build/esm/src/annotation.js +19 -3
- package/build/esm/src/articulation.js +5 -1
- package/build/esm/src/beam.js +13 -0
- package/build/esm/src/bend.js +57 -6
- package/build/esm/src/clef.js +3 -0
- package/build/esm/src/continuouslayout.js +681 -0
- package/build/esm/src/continuousspan.js +159 -0
- package/build/esm/src/curve.js +21 -2
- package/build/esm/src/easyscore/composition.js +13 -2
- package/build/esm/src/easyscore/policies.js +6 -3
- package/build/esm/src/engravinggeometry.js +8 -1
- package/build/esm/src/factory.js +16 -4
- package/build/esm/src/font.js +9 -1
- package/build/esm/src/fretdiagram.js +77 -0
- package/build/esm/src/guitargesture.js +33 -0
- package/build/esm/src/guitarmodifiers.js +26 -0
- package/build/esm/src/index.js +8 -0
- package/build/esm/src/instrumentprofile.js +123 -0
- package/build/esm/src/keysignature.js +23 -1
- package/build/esm/src/notationspelling.js +73 -0
- package/build/esm/src/note.js +3 -0
- package/build/esm/src/ornament.js +5 -0
- package/build/esm/src/pagebreaks.js +58 -0
- package/build/esm/src/pedalmarking.js +39 -17
- package/build/esm/src/phraselayout.js +503 -0
- package/build/esm/src/phraseribbon.js +28 -0
- package/build/esm/src/publication.js +402 -0
- package/build/esm/src/publicationview.js +114 -0
- package/build/esm/src/scorenavigation.js +172 -0
- package/build/esm/src/sheet.js +14 -2
- package/build/esm/src/stave.js +33 -16
- package/build/esm/src/stavebarline.js +5 -7
- package/build/esm/src/staveconnector.js +1 -0
- package/build/esm/src/stavehairpin.js +53 -27
- package/build/esm/src/stavenote.js +6 -1
- package/build/esm/src/stavetie.js +27 -2
- package/build/esm/src/strokes.js +4 -0
- package/build/esm/src/system.js +19 -4
- package/build/esm/src/systembreaks.js +42 -0
- package/build/esm/src/tabnote.js +6 -1
- package/build/esm/src/textbracket.js +24 -5
- package/build/esm/src/timesignature.js +15 -6
- package/build/esm/src/tuplet.js +1 -0
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vexflow.js +16 -0
- package/build/esm/src/voice.js +7 -3
- package/build/esm/tests/engraving/continuous-studies.mjs +140 -0
- package/build/esm/tests/engraving/instrument-studies.mjs +273 -0
- package/build/esm/tests/engraving/phrase-studies.mjs +63 -0
- package/build/esm/tests/engraving/publication-studies.mjs +87 -0
- package/build/esm/tests/engraving/specialist-studies.mjs +347 -0
- package/build/esm/tests/engraving/studies.mjs +88 -0
- package/build/esm/tests/node/continuous-score-tests.mjs +282 -0
- package/build/esm/tests/node/instrument-profile-tests.mjs +224 -0
- package/build/esm/tests/node/phrase-layout-tests.mjs +281 -0
- package/build/esm/tests/node/publication-tests.mjs +219 -0
- package/build/esm/tools/easyscore-structure.mjs +1 -1
- package/build/esm/tools/explorer/catalog/entries.mjs +2 -1
- package/build/esm/tools/explorer/catalog/expression.mjs +14 -9
- package/build/esm/tools/explorer/catalog/guitar.mjs +238 -0
- package/build/esm/tools/explorer/catalog/layout.mjs +8 -6
- package/build/esm/tools/explorer/catalog/notes.mjs +16 -14
- package/build/esm/tools/explorer/catalog/staves.mjs +12 -6
- package/build/esm/tools/explorer/catalog/strings.mjs +10 -7
- package/build/types/src/alternatingtremolo.d.ts +13 -0
- package/build/types/src/annotation.d.ts +9 -0
- package/build/types/src/articulation.d.ts +3 -0
- package/build/types/src/beam.d.ts +2 -0
- package/build/types/src/bend.d.ts +8 -0
- package/build/types/src/clef.d.ts +3 -0
- package/build/types/src/continuouslayout.d.ts +103 -0
- package/build/types/src/continuousspan.d.ts +60 -0
- package/build/types/src/curve.d.ts +11 -0
- package/build/types/src/easyscore/composition.d.ts +8 -0
- package/build/types/src/easyscore/policies.d.ts +1 -1
- package/build/types/src/fretdiagram.d.ts +23 -0
- package/build/types/src/guitargesture.d.ts +26 -0
- package/build/types/src/guitarmodifiers.d.ts +3 -0
- package/build/types/src/index.d.ts +10 -0
- package/build/types/src/instrumentprofile.d.ts +124 -0
- package/build/types/src/keysignature.d.ts +9 -0
- package/build/types/src/notationspelling.d.ts +25 -0
- package/build/types/src/note.d.ts +15 -0
- package/build/types/src/ornament.d.ts +3 -1
- package/build/types/src/pagebreaks.d.ts +26 -0
- package/build/types/src/pedalmarking.d.ts +9 -0
- package/build/types/src/phraselayout.d.ts +87 -0
- package/build/types/src/phraseribbon.d.ts +7 -0
- package/build/types/src/publication.d.ts +61 -0
- package/build/types/src/publicationview.d.ts +27 -0
- package/build/types/src/scorenavigation.d.ts +33 -0
- package/build/types/src/sheet.d.ts +5 -0
- package/build/types/src/stave.d.ts +13 -0
- package/build/types/src/stavehairpin.d.ts +18 -0
- package/build/types/src/stavetie.d.ts +5 -0
- package/build/types/src/system.d.ts +8 -1
- package/build/types/src/systembreaks.d.ts +9 -0
- package/build/types/src/textbracket.d.ts +7 -0
- package/build/types/src/timesignature.d.ts +4 -0
- package/build/types/src/vexflow.d.ts +16 -0
- package/build/types/src/voice.d.ts +2 -0
- package/changelog/CHANGELOG.md +8 -0
- package/package.json +9 -2
|
@@ -4,11 +4,20 @@ import { Glyphs } from './glyphs.js';
|
|
|
4
4
|
import { Stave } from './stave.js';
|
|
5
5
|
import { StaveModifier, StaveModifierPosition } from './stavemodifier.js';
|
|
6
6
|
import { Tables } from './tables.js';
|
|
7
|
-
import { defined } from './util.js';
|
|
7
|
+
import { defined, RuntimeError } from './util.js';
|
|
8
8
|
export class KeySignature extends StaveModifier {
|
|
9
9
|
static get CATEGORY() {
|
|
10
10
|
return "KeySignature";
|
|
11
11
|
}
|
|
12
|
+
setOrdered(entries) {
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
if (!entry.type || !Number.isSafeInteger(entry.line * 2))
|
|
15
|
+
throw new RuntimeError('BadArguments', 'Expected an accidental and a staff line or space.');
|
|
16
|
+
}
|
|
17
|
+
this.ordered = entries.map((entry) => (Object.assign({}, entry)));
|
|
18
|
+
this.formatted = false;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
12
21
|
constructor(keySpec, cancelKeySpec, alterKeySpec) {
|
|
13
22
|
super();
|
|
14
23
|
this.accList = [];
|
|
@@ -160,6 +169,7 @@ export class KeySignature extends StaveModifier {
|
|
|
160
169
|
}
|
|
161
170
|
setKeySig(keySpec, cancelKeySpec, alterKeySpec) {
|
|
162
171
|
this.formatted = false;
|
|
172
|
+
this.ordered = undefined;
|
|
163
173
|
this.keySpec = keySpec;
|
|
164
174
|
this.cancelKeySpec = cancelKeySpec;
|
|
165
175
|
this.alterKeySpec = alterKeySpec;
|
|
@@ -185,8 +195,15 @@ export class KeySignature extends StaveModifier {
|
|
|
185
195
|
stave = new Stave(0, 0, 100);
|
|
186
196
|
this.setStave(stave);
|
|
187
197
|
}
|
|
198
|
+
this.formattedStaveY = stave.getY();
|
|
188
199
|
this.width = 0;
|
|
189
200
|
this.children = [];
|
|
201
|
+
if (this.ordered) {
|
|
202
|
+
this.ordered.forEach((entry, i, list) => this.convertToGlyph(entry, list[i + 1], stave));
|
|
203
|
+
this.calculateDimensions();
|
|
204
|
+
this.formatted = true;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
190
207
|
this.accList = Tables.keySignature(defined(this.keySpec));
|
|
191
208
|
const accList = this.accList;
|
|
192
209
|
const firstAccidentalType = accList.length > 0 ? accList[0].type : undefined;
|
|
@@ -210,6 +227,11 @@ export class KeySignature extends StaveModifier {
|
|
|
210
227
|
this.calculateDimensions();
|
|
211
228
|
this.formatted = true;
|
|
212
229
|
}
|
|
230
|
+
getInkParts() {
|
|
231
|
+
if (!this.formatted || this.formattedStaveY !== this.checkStave().getY())
|
|
232
|
+
this.format();
|
|
233
|
+
return this.children.map((glyph) => glyph.getTextInk(this.x, 0));
|
|
234
|
+
}
|
|
213
235
|
draw() {
|
|
214
236
|
const stave = this.checkStave();
|
|
215
237
|
const ctx = stave.checkContext();
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Tables } from './tables.js';
|
|
2
|
+
import { RuntimeError } from './util.js';
|
|
3
|
+
export class NotationSpelling {
|
|
4
|
+
static transpose(key, semitones, steps) {
|
|
5
|
+
var _a;
|
|
6
|
+
const parsed = /^([a-g])(bb|##|b|#|n)?\/(-?\d+)$/i.exec(key);
|
|
7
|
+
if (!parsed || !Number.isSafeInteger(semitones) || !Number.isSafeInteger(steps))
|
|
8
|
+
throw new RuntimeError('BadArguments', 'Expected a written pitch and integer transposition.');
|
|
9
|
+
const letters = 'cdefgab', naturals = [0, 2, 4, 5, 7, 9, 11];
|
|
10
|
+
const index = letters.indexOf(parsed[1].toLowerCase()), octave = Number(parsed[3]);
|
|
11
|
+
const target = octave * 7 + index + steps, letter = ((target % 7) + 7) % 7;
|
|
12
|
+
const targetOctave = Math.floor(target / 7);
|
|
13
|
+
const signs = ['bb', 'b', '', '#', '##'];
|
|
14
|
+
const accidental = (_a = parsed[2]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
15
|
+
const alteration = accidental && accidental !== 'n' ? signs.indexOf(accidental) - 2 : 0;
|
|
16
|
+
const delta = octave * 12 + naturals[index] + alteration + semitones - (targetOctave * 12 + naturals[letter]);
|
|
17
|
+
if (!(Math.abs(delta) <= 2))
|
|
18
|
+
throw new RuntimeError('BadArguments', 'Spelling requires more than a double accidental.');
|
|
19
|
+
return letters[letter] + signs[delta + 2] + '/' + targetOctave;
|
|
20
|
+
}
|
|
21
|
+
static transposeKey(key, semitones, steps) {
|
|
22
|
+
Tables.keySignature(key);
|
|
23
|
+
const minor = key.endsWith('m');
|
|
24
|
+
const pitch = this.transpose((minor ? key.slice(0, -1) : key) + '/4', semitones, steps).split('/')[0];
|
|
25
|
+
const result = pitch[0].toUpperCase() + pitch.slice(1) + (minor ? 'm' : '');
|
|
26
|
+
Tables.keySignature(result);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
static rhythm(start, length, cuts = [], rest = false) {
|
|
30
|
+
const end = start + length;
|
|
31
|
+
if (![start, length, end, ...cuts].every(Number.isSafeInteger) || start < 0 || length <= 0)
|
|
32
|
+
throw new RuntimeError('BadArguments', 'Expected integer positions in 64th notes and a positive length.');
|
|
33
|
+
const stops = [...new Set(cuts.filter((n) => n > start && n < end))].sort((a, b) => a - b);
|
|
34
|
+
const segments = [];
|
|
35
|
+
let position = start;
|
|
36
|
+
for (const stop of [...stops, end]) {
|
|
37
|
+
while (position < stop) {
|
|
38
|
+
const remaining = stop - position;
|
|
39
|
+
let unit = 64;
|
|
40
|
+
while (unit > remaining)
|
|
41
|
+
unit /= 2;
|
|
42
|
+
const dotted = unit >= 2 && unit * 1.5 <= remaining;
|
|
43
|
+
const next = position + unit * (dotted ? 1.5 : 1);
|
|
44
|
+
segments.push({
|
|
45
|
+
start: position,
|
|
46
|
+
duration: String(64 / unit),
|
|
47
|
+
dots: dotted ? 1 : 0,
|
|
48
|
+
tieNext: !rest && next < end,
|
|
49
|
+
});
|
|
50
|
+
position = next;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return segments;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class WrittenAccidentalState {
|
|
57
|
+
constructor(signature = {}) {
|
|
58
|
+
this.seen = new Map();
|
|
59
|
+
this.signature = Object.assign({}, signature);
|
|
60
|
+
}
|
|
61
|
+
reset() {
|
|
62
|
+
this.seen.clear();
|
|
63
|
+
}
|
|
64
|
+
sign(key, sign, cautionary = false) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
const pitch = key.toLowerCase();
|
|
67
|
+
if (!/^[a-g]\/-?\d+$/.test(pitch) || !sign)
|
|
68
|
+
throw new RuntimeError('BadArguments', 'Expected a staff pitch and a written accidental.');
|
|
69
|
+
const previous = (_b = (_a = this.seen.get(pitch)) !== null && _a !== void 0 ? _a : this.signature[pitch[0]]) !== null && _b !== void 0 ? _b : 'n';
|
|
70
|
+
this.seen.set(pitch, sign);
|
|
71
|
+
return cautionary || sign !== previous ? sign : undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
package/build/esm/src/note.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Glyphs } from './glyphs.js';
|
|
2
|
+
import { copyBend } from './guitargesture.js';
|
|
2
3
|
import { Metrics } from './metrics.js';
|
|
3
4
|
import { drawDot } from './rendercontext.js';
|
|
4
5
|
import { Tables } from './tables.js';
|
|
@@ -118,10 +119,12 @@ export class Note extends Tickable {
|
|
|
118
119
|
};
|
|
119
120
|
}
|
|
120
121
|
constructor(noteStruct) {
|
|
122
|
+
var _a;
|
|
121
123
|
super();
|
|
122
124
|
if (!noteStruct) {
|
|
123
125
|
throw new RuntimeError('BadArguments', 'Note must have valid initialization data to identify duration and type.');
|
|
124
126
|
}
|
|
127
|
+
this.notation = ((_a = noteStruct.notation) !== null && _a !== void 0 ? _a : []).map((entry) => (Object.assign(Object.assign(Object.assign({}, entry), (entry.stroke && { stroke: Object.assign({}, entry.stroke) })), (entry.bend && { bend: copyBend(entry.bend) }))));
|
|
125
128
|
const parsedNoteStruct = Note.parseNoteStruct(noteStruct);
|
|
126
129
|
if (!parsedNoteStruct) {
|
|
127
130
|
throw new RuntimeError('BadArguments', `Invalid note initialization object: ${JSON.stringify(noteStruct)}`);
|
|
@@ -86,6 +86,7 @@ export class Ornament extends Modifier {
|
|
|
86
86
|
constructor(type) {
|
|
87
87
|
super();
|
|
88
88
|
this.sideOffset = 0;
|
|
89
|
+
this.layoutShiftY = 0;
|
|
89
90
|
this.position = ModifierPosition.ABOVE;
|
|
90
91
|
if (Ornament.ornamentRight.indexOf(type) >= 0) {
|
|
91
92
|
this.position = ModifierPosition.RIGHT;
|
|
@@ -132,6 +133,9 @@ export class Ornament extends Modifier {
|
|
|
132
133
|
this.accidentalLower.setText(Tables.accidentalCodes(accid));
|
|
133
134
|
return this;
|
|
134
135
|
}
|
|
136
|
+
setLayoutShiftY(y) {
|
|
137
|
+
this.layoutShiftY = y;
|
|
138
|
+
}
|
|
135
139
|
positionElements() {
|
|
136
140
|
const note = this.checkAttachedNote();
|
|
137
141
|
const stave = note.checkStave();
|
|
@@ -147,6 +151,7 @@ export class Ornament extends Modifier {
|
|
|
147
151
|
if (this.position === ModifierPosition.BELOW) {
|
|
148
152
|
glyphY = getBottomY(note, this.textLine) + (this.textLine + initialOffset + 1.5) * staffSpace;
|
|
149
153
|
}
|
|
154
|
+
glyphY += this.layoutShiftY;
|
|
150
155
|
if (this.delayed) {
|
|
151
156
|
let delayXShift = 0;
|
|
152
157
|
const startX = note.getTickContext().getX();
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function paginate(systems, rules) {
|
|
2
|
+
const count = systems.length;
|
|
3
|
+
const costs = new Array(count + 1);
|
|
4
|
+
const ends = new Array(count);
|
|
5
|
+
costs[count] = { conflicts: 0, pages: 0, penalty: 0 };
|
|
6
|
+
for (let first = count - 1; first >= 0; first--) {
|
|
7
|
+
const capacity = first === 0 ? rules.firstHeight : rules.laterHeight;
|
|
8
|
+
let used = 0;
|
|
9
|
+
for (let i = first; i < count; i++) {
|
|
10
|
+
const row = systems[i];
|
|
11
|
+
if (i > first && rules.forceBefore.has(row.measures[0]))
|
|
12
|
+
break;
|
|
13
|
+
used += row.height + (i === first ? 0 : rules.gap);
|
|
14
|
+
if (i > first && used > capacity + 1e-7)
|
|
15
|
+
break;
|
|
16
|
+
const after = row.measures[row.measures.length - 1];
|
|
17
|
+
const turn = i + 1 < count;
|
|
18
|
+
const rest = costs[i + 1];
|
|
19
|
+
const conflicts = rest.conflicts + Number(turn && rules.forbidAfter.has(after));
|
|
20
|
+
const pages = rest.pages + 1;
|
|
21
|
+
const difficulty = !turn || rules.preferAfter.has(after) ? 0 : rules.part && !row.restAtEnd ? 4 : 1;
|
|
22
|
+
const unused = Math.max(0, capacity - used) / capacity;
|
|
23
|
+
const penalty = rest.penalty + difficulty + (turn ? unused * unused : 0);
|
|
24
|
+
const best = costs[first];
|
|
25
|
+
if (!best ||
|
|
26
|
+
conflicts < best.conflicts ||
|
|
27
|
+
(conflicts === best.conflicts && (pages < best.pages || (pages === best.pages && penalty <= best.penalty)))) {
|
|
28
|
+
costs[first] = { conflicts, pages, penalty };
|
|
29
|
+
ends[first] = i + 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const pages = [];
|
|
34
|
+
for (let first = 0; first < count; first = ends[first]) {
|
|
35
|
+
const end = ends[first];
|
|
36
|
+
const rows = systems.slice(first, end);
|
|
37
|
+
const capacity = first === 0 ? rules.firstHeight : rules.laterHeight;
|
|
38
|
+
const spare = capacity - rows.reduce((h, r) => h + r.height, 0) - rules.gap * (rows.length - 1);
|
|
39
|
+
const extra = rows.length > 1 && (end < count || rules.justifyLast)
|
|
40
|
+
? Math.min(rules.maxExtraGap, Math.max(0, spare) / (rows.length - 1))
|
|
41
|
+
: 0;
|
|
42
|
+
let y = 0;
|
|
43
|
+
const offsets = rows.map((row) => {
|
|
44
|
+
const start = y;
|
|
45
|
+
y += row.height + rules.gap + extra;
|
|
46
|
+
return start;
|
|
47
|
+
});
|
|
48
|
+
const measures = rows[rows.length - 1].measures;
|
|
49
|
+
pages.push({
|
|
50
|
+
first,
|
|
51
|
+
end,
|
|
52
|
+
offsets,
|
|
53
|
+
overflow: Math.max(0, -spare),
|
|
54
|
+
forbiddenTurn: end < count && rules.forbidAfter.has(measures[measures.length - 1]),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return pages;
|
|
58
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Annotation } from './annotation.js';
|
|
2
|
+
import { BoundingBox } from './boundingbox.js';
|
|
2
3
|
import { Element } from './element.js';
|
|
3
4
|
import { Glyphs } from './glyphs.js';
|
|
4
5
|
import { Metrics } from './metrics.js';
|
|
@@ -58,7 +59,42 @@ export class PedalMarking extends Element {
|
|
|
58
59
|
this.line = line;
|
|
59
60
|
return this;
|
|
60
61
|
}
|
|
62
|
+
getNotes() {
|
|
63
|
+
return this.notes;
|
|
64
|
+
}
|
|
65
|
+
setLayoutBaseline(y) {
|
|
66
|
+
this.layoutBaseline = y;
|
|
67
|
+
}
|
|
68
|
+
releaseX(note) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const notes = note.getVoice().getTickables();
|
|
71
|
+
return (_b = (_a = notes[notes.indexOf(note) + 1]) === null || _a === void 0 ? void 0 : _a.getAbsoluteX()) !== null && _b !== void 0 ? _b : note.checkStave().getX() + note.checkStave().getWidth();
|
|
72
|
+
}
|
|
73
|
+
getBoundingBox() {
|
|
74
|
+
const text = new Element('PedalMarking').setFont(this.fontInfo);
|
|
75
|
+
let box;
|
|
76
|
+
const include = (part) => {
|
|
77
|
+
box = box ? box.mergeWith(part) : part;
|
|
78
|
+
};
|
|
79
|
+
this.notes.forEach((note, i) => {
|
|
80
|
+
const down = i % 2 === 0, x = note.getAbsoluteX(), y = this.getYForStave(note.checkStave());
|
|
81
|
+
const repeated = note === this.notes[i - 1];
|
|
82
|
+
const end = this.releaseX(note);
|
|
83
|
+
if (this.type === PedalMarking.type.TEXT || (this.type === PedalMarking.type.MIXED && down && !repeated)) {
|
|
84
|
+
text.setText(down ? this.depressText : this.releaseText);
|
|
85
|
+
include(text.getTextInk(down ? x : end - text.getWidth(), y));
|
|
86
|
+
}
|
|
87
|
+
if (this.type !== PedalMarking.type.TEXT) {
|
|
88
|
+
const edge = down ? x + (repeated ? 5 : 0) : note === this.notes[i + 1] ? x : end - 5;
|
|
89
|
+
const pad = this.renderOptions.bracketLineWidth / 2, h = this.renderOptions.bracketHeight;
|
|
90
|
+
include(new BoundingBox(edge - pad, y - h - pad, 2 * pad, h + 2 * pad));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return box !== null && box !== void 0 ? box : new BoundingBox(0, 0, 0, 0);
|
|
94
|
+
}
|
|
61
95
|
getYForStave(stave) {
|
|
96
|
+
if (this.layoutBaseline !== undefined)
|
|
97
|
+
return this.layoutBaseline;
|
|
62
98
|
let y = stave.getYForBottomText(this.line + 3);
|
|
63
99
|
const events = this.notes.filter((note) => note.getStave() === stave);
|
|
64
100
|
if (!events.length)
|
|
@@ -97,7 +133,6 @@ export class PedalMarking extends Element {
|
|
|
97
133
|
for (const stave of baselines.keys())
|
|
98
134
|
baselines.set(stave, this.getYForStave(stave));
|
|
99
135
|
this.notes.forEach((note, index, notes) => {
|
|
100
|
-
var _a, _b, _c, _d;
|
|
101
136
|
isPedalDepressed = !isPedalDepressed;
|
|
102
137
|
const x = note.getAbsoluteX();
|
|
103
138
|
const y = baselines.get(note.checkStave());
|
|
@@ -123,13 +158,7 @@ export class PedalMarking extends Element {
|
|
|
123
158
|
}
|
|
124
159
|
}
|
|
125
160
|
else {
|
|
126
|
-
const
|
|
127
|
-
const voiceNotes = note.getVoice().getTickables().length;
|
|
128
|
-
const noteEndX = noteNdx + 1 < voiceNotes
|
|
129
|
-
?
|
|
130
|
-
note.getVoice().getTickables()[noteNdx + 1].getAbsoluteX()
|
|
131
|
-
:
|
|
132
|
-
((_b = (_a = note.getStave()) === null || _a === void 0 ? void 0 : _a.getX()) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = note.getStave()) === null || _c === void 0 ? void 0 : _c.getWidth()) !== null && _d !== void 0 ? _d : 0);
|
|
161
|
+
const noteEndX = this.releaseX(note);
|
|
133
162
|
ctx.beginPath();
|
|
134
163
|
ctx.moveTo(prevX, prevY);
|
|
135
164
|
ctx.lineTo(nextNoteIsSame ? x - 5 : noteEndX - 5, y);
|
|
@@ -149,7 +178,6 @@ export class PedalMarking extends Element {
|
|
|
149
178
|
for (const stave of baselines.keys())
|
|
150
179
|
baselines.set(stave, this.getYForStave(stave));
|
|
151
180
|
this.notes.forEach((note) => {
|
|
152
|
-
var _a, _b, _c, _d;
|
|
153
181
|
isPedalDepressed = !isPedalDepressed;
|
|
154
182
|
const stave = note.checkStave();
|
|
155
183
|
const x = note.getAbsoluteX();
|
|
@@ -159,13 +187,7 @@ export class PedalMarking extends Element {
|
|
|
159
187
|
ctx.fillText(this.depressText, x, y);
|
|
160
188
|
}
|
|
161
189
|
else {
|
|
162
|
-
const
|
|
163
|
-
const voiceNotes = note.getVoice().getTickables().length;
|
|
164
|
-
const noteEndX = noteNdx + 1 < voiceNotes
|
|
165
|
-
?
|
|
166
|
-
note.getVoice().getTickables()[noteNdx + 1].getAbsoluteX()
|
|
167
|
-
:
|
|
168
|
-
((_b = (_a = note.getStave()) === null || _a === void 0 ? void 0 : _a.getX()) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = note.getStave()) === null || _c === void 0 ? void 0 : _c.getWidth()) !== null && _d !== void 0 ? _d : 0);
|
|
190
|
+
const noteEndX = this.releaseX(note);
|
|
169
191
|
textWidth = ctx.measureText(this.releaseText).width;
|
|
170
192
|
ctx.fillText(this.releaseText, noteEndX - textWidth, y);
|
|
171
193
|
}
|
|
@@ -179,7 +201,7 @@ export class PedalMarking extends Element {
|
|
|
179
201
|
ctx.setFillStyle(this.renderOptions.color);
|
|
180
202
|
}
|
|
181
203
|
this.applyStyle(ctx);
|
|
182
|
-
ctx.setFont(this.
|
|
204
|
+
ctx.setFont(this.fontInfo);
|
|
183
205
|
L('Rendering Pedal Marking');
|
|
184
206
|
if (this.type === PedalMarking.type.BRACKET || this.type === PedalMarking.type.MIXED) {
|
|
185
207
|
ctx.setLineWidth(this.renderOptions.bracketLineWidth);
|