vexflow 5.0.0-alpha.3 → 5.0.0-beta.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 +6 -6
- 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 +2066 -1877
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +1052 -993
- 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/accidental.js +22 -28
- package/build/esm/src/annotation.js +0 -2
- package/build/esm/src/barnote.js +3 -3
- package/build/esm/src/beam.js +26 -46
- package/build/esm/src/bend.js +11 -3
- package/build/esm/src/chordsymbol.js +0 -4
- package/build/esm/src/clef.js +0 -2
- package/build/esm/src/clefnote.js +6 -1
- package/build/esm/src/curve.js +8 -5
- package/build/esm/src/element.js +94 -118
- package/build/esm/src/factory.js +4 -4
- package/build/esm/src/flag.js +20 -0
- package/build/esm/src/fonts/gonville.js +1 -1
- package/build/esm/src/formatter.js +13 -21
- package/build/esm/src/fraction.js +15 -22
- package/build/esm/src/glyphnote.js +3 -4
- package/build/esm/src/gracenote.js +0 -2
- package/build/esm/src/gracenotegroup.js +17 -8
- package/build/esm/src/index.js +1 -0
- package/build/esm/src/keysignature.js +38 -31
- package/build/esm/src/keysignote.js +1 -1
- package/build/esm/src/metrics.js +58 -7
- package/build/esm/src/modifier.js +10 -23
- package/build/esm/src/multimeasurerest.js +16 -25
- package/build/esm/src/note.js +7 -0
- package/build/esm/src/notehead.js +6 -1
- package/build/esm/src/ornament.js +0 -2
- package/build/esm/src/pedalmarking.js +33 -41
- package/build/esm/src/registry.js +5 -19
- package/build/esm/src/stave.js +11 -19
- package/build/esm/src/stavebarline.js +2 -3
- package/build/esm/src/stavehairpin.js +1 -1
- package/build/esm/src/staveline.js +0 -4
- package/build/esm/src/stavemodifier.js +0 -2
- package/build/esm/src/stavenote.js +42 -68
- package/build/esm/src/staverepetition.js +3 -2
- package/build/esm/src/stavesection.js +13 -15
- package/build/esm/src/stavetempo.js +7 -13
- package/build/esm/src/stavetext.js +2 -2
- package/build/esm/src/stavetie.js +82 -40
- package/build/esm/src/stavevolta.js +3 -2
- package/build/esm/src/stem.js +0 -4
- package/build/esm/src/stemmablenote.js +5 -6
- package/build/esm/src/stringnumber.js +0 -2
- package/build/esm/src/svgcontext.js +5 -13
- package/build/esm/src/tabnote.js +2 -8
- package/build/esm/src/textbracket.js +0 -3
- package/build/esm/src/textnote.js +0 -2
- package/build/esm/src/tickable.js +13 -26
- package/build/esm/src/tickcontext.js +20 -2
- package/build/esm/src/timesignature.js +2 -4
- package/build/esm/src/timesignote.js +2 -0
- package/build/esm/src/tuplet.js +37 -30
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vexflow.js +6 -2
- package/build/esm/src/vibrato.js +6 -1
- package/build/esm/tests/accidental_tests.js +30 -17
- package/build/esm/tests/annotation_tests.js +12 -12
- package/build/esm/tests/articulation_tests.js +13 -13
- package/build/esm/tests/auto_beam_formatting_tests.js +33 -33
- package/build/esm/tests/beam_tests.js +1 -1
- package/build/esm/tests/bend_tests.js +7 -7
- package/build/esm/tests/chordsymbol_tests.js +8 -8
- package/build/esm/tests/clef_tests.js +5 -1
- package/build/esm/tests/curve_tests.js +34 -0
- package/build/esm/tests/{bach_tests.js → demo_petzold_tests.js} +7 -7
- package/build/esm/tests/dot_tests.js +4 -4
- package/build/esm/tests/formatter_tests.js +25 -25
- package/build/esm/tests/glyphnote_tests.js +6 -0
- package/build/esm/tests/gracenote_tests.js +2 -1
- package/build/esm/tests/gracetabnote_tests.js +1 -1
- package/build/esm/tests/index.js +1 -1
- package/build/esm/tests/key_clef_tests.js +6 -6
- package/build/esm/tests/keysignature_tests.js +20 -17
- package/build/esm/tests/notehead_tests.js +10 -7
- package/build/esm/tests/offscreencanvas_tests.js +1 -1
- package/build/esm/tests/ornament_tests.js +8 -8
- package/build/esm/tests/pedalmarking_tests.js +27 -0
- package/build/esm/tests/percussion_tests.js +6 -3
- package/build/esm/tests/renderer_tests.js +1 -1
- package/build/esm/tests/rests_tests.js +26 -26
- package/build/esm/tests/rhythm_tests.js +15 -15
- package/build/esm/tests/stave_tests.js +44 -43
- package/build/esm/tests/staveconnector_tests.js +73 -73
- package/build/esm/tests/stavehairpin_tests.js +1 -1
- package/build/esm/tests/stavemodifier_tests.js +3 -3
- package/build/esm/tests/stavenote_tests.js +29 -29
- package/build/esm/tests/stavetie_tests.js +29 -0
- package/build/esm/tests/stringnumber_tests.js +1 -1
- package/build/esm/tests/strokes_tests.js +1 -1
- package/build/esm/tests/style_tests.js +1 -1
- package/build/esm/tests/tabnote_tests.js +7 -7
- package/build/esm/tests/tabslide_tests.js +6 -6
- package/build/esm/tests/tabstave_tests.js +2 -1
- package/build/esm/tests/tabtie_tests.js +8 -8
- package/build/esm/tests/textnote_tests.js +1 -1
- package/build/esm/tests/threevoice_tests.js +2 -2
- package/build/esm/tests/timesignature_tests.js +23 -13
- package/build/esm/tests/vexflow_test_helpers.js +25 -39
- package/build/esm/tests/vibrato_tests.js +3 -3
- package/build/esm/tests/voice_tests.js +1 -1
- package/build/types/src/accidental.d.ts +19 -1
- package/build/types/src/annotation.d.ts +1 -1
- package/build/types/src/beam.d.ts +12 -1
- package/build/types/src/bend.d.ts +6 -0
- package/build/types/src/clefnote.d.ts +2 -0
- package/build/types/src/curve.d.ts +5 -4
- package/build/types/src/element.d.ts +23 -14
- package/build/types/src/factory.d.ts +2 -2
- package/build/types/src/flag.d.ts +12 -0
- package/build/types/src/fonts/gonville.d.ts +1 -1
- package/build/types/src/formatter.d.ts +5 -3
- package/build/types/src/fraction.d.ts +12 -7
- package/build/types/src/frethandfinger.d.ts +1 -1
- package/build/types/src/index.d.ts +1 -0
- package/build/types/src/keysignature.d.ts +7 -7
- package/build/types/src/metrics.d.ts +5 -0
- package/build/types/src/modifier.d.ts +3 -2
- package/build/types/src/multimeasurerest.d.ts +4 -1
- package/build/types/src/note.d.ts +2 -0
- package/build/types/src/pedalmarking.d.ts +2 -2
- package/build/types/src/registry.d.ts +1 -1
- package/build/types/src/stave.d.ts +1 -3
- package/build/types/src/stavebarline.d.ts +1 -1
- package/build/types/src/staveline.d.ts +1 -1
- package/build/types/src/stavemodifier.d.ts +0 -1
- package/build/types/src/stavenote.d.ts +2 -1
- package/build/types/src/staverepetition.d.ts +1 -1
- package/build/types/src/stavesection.d.ts +3 -4
- package/build/types/src/stavetempo.d.ts +4 -5
- package/build/types/src/stavetext.d.ts +1 -2
- package/build/types/src/stavetie.d.ts +39 -2
- package/build/types/src/stavevolta.d.ts +1 -2
- package/build/types/src/stemmablenote.d.ts +2 -3
- package/build/types/src/svgcontext.d.ts +1 -1
- package/build/types/src/tickable.d.ts +2 -1
- package/build/types/src/tickcontext.d.ts +30 -0
- package/build/types/src/tuplet.d.ts +2 -12
- package/build/types/src/typeguard.d.ts +1 -0
- package/package.json +33 -29
- package/tests/flow.html +2 -2
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var _a, _Accidental_checkCollision;
|
|
7
1
|
import { Fraction } from './fraction.js';
|
|
8
2
|
import { Metrics } from './metrics.js';
|
|
9
3
|
import { Modifier } from './modifier.js';
|
|
@@ -99,7 +93,7 @@ export class Accidental extends Modifier {
|
|
|
99
93
|
const groupStart = i;
|
|
100
94
|
let groupEnd = i;
|
|
101
95
|
while (groupEnd + 1 < staveLineAccidentalLayoutMetrics.length && !noFurtherConflicts) {
|
|
102
|
-
if (
|
|
96
|
+
if (this.checkCollision(staveLineAccidentalLayoutMetrics[groupEnd], staveLineAccidentalLayoutMetrics[groupEnd + 1])) {
|
|
103
97
|
groupEnd++;
|
|
104
98
|
}
|
|
105
99
|
else {
|
|
@@ -112,9 +106,9 @@ export class Accidental extends Modifier {
|
|
|
112
106
|
const [a, b] = getGroupLines([indexA, indexB]).map((item) => item.line);
|
|
113
107
|
return a - b;
|
|
114
108
|
};
|
|
115
|
-
const notColliding = (...indexPairs) => indexPairs.map(getGroupLines).every(([line1, line2]) => !
|
|
109
|
+
const notColliding = (...indexPairs) => indexPairs.map(getGroupLines).every(([line1, line2]) => !this.checkCollision(line1, line2));
|
|
116
110
|
const groupLength = groupEnd - groupStart + 1;
|
|
117
|
-
let endCase =
|
|
111
|
+
let endCase = this.checkCollision(staveLineAccidentalLayoutMetrics[groupStart], staveLineAccidentalLayoutMetrics[groupEnd])
|
|
118
112
|
? 'a'
|
|
119
113
|
: 'b';
|
|
120
114
|
switch (groupLength) {
|
|
@@ -155,7 +149,7 @@ export class Accidental extends Modifier {
|
|
|
155
149
|
while (collisionDetected === true) {
|
|
156
150
|
collisionDetected = false;
|
|
157
151
|
for (let line = 0; line + patternLength < staveLineAccidentalLayoutMetrics.length; line++) {
|
|
158
|
-
if (
|
|
152
|
+
if (this.checkCollision(staveLineAccidentalLayoutMetrics[line], staveLineAccidentalLayoutMetrics[line + patternLength])) {
|
|
159
153
|
collisionDetected = true;
|
|
160
154
|
patternLength++;
|
|
161
155
|
break;
|
|
@@ -206,6 +200,23 @@ export class Accidental extends Modifier {
|
|
|
206
200
|
});
|
|
207
201
|
state.leftShift = totalShift + additionalPadding;
|
|
208
202
|
}
|
|
203
|
+
static checkCollision(line1, line2) {
|
|
204
|
+
let clearance = line2.line - line1.line;
|
|
205
|
+
let clearanceRequired = 3;
|
|
206
|
+
if (clearance > 0) {
|
|
207
|
+
clearanceRequired = line2.flatLine || line2.dblSharpLine ? 2.5 : 3.0;
|
|
208
|
+
if (line1.dblSharpLine)
|
|
209
|
+
clearance -= 0.5;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
clearanceRequired = line1.flatLine || line1.dblSharpLine ? 2.5 : 3.0;
|
|
213
|
+
if (line2.dblSharpLine)
|
|
214
|
+
clearance -= 0.5;
|
|
215
|
+
}
|
|
216
|
+
const collision = Math.abs(clearance) < clearanceRequired;
|
|
217
|
+
L('Line1, Line2, Collision: ', line1.line, line2.line, collision);
|
|
218
|
+
return collision;
|
|
219
|
+
}
|
|
209
220
|
static applyAccidentals(voices, keySignature) {
|
|
210
221
|
const tickPositions = [];
|
|
211
222
|
const tickNoteMap = {};
|
|
@@ -255,7 +266,7 @@ export class Accidental extends Modifier {
|
|
|
255
266
|
});
|
|
256
267
|
if (!sameAccidental || (sameAccidental && previouslyModified)) {
|
|
257
268
|
scaleMap[key.root + octave] = pitch;
|
|
258
|
-
const accidental = new
|
|
269
|
+
const accidental = new Accidental(accidentalString);
|
|
259
270
|
staveNote.addModifier(accidental, keyIndex);
|
|
260
271
|
modifiedPitches.push(keyString);
|
|
261
272
|
}
|
|
@@ -316,21 +327,4 @@ export class Accidental extends Modifier {
|
|
|
316
327
|
this.renderText(ctx, 0, 0);
|
|
317
328
|
}
|
|
318
329
|
}
|
|
319
|
-
_a = Accidental, _Accidental_checkCollision = function _Accidental_checkCollision(line1, line2) {
|
|
320
|
-
let clearance = line2.line - line1.line;
|
|
321
|
-
let clearanceRequired = 3;
|
|
322
|
-
if (clearance > 0) {
|
|
323
|
-
clearanceRequired = line2.flatLine || line2.dblSharpLine ? 2.5 : 3.0;
|
|
324
|
-
if (line1.dblSharpLine)
|
|
325
|
-
clearance -= 0.5;
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
clearanceRequired = line1.flatLine || line1.dblSharpLine ? 2.5 : 3.0;
|
|
329
|
-
if (line2.dblSharpLine)
|
|
330
|
-
clearance -= 0.5;
|
|
331
|
-
}
|
|
332
|
-
const collision = Math.abs(clearance) < clearanceRequired;
|
|
333
|
-
L('Line1, Line2, Collision: ', line1.line, line2.line, collision);
|
|
334
|
-
return collision;
|
|
335
|
-
};
|
|
336
330
|
Accidental.DEBUG = false;
|
|
@@ -153,7 +153,6 @@ export class Annotation extends Modifier {
|
|
|
153
153
|
const stemDirection = note.hasStem() ? note.getStemDirection() : Stem.UP;
|
|
154
154
|
const start = note.getModifierStartXY(ModifierPosition.ABOVE, this.index);
|
|
155
155
|
this.setRendered();
|
|
156
|
-
this.applyStyle();
|
|
157
156
|
ctx.openGroup('annotation', this.getAttribute('id'));
|
|
158
157
|
const textWidth = this.getWidth();
|
|
159
158
|
const textHeight = Font.convertSizeToPixelValue(this.fontInfo.size);
|
|
@@ -209,7 +208,6 @@ export class Annotation extends Modifier {
|
|
|
209
208
|
this.y = y;
|
|
210
209
|
this.renderText(ctx, 0, 0);
|
|
211
210
|
ctx.closeGroup();
|
|
212
|
-
this.restoreStyle();
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
Annotation.DEBUG = false;
|
package/build/esm/src/barnote.js
CHANGED
|
@@ -45,11 +45,11 @@ export class BarNote extends Note {
|
|
|
45
45
|
draw() {
|
|
46
46
|
const ctx = this.checkContext();
|
|
47
47
|
L('Rendering bar line at: ', this.getAbsoluteX());
|
|
48
|
-
this.applyStyle(ctx);
|
|
49
48
|
const barline = new Barline(this.type);
|
|
50
49
|
barline.setX(this.getAbsoluteX());
|
|
51
|
-
barline.
|
|
52
|
-
|
|
50
|
+
barline.setStave(this.checkStave());
|
|
51
|
+
barline.setContext(ctx);
|
|
52
|
+
barline.drawWithStyle();
|
|
53
53
|
this.setRendered();
|
|
54
54
|
}
|
|
55
55
|
}
|
package/build/esm/src/beam.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
-
};
|
|
12
|
-
var _Beam_stemDirection, _Beam_ticks, _Beam_yShift, _Beam_breakOnIndexes, _Beam_beamCount, _Beam_unbeamable, _Beam_forcedPartialDirections;
|
|
13
1
|
import { Element } from './element.js';
|
|
14
2
|
import { Fraction } from './fraction.js';
|
|
15
3
|
import { Stem } from './stem.js';
|
|
@@ -45,7 +33,7 @@ export class Beam extends Element {
|
|
|
45
33
|
return "Beam";
|
|
46
34
|
}
|
|
47
35
|
getStemDirection() {
|
|
48
|
-
return
|
|
36
|
+
return this._stemDirection;
|
|
49
37
|
}
|
|
50
38
|
static getDefaultBeamGroups(timeSig) {
|
|
51
39
|
if (!timeSig || timeSig === 'c') {
|
|
@@ -289,27 +277,22 @@ export class Beam extends Element {
|
|
|
289
277
|
constructor(notes, autoStem = false) {
|
|
290
278
|
super();
|
|
291
279
|
this.slope = 0;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
_Beam_yShift.set(this, 0);
|
|
295
|
-
_Beam_breakOnIndexes.set(this, void 0);
|
|
296
|
-
_Beam_beamCount.set(this, void 0);
|
|
297
|
-
_Beam_unbeamable.set(this, void 0);
|
|
298
|
-
_Beam_forcedPartialDirections.set(this, {});
|
|
280
|
+
this.yShift = 0;
|
|
281
|
+
this.forcedPartialDirections = {};
|
|
299
282
|
if (!notes || notes.length === 0) {
|
|
300
283
|
throw new RuntimeError('BadArguments', 'No notes provided for beam.');
|
|
301
284
|
}
|
|
302
285
|
if (notes.length === 1) {
|
|
303
286
|
throw new RuntimeError('BadArguments', 'Too few notes for beam.');
|
|
304
287
|
}
|
|
305
|
-
|
|
306
|
-
if (
|
|
288
|
+
this._ticks = notes[0].getIntrinsicTicks();
|
|
289
|
+
if (this._ticks >= Tables.durationToTicks('4')) {
|
|
307
290
|
throw new RuntimeError('BadArguments', 'Beams can only be applied to notes shorter than a quarter note.');
|
|
308
291
|
}
|
|
309
292
|
let i;
|
|
310
293
|
let note;
|
|
311
|
-
|
|
312
|
-
let stemDirection =
|
|
294
|
+
this._stemDirection = notes[0].getStemDirection();
|
|
295
|
+
let stemDirection = this._stemDirection;
|
|
313
296
|
if (autoStem && isStaveNote(notes[0])) {
|
|
314
297
|
stemDirection = calculateStemDirection(notes);
|
|
315
298
|
}
|
|
@@ -321,14 +304,14 @@ export class Beam extends Element {
|
|
|
321
304
|
note = notes[i];
|
|
322
305
|
if (autoStem) {
|
|
323
306
|
note.setStemDirection(stemDirection);
|
|
324
|
-
|
|
307
|
+
this._stemDirection = stemDirection;
|
|
325
308
|
}
|
|
326
309
|
note.setBeam(this);
|
|
327
310
|
}
|
|
328
311
|
this.postFormatted = false;
|
|
329
312
|
this.notes = notes;
|
|
330
|
-
|
|
331
|
-
|
|
313
|
+
this._beamCount = this.getBeamCount();
|
|
314
|
+
this.breakOnIndexes = [];
|
|
332
315
|
this.renderOptions = {
|
|
333
316
|
beamWidth: 5,
|
|
334
317
|
maxSlope: 0.25,
|
|
@@ -351,15 +334,15 @@ export class Beam extends Element {
|
|
|
351
334
|
return maxBeamCount;
|
|
352
335
|
}
|
|
353
336
|
breakSecondaryAt(indexes) {
|
|
354
|
-
|
|
337
|
+
this.breakOnIndexes = indexes;
|
|
355
338
|
return this;
|
|
356
339
|
}
|
|
357
340
|
setPartialBeamSideAt(noteIndex, side) {
|
|
358
|
-
|
|
341
|
+
this.forcedPartialDirections[noteIndex] = side;
|
|
359
342
|
return this;
|
|
360
343
|
}
|
|
361
344
|
unsetPartialBeamSideAt(noteIndex) {
|
|
362
|
-
delete
|
|
345
|
+
delete this.forcedPartialDirections[noteIndex];
|
|
363
346
|
return this;
|
|
364
347
|
}
|
|
365
348
|
getSlopeY(x, firstX, firstY, slope) {
|
|
@@ -367,7 +350,7 @@ export class Beam extends Element {
|
|
|
367
350
|
}
|
|
368
351
|
calculateSlope() {
|
|
369
352
|
const { notes, renderOptions: { maxSlope, minSlope, slopeIterations, slopeCost }, } = this;
|
|
370
|
-
const stemDirection =
|
|
353
|
+
const stemDirection = this._stemDirection;
|
|
371
354
|
const firstNote = notes[0];
|
|
372
355
|
const initialSlope = getStemSlope(firstNote, notes[notes.length - 1]);
|
|
373
356
|
const increment = (maxSlope - minSlope) / slopeIterations;
|
|
@@ -402,11 +385,11 @@ export class Beam extends Element {
|
|
|
402
385
|
}
|
|
403
386
|
}
|
|
404
387
|
this.slope = bestSlope;
|
|
405
|
-
|
|
388
|
+
this.yShift = yShift;
|
|
406
389
|
}
|
|
407
390
|
calculateFlatSlope() {
|
|
408
391
|
const { notes, renderOptions: { beamWidth, minFlatBeamOffset, flatBeamOffset }, } = this;
|
|
409
|
-
const stemDirection =
|
|
392
|
+
const stemDirection = this._stemDirection;
|
|
410
393
|
let total = 0;
|
|
411
394
|
let extremeY = 0;
|
|
412
395
|
let extremeBeamCount = 0;
|
|
@@ -445,7 +428,7 @@ export class Beam extends Element {
|
|
|
445
428
|
this.renderOptions.flatBeamOffset = offset;
|
|
446
429
|
}
|
|
447
430
|
this.slope = 0;
|
|
448
|
-
|
|
431
|
+
this.yShift = 0;
|
|
449
432
|
}
|
|
450
433
|
getBeamYToDraw() {
|
|
451
434
|
const firstNote = this.notes[0];
|
|
@@ -458,8 +441,8 @@ export class Beam extends Element {
|
|
|
458
441
|
}
|
|
459
442
|
applyStemExtensions() {
|
|
460
443
|
const { notes, slope, renderOptions: { showStemlets, stemletExtension, beamWidth }, } = this;
|
|
461
|
-
const yShift =
|
|
462
|
-
const beamCount =
|
|
444
|
+
const yShift = this.yShift;
|
|
445
|
+
const beamCount = this._beamCount;
|
|
463
446
|
const firstNote = notes[0];
|
|
464
447
|
const firstStemTipY = this.getBeamYToDraw();
|
|
465
448
|
const firstStemX = firstNote.getStemX();
|
|
@@ -473,7 +456,7 @@ export class Beam extends Element {
|
|
|
473
456
|
const preBeamExtension = stem.getExtension();
|
|
474
457
|
const beamExtension = note.getStemDirection() === Stem.UP ? stemTipY - beamedStemTipY : beamedStemTipY - stemTipY;
|
|
475
458
|
let crossStemExtension = 0;
|
|
476
|
-
if (note.getStemDirection() !==
|
|
459
|
+
if (note.getStemDirection() !== this._stemDirection) {
|
|
477
460
|
const beamCount = note.getGlyphProps().beamCount;
|
|
478
461
|
crossStemExtension = (1 + (beamCount - 1) * 1.5) * this.renderOptions.beamWidth;
|
|
479
462
|
}
|
|
@@ -490,7 +473,7 @@ export class Beam extends Element {
|
|
|
490
473
|
if (duration === '4') {
|
|
491
474
|
return BEAM_LEFT;
|
|
492
475
|
}
|
|
493
|
-
const forcedBeamDirection =
|
|
476
|
+
const forcedBeamDirection = this.forcedPartialDirections[noteIndex];
|
|
494
477
|
if (forcedBeamDirection)
|
|
495
478
|
return forcedBeamDirection;
|
|
496
479
|
const lookupDuration = `${Tables.durationToNumber(duration) / 2}`;
|
|
@@ -522,7 +505,7 @@ export class Beam extends Element {
|
|
|
522
505
|
tickTally += ticks;
|
|
523
506
|
let shouldBreak = false;
|
|
524
507
|
if (parseInt(duration, 10) >= 8) {
|
|
525
|
-
shouldBreak =
|
|
508
|
+
shouldBreak = this.breakOnIndexes.indexOf(i) !== -1;
|
|
526
509
|
if (this.renderOptions.secondaryBreakTicks && tickTally >= this.renderOptions.secondaryBreakTicks) {
|
|
527
510
|
tickTally = 0;
|
|
528
511
|
shouldBreak = true;
|
|
@@ -593,7 +576,7 @@ export class Beam extends Element {
|
|
|
593
576
|
if (stem) {
|
|
594
577
|
const stemX = note.getStemX();
|
|
595
578
|
stem.setNoteHeadXBounds(stemX, stemX);
|
|
596
|
-
stem.setContext(ctx).
|
|
579
|
+
stem.setContext(ctx).drawWithStyle();
|
|
597
580
|
}
|
|
598
581
|
}, this);
|
|
599
582
|
}
|
|
@@ -602,7 +585,7 @@ export class Beam extends Element {
|
|
|
602
585
|
const firstNote = this.notes[0];
|
|
603
586
|
let beamY = this.getBeamYToDraw();
|
|
604
587
|
const firstStemX = firstNote.getStemX();
|
|
605
|
-
const beamThickness = this.renderOptions.beamWidth *
|
|
588
|
+
const beamThickness = this.renderOptions.beamWidth * this._stemDirection;
|
|
606
589
|
for (let i = 0; i < validBeamDurations.length; ++i) {
|
|
607
590
|
const duration = validBeamDurations[i];
|
|
608
591
|
const beamLines = this.getBeamLines(duration);
|
|
@@ -646,17 +629,14 @@ export class Beam extends Element {
|
|
|
646
629
|
draw() {
|
|
647
630
|
const ctx = this.checkContext();
|
|
648
631
|
this.setRendered();
|
|
649
|
-
if (
|
|
632
|
+
if (this.unbeamable)
|
|
650
633
|
return;
|
|
651
634
|
if (!this.postFormatted) {
|
|
652
635
|
this.postFormat();
|
|
653
636
|
}
|
|
654
|
-
this.drawStems(ctx);
|
|
655
|
-
this.applyStyle();
|
|
656
637
|
ctx.openGroup('beam', this.getAttribute('id'));
|
|
638
|
+
this.drawStems(ctx);
|
|
657
639
|
this.drawBeamLines(ctx);
|
|
658
640
|
ctx.closeGroup();
|
|
659
|
-
this.restoreStyle();
|
|
660
641
|
}
|
|
661
642
|
}
|
|
662
|
-
_Beam_stemDirection = new WeakMap(), _Beam_ticks = new WeakMap(), _Beam_yShift = new WeakMap(), _Beam_breakOnIndexes = new WeakMap(), _Beam_beamCount = new WeakMap(), _Beam_unbeamable = new WeakMap(), _Beam_forcedPartialDirections = new WeakMap();
|
package/build/esm/src/bend.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Element } from './element.js';
|
|
2
|
+
import { Metrics } from './metrics.js';
|
|
2
3
|
import { Modifier } from './modifier.js';
|
|
3
4
|
import { isTabNote } from './typeguard.js';
|
|
4
5
|
import { RuntimeError } from './util.js';
|
|
@@ -33,15 +34,22 @@ export class Bend extends Modifier {
|
|
|
33
34
|
state.topTextLine += 1;
|
|
34
35
|
return true;
|
|
35
36
|
}
|
|
37
|
+
setStyleLine(style) {
|
|
38
|
+
this.styleLine = style;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
getStyleLine() {
|
|
42
|
+
return this.styleLine;
|
|
43
|
+
}
|
|
36
44
|
constructor(phrase) {
|
|
37
45
|
super();
|
|
46
|
+
this.styleLine = Metrics.getStyle('Bend.line');
|
|
38
47
|
this.xShift = 0;
|
|
39
48
|
this.tap = '';
|
|
40
49
|
this.renderOptions = {
|
|
41
50
|
bendWidth: 8,
|
|
42
51
|
releaseWidth: 8,
|
|
43
52
|
};
|
|
44
|
-
this.setStyle({ lineWidth: 1.0, strokeStyle: 'black', fillStyle: 'black' });
|
|
45
53
|
this.phrase = phrase;
|
|
46
54
|
this.updateWidth();
|
|
47
55
|
}
|
|
@@ -86,7 +94,6 @@ export class Bend extends Modifier {
|
|
|
86
94
|
const ctx = this.checkContext();
|
|
87
95
|
const note = this.checkAttachedNote();
|
|
88
96
|
this.setRendered();
|
|
89
|
-
this.applyStyle();
|
|
90
97
|
const start = note.getModifierStartXY(Modifier.Position.RIGHT, this.index);
|
|
91
98
|
start.x += 3;
|
|
92
99
|
start.y += 0.5;
|
|
@@ -99,12 +106,14 @@ export class Bend extends Modifier {
|
|
|
99
106
|
const renderBend = (x, y, width, height) => {
|
|
100
107
|
const cpX = x + width;
|
|
101
108
|
const cpY = y;
|
|
109
|
+
this.applyStyle(ctx, this.styleLine);
|
|
102
110
|
ctx.beginPath();
|
|
103
111
|
ctx.moveTo(x, y);
|
|
104
112
|
ctx.quadraticCurveTo(cpX, cpY, x + width, height);
|
|
105
113
|
ctx.stroke();
|
|
106
114
|
};
|
|
107
115
|
const renderRelease = (x, y, width, height) => {
|
|
116
|
+
this.applyStyle(ctx, this.styleLine);
|
|
108
117
|
ctx.beginPath();
|
|
109
118
|
ctx.moveTo(x, height);
|
|
110
119
|
ctx.quadraticCurveTo(x + width, height, x + width, y);
|
|
@@ -173,6 +182,5 @@ export class Bend extends Modifier {
|
|
|
173
182
|
else if (lastBend.type === Bend.DOWN) {
|
|
174
183
|
renderArrowHead(lastBend.x + lastDrawnWidth, start.y, -1);
|
|
175
184
|
}
|
|
176
|
-
this.restoreStyle();
|
|
177
185
|
}
|
|
178
186
|
}
|
|
@@ -229,8 +229,6 @@ export class ChordSymbol extends Modifier {
|
|
|
229
229
|
const ctx = this.checkContext();
|
|
230
230
|
const note = this.checkAttachedNote();
|
|
231
231
|
this.setRendered();
|
|
232
|
-
ctx.save();
|
|
233
|
-
this.applyStyle();
|
|
234
232
|
ctx.openGroup('chordsymbol', this.getAttribute('id'));
|
|
235
233
|
const start = note.getModifierStartXY(Modifier.Position.ABOVE, this.index);
|
|
236
234
|
ctx.setFont(this.fontInfo);
|
|
@@ -276,8 +274,6 @@ export class ChordSymbol extends Modifier {
|
|
|
276
274
|
symbol.renderText(ctx, 0, 0);
|
|
277
275
|
});
|
|
278
276
|
ctx.closeGroup();
|
|
279
|
-
this.restoreStyle();
|
|
280
|
-
ctx.restore();
|
|
281
277
|
}
|
|
282
278
|
getBoundingBox() {
|
|
283
279
|
const boundingBox = this.symbolBlocks[0].getBoundingBox();
|
package/build/esm/src/clef.js
CHANGED
|
@@ -109,12 +109,10 @@ export class Clef extends StaveModifier {
|
|
|
109
109
|
const stave = this.checkStave();
|
|
110
110
|
const ctx = stave.checkContext();
|
|
111
111
|
this.setRendered();
|
|
112
|
-
this.applyStyle(ctx);
|
|
113
112
|
ctx.openGroup('clef', this.getAttribute('id'));
|
|
114
113
|
this.y = stave.getYForLine(this.line);
|
|
115
114
|
this.renderText(ctx, 0, 0);
|
|
116
115
|
ctx.closeGroup();
|
|
117
|
-
this.restoreStyle(ctx);
|
|
118
116
|
}
|
|
119
117
|
}
|
|
120
118
|
Clef.DEBUG = false;
|
|
@@ -25,6 +25,11 @@ export class ClefNote extends Note {
|
|
|
25
25
|
const stave = this.checkStave();
|
|
26
26
|
const ctx = this.checkContext();
|
|
27
27
|
this.setRendered();
|
|
28
|
-
this.clef.
|
|
28
|
+
this.clef.setX(this.getAbsoluteX());
|
|
29
|
+
this.clef.setY(stave.getYForLine(this.clef.line));
|
|
30
|
+
this.clef.renderText(ctx, 0, 0);
|
|
31
|
+
}
|
|
32
|
+
getBoundingBox() {
|
|
33
|
+
return this.clef.getBoundingBox();
|
|
29
34
|
}
|
|
30
35
|
}
|
package/build/esm/src/curve.js
CHANGED
|
@@ -23,9 +23,8 @@ export class Curve extends Element {
|
|
|
23
23
|
this.renderOptions = Object.assign({ thickness: 2, xShift: 0, yShift: 10, position: CurvePosition.NEAR_HEAD, positionEnd: CurvePosition.NEAR_HEAD, invert: false, cps: [
|
|
24
24
|
{ x: 0, y: 10 },
|
|
25
25
|
{ x: 0, y: 10 },
|
|
26
|
-
] }, options);
|
|
27
|
-
this.from
|
|
28
|
-
this.to = to;
|
|
26
|
+
], openingDirection: 'auto' }, options);
|
|
27
|
+
this.setNotes(from, to);
|
|
29
28
|
}
|
|
30
29
|
setNotes(from, to) {
|
|
31
30
|
if (!from && !to) {
|
|
@@ -41,7 +40,6 @@ export class Curve extends Element {
|
|
|
41
40
|
renderCurve(params) {
|
|
42
41
|
var _a, _b;
|
|
43
42
|
const ctx = this.checkContext();
|
|
44
|
-
this.applyStyle();
|
|
45
43
|
const xShift = this.renderOptions.xShift;
|
|
46
44
|
const yShift = this.renderOptions.yShift * params.direction;
|
|
47
45
|
const firstX = params.firstX + xShift;
|
|
@@ -62,7 +60,6 @@ export class Curve extends Element {
|
|
|
62
60
|
ctx.closePath();
|
|
63
61
|
if (!((_b = this.style) === null || _b === void 0 ? void 0 : _b.lineDash))
|
|
64
62
|
ctx.fill();
|
|
65
|
-
this.restoreStyle();
|
|
66
63
|
}
|
|
67
64
|
draw() {
|
|
68
65
|
this.checkContext();
|
|
@@ -111,6 +108,12 @@ export class Curve extends Element {
|
|
|
111
108
|
lastX = stave.getTieEndX();
|
|
112
109
|
lastY = firstNote.getStemExtents()[endMetric];
|
|
113
110
|
}
|
|
111
|
+
if (this.renderOptions.openingDirection === 'up') {
|
|
112
|
+
stemDirection = 1;
|
|
113
|
+
}
|
|
114
|
+
if (this.renderOptions.openingDirection === 'down') {
|
|
115
|
+
stemDirection = -1;
|
|
116
|
+
}
|
|
114
117
|
this.renderCurve({
|
|
115
118
|
firstX,
|
|
116
119
|
lastX,
|