vexflow 5.0.0-alpha.3 → 5.0.0-alpha.4
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 +528 -492
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +460 -452
- 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/beam.js +24 -42
- package/build/esm/src/clefnote.js +6 -1
- package/build/esm/src/element.js +83 -101
- package/build/esm/src/fonts/gonville.js +1 -1
- package/build/esm/src/formatter.js +9 -17
- package/build/esm/src/fraction.js +15 -22
- package/build/esm/src/glyphnote.js +3 -2
- package/build/esm/src/metrics.js +3 -0
- package/build/esm/src/modifier.js +6 -21
- package/build/esm/src/multimeasurerest.js +16 -25
- package/build/esm/src/note.js +7 -0
- package/build/esm/src/registry.js +5 -19
- package/build/esm/src/stave.js +4 -6
- package/build/esm/src/stavenote.js +26 -40
- package/build/esm/src/stavetempo.js +4 -11
- package/build/esm/src/stavetie.js +82 -36
- package/build/esm/src/svgcontext.js +5 -12
- package/build/esm/src/tickable.js +13 -26
- package/build/esm/src/tickcontext.js +20 -2
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vibrato.js +6 -1
- package/build/esm/tests/clef_tests.js +5 -1
- package/build/esm/tests/glyphnote_tests.js +6 -0
- package/build/esm/tests/stavetie_tests.js +29 -0
- package/build/esm/tests/tabstave_tests.js +1 -0
- package/build/esm/tests/vexflow_test_helpers.js +25 -39
- 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/clefnote.d.ts +2 -0
- package/build/types/src/element.d.ts +13 -3
- 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/modifier.d.ts +2 -1
- package/build/types/src/multimeasurerest.d.ts +4 -1
- package/build/types/src/note.d.ts +2 -0
- package/build/types/src/registry.d.ts +1 -1
- package/build/types/src/stavenote.d.ts +2 -1
- package/build/types/src/stavetempo.d.ts +3 -3
- package/build/types/src/stavetie.d.ts +39 -2
- 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/package.json +2 -2
- 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, _Fraction_fractionA, _Fraction_fractionB;
|
|
7
1
|
import { RuntimeError } from './util.js';
|
|
8
2
|
export class Fraction {
|
|
9
3
|
static get CATEGORY() {
|
|
@@ -22,7 +16,7 @@ export class Fraction {
|
|
|
22
16
|
return a;
|
|
23
17
|
}
|
|
24
18
|
static LCM(a, b) {
|
|
25
|
-
return (a * b) /
|
|
19
|
+
return (a * b) / Fraction.GCD(a, b);
|
|
26
20
|
}
|
|
27
21
|
static LCMM(args) {
|
|
28
22
|
if (args.length === 0) {
|
|
@@ -32,10 +26,10 @@ export class Fraction {
|
|
|
32
26
|
return args[0];
|
|
33
27
|
}
|
|
34
28
|
else if (args.length === 2) {
|
|
35
|
-
return
|
|
29
|
+
return Fraction.LCM(args[0], args[1]);
|
|
36
30
|
}
|
|
37
31
|
else {
|
|
38
|
-
return
|
|
32
|
+
return Fraction.LCM(args.shift(), Fraction.LCMM(args));
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
35
|
constructor(numerator, denominator) {
|
|
@@ -54,7 +48,7 @@ export class Fraction {
|
|
|
54
48
|
simplify() {
|
|
55
49
|
let u = this.numerator;
|
|
56
50
|
let d = this.denominator;
|
|
57
|
-
const gcd =
|
|
51
|
+
const gcd = Fraction.GCD(u, d);
|
|
58
52
|
u /= gcd;
|
|
59
53
|
d /= gcd;
|
|
60
54
|
if (d < 0) {
|
|
@@ -65,7 +59,7 @@ export class Fraction {
|
|
|
65
59
|
}
|
|
66
60
|
add(param1 = 0, param2 = 1) {
|
|
67
61
|
const [otherNumerator, otherDenominator] = getNumeratorAndDenominator(param1, param2);
|
|
68
|
-
const lcm =
|
|
62
|
+
const lcm = Fraction.LCM(this.denominator, otherDenominator);
|
|
69
63
|
const a = lcm / this.denominator;
|
|
70
64
|
const b = lcm / otherDenominator;
|
|
71
65
|
const u = this.numerator * a + otherNumerator * b;
|
|
@@ -73,7 +67,7 @@ export class Fraction {
|
|
|
73
67
|
}
|
|
74
68
|
subtract(param1 = 0, param2 = 1) {
|
|
75
69
|
const [otherNumerator, otherDenominator] = getNumeratorAndDenominator(param1, param2);
|
|
76
|
-
const lcm =
|
|
70
|
+
const lcm = Fraction.LCM(this.denominator, otherDenominator);
|
|
77
71
|
const a = lcm / this.denominator;
|
|
78
72
|
const b = lcm / otherDenominator;
|
|
79
73
|
const u = this.numerator * a - otherNumerator * b;
|
|
@@ -88,17 +82,17 @@ export class Fraction {
|
|
|
88
82
|
return this.set(this.numerator * otherDenominator, this.denominator * otherNumerator);
|
|
89
83
|
}
|
|
90
84
|
equals(compare) {
|
|
91
|
-
const a =
|
|
92
|
-
const b =
|
|
85
|
+
const a = Fraction.fractionA.copy(compare).simplify();
|
|
86
|
+
const b = Fraction.fractionB.copy(this).simplify();
|
|
93
87
|
return a.numerator === b.numerator && a.denominator === b.denominator;
|
|
94
88
|
}
|
|
95
89
|
greaterThan(compare) {
|
|
96
|
-
const a =
|
|
90
|
+
const a = Fraction.fractionA.copy(this);
|
|
97
91
|
a.subtract(compare);
|
|
98
92
|
return a.numerator > 0;
|
|
99
93
|
}
|
|
100
94
|
greaterThanEquals(compare) {
|
|
101
|
-
const a =
|
|
95
|
+
const a = Fraction.fractionA.copy(this);
|
|
102
96
|
a.subtract(compare);
|
|
103
97
|
return a.numerator >= 0;
|
|
104
98
|
}
|
|
@@ -109,7 +103,7 @@ export class Fraction {
|
|
|
109
103
|
return !this.greaterThan(compare);
|
|
110
104
|
}
|
|
111
105
|
clone() {
|
|
112
|
-
return new
|
|
106
|
+
return new Fraction(this.numerator, this.denominator);
|
|
113
107
|
}
|
|
114
108
|
copy(other) {
|
|
115
109
|
if (typeof other === 'number') {
|
|
@@ -134,12 +128,12 @@ export class Fraction {
|
|
|
134
128
|
return `${this.numerator}/${this.denominator}`;
|
|
135
129
|
}
|
|
136
130
|
toSimplifiedString() {
|
|
137
|
-
return
|
|
131
|
+
return Fraction.fractionA.copy(this).simplify().toString();
|
|
138
132
|
}
|
|
139
133
|
toMixedString() {
|
|
140
134
|
let s = '';
|
|
141
135
|
const q = this.quotient();
|
|
142
|
-
const f =
|
|
136
|
+
const f = Fraction.fractionA.copy(this);
|
|
143
137
|
if (q < 0) {
|
|
144
138
|
f.makeAbs();
|
|
145
139
|
}
|
|
@@ -164,9 +158,8 @@ export class Fraction {
|
|
|
164
158
|
return this.set(n, d);
|
|
165
159
|
}
|
|
166
160
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
_Fraction_fractionB = { value: new _a() };
|
|
161
|
+
Fraction.fractionA = new Fraction();
|
|
162
|
+
Fraction.fractionB = new Fraction();
|
|
170
163
|
function getNumeratorAndDenominator(n, d = 1) {
|
|
171
164
|
if (typeof n === 'number') {
|
|
172
165
|
return [n, d];
|
|
@@ -34,8 +34,9 @@ export class GlyphNote extends Note {
|
|
|
34
34
|
this.setRendered();
|
|
35
35
|
this.applyStyle(ctx);
|
|
36
36
|
ctx.openGroup('glyphNote', this.getAttribute('id'));
|
|
37
|
-
|
|
38
|
-
this.
|
|
37
|
+
this.x = this.isCenterAligned() ? this.getAbsoluteX() - this.getWidth() / 2 : this.getAbsoluteX();
|
|
38
|
+
this.y = stave.getYForLine(this.options.line);
|
|
39
|
+
this.renderText(ctx, 0, 0);
|
|
39
40
|
this.drawModifiers();
|
|
40
41
|
ctx.closeGroup();
|
|
41
42
|
this.restoreStyle(ctx);
|
package/build/esm/src/metrics.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
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");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
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");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _Modifier_spacingFromNextModifier, _Modifier_modifierContext;
|
|
13
1
|
import { Element } from './element.js';
|
|
14
2
|
import { defined, RuntimeError } from './util.js';
|
|
15
3
|
export var ModifierPosition;
|
|
@@ -38,12 +26,10 @@ export class Modifier extends Element {
|
|
|
38
26
|
}
|
|
39
27
|
constructor() {
|
|
40
28
|
super();
|
|
41
|
-
_Modifier_spacingFromNextModifier.set(this, void 0);
|
|
42
|
-
_Modifier_modifierContext.set(this, void 0);
|
|
43
29
|
this.width = 0;
|
|
44
30
|
this.textLine = 0;
|
|
45
31
|
this.position = Modifier.Position.LEFT;
|
|
46
|
-
|
|
32
|
+
this.spacingFromNextModifier = 0;
|
|
47
33
|
}
|
|
48
34
|
reset() {
|
|
49
35
|
}
|
|
@@ -70,13 +56,13 @@ export class Modifier extends Element {
|
|
|
70
56
|
return this;
|
|
71
57
|
}
|
|
72
58
|
getModifierContext() {
|
|
73
|
-
return
|
|
59
|
+
return this.modifierContext;
|
|
74
60
|
}
|
|
75
61
|
checkModifierContext() {
|
|
76
|
-
return defined(
|
|
62
|
+
return defined(this.modifierContext, 'NoModifierContext', 'Modifier Context Required');
|
|
77
63
|
}
|
|
78
64
|
setModifierContext(c) {
|
|
79
|
-
|
|
65
|
+
this.modifierContext = c;
|
|
80
66
|
return this;
|
|
81
67
|
}
|
|
82
68
|
getPosition() {
|
|
@@ -96,10 +82,10 @@ export class Modifier extends Element {
|
|
|
96
82
|
return this;
|
|
97
83
|
}
|
|
98
84
|
setSpacingFromNextModifier(x) {
|
|
99
|
-
|
|
85
|
+
this.spacingFromNextModifier = x;
|
|
100
86
|
}
|
|
101
87
|
getSpacingFromNextModifier() {
|
|
102
|
-
return
|
|
88
|
+
return this.spacingFromNextModifier;
|
|
103
89
|
}
|
|
104
90
|
setXShift(x) {
|
|
105
91
|
this.xShift = 0;
|
|
@@ -131,4 +117,3 @@ export class Modifier extends Element {
|
|
|
131
117
|
});
|
|
132
118
|
}
|
|
133
119
|
}
|
|
134
|
-
_Modifier_spacingFromNextModifier = new WeakMap(), _Modifier_modifierContext = new WeakMap();
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
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");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
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");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _MultiMeasureRest_hasPaddingLeft, _MultiMeasureRest_hasPaddingRight, _MultiMeasureRest_hasLineThickness, _MultiMeasureRest_hasSymbolSpacing;
|
|
13
1
|
import { Element } from './element.js';
|
|
14
2
|
import { Glyphs } from './glyphs.js';
|
|
15
3
|
import { Metrics } from './metrics.js';
|
|
16
4
|
import { StaveModifierPosition } from './stavemodifier.js';
|
|
17
5
|
import { Tables } from './tables.js';
|
|
18
6
|
import { isBarline } from './typeguard.js';
|
|
19
|
-
import { defined } from './util.js';
|
|
7
|
+
import { defined, RuntimeError } from './util.js';
|
|
20
8
|
export class MultiMeasureRest extends Element {
|
|
21
9
|
static get CATEGORY() {
|
|
22
10
|
return "MultiMeasureRest";
|
|
@@ -25,10 +13,10 @@ export class MultiMeasureRest extends Element {
|
|
|
25
13
|
var _a;
|
|
26
14
|
super();
|
|
27
15
|
this.xs = { left: NaN, right: NaN };
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
this.hasPaddingLeft = false;
|
|
17
|
+
this.hasPaddingRight = false;
|
|
18
|
+
this.hasLineThickness = false;
|
|
19
|
+
this.hasSymbolSpacing = false;
|
|
32
20
|
const fontSize = (_a = options.numberGlyphPoint) !== null && _a !== void 0 ? _a : Metrics.get('MultiMeasureRest.fontSize');
|
|
33
21
|
this.fontInfo.size = fontSize;
|
|
34
22
|
this.numberOfMeasures = numberOfMeasures;
|
|
@@ -37,10 +25,10 @@ export class MultiMeasureRest extends Element {
|
|
|
37
25
|
for (const digit of t) {
|
|
38
26
|
this.text += String.fromCodePoint(0xe080 + Number(digit));
|
|
39
27
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
this.hasPaddingLeft = typeof options.paddingLeft === 'number';
|
|
29
|
+
this.hasPaddingRight = typeof options.paddingRight === 'number';
|
|
30
|
+
this.hasLineThickness = typeof options.lineThickness === 'number';
|
|
31
|
+
this.hasSymbolSpacing = typeof options.symbolSpacing === 'number';
|
|
44
32
|
this.renderOptions = Object.assign({ useSymbols: false, showNumber: true, numberLine: -0.5, numberGlyphPoint: fontSize, line: 2, spacingBetweenLinesPx: Tables.STAVE_LINE_DISTANCE, serifThickness: 2, semibreveRestGlyphScale: Metrics.get('fontSize'), paddingLeft: 0, paddingRight: 0, lineThickness: 5, symbolSpacing: 0 }, options);
|
|
45
33
|
}
|
|
46
34
|
getXs() {
|
|
@@ -65,7 +53,11 @@ export class MultiMeasureRest extends Element {
|
|
|
65
53
|
let txt = '\ue4ef';
|
|
66
54
|
const el = new Element();
|
|
67
55
|
el.setText(txt);
|
|
68
|
-
|
|
56
|
+
const elWidth = el.getWidth();
|
|
57
|
+
if (!elWidth) {
|
|
58
|
+
throw new RuntimeError('Cannot drawLine if width is 0');
|
|
59
|
+
}
|
|
60
|
+
for (let i = 1; (i + 2) * elWidth + left <= right; i++) {
|
|
69
61
|
txt += '\ue4f0';
|
|
70
62
|
}
|
|
71
63
|
txt += '\ue4f1';
|
|
@@ -114,10 +106,10 @@ export class MultiMeasureRest extends Element {
|
|
|
114
106
|
left -= begModifiers[0].getWidth();
|
|
115
107
|
}
|
|
116
108
|
const options = this.renderOptions;
|
|
117
|
-
if (
|
|
109
|
+
if (this.hasPaddingLeft) {
|
|
118
110
|
left = stave.getX() + options.paddingLeft;
|
|
119
111
|
}
|
|
120
|
-
if (
|
|
112
|
+
if (this.hasPaddingRight) {
|
|
121
113
|
right = stave.getX() + stave.getWidth() - options.paddingRight;
|
|
122
114
|
}
|
|
123
115
|
this.xs.left = left;
|
|
@@ -133,4 +125,3 @@ export class MultiMeasureRest extends Element {
|
|
|
133
125
|
}
|
|
134
126
|
}
|
|
135
127
|
}
|
|
136
|
-
_MultiMeasureRest_hasPaddingLeft = new WeakMap(), _MultiMeasureRest_hasPaddingRight = new WeakMap(), _MultiMeasureRest_hasLineThickness = new WeakMap(), _MultiMeasureRest_hasSymbolSpacing = new WeakMap();
|
package/build/esm/src/note.js
CHANGED
|
@@ -373,4 +373,11 @@ export class Note extends Tickable {
|
|
|
373
373
|
getKeyProps() {
|
|
374
374
|
return this.keyProps;
|
|
375
375
|
}
|
|
376
|
+
getBoundingBox() {
|
|
377
|
+
const boundingBox = super.getBoundingBox();
|
|
378
|
+
for (let i = 0; i < this.modifiers.length; i++) {
|
|
379
|
+
boundingBox.mergeWith(this.modifiers[i].getBoundingBox());
|
|
380
|
+
}
|
|
381
|
+
return boundingBox;
|
|
382
|
+
}
|
|
376
383
|
}
|
|
@@ -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 _a, _Registry_defaultRegistry;
|
|
13
1
|
import { RuntimeError } from './util.js';
|
|
14
2
|
class Index {
|
|
15
3
|
constructor() {
|
|
@@ -20,13 +8,13 @@ class Index {
|
|
|
20
8
|
}
|
|
21
9
|
export class Registry {
|
|
22
10
|
static getDefaultRegistry() {
|
|
23
|
-
return
|
|
11
|
+
return Registry.defaultRegistry;
|
|
24
12
|
}
|
|
25
13
|
static enableDefaultRegistry(registry) {
|
|
26
|
-
|
|
14
|
+
Registry.defaultRegistry = registry;
|
|
27
15
|
}
|
|
28
16
|
static disableDefaultRegistry() {
|
|
29
|
-
|
|
17
|
+
Registry.defaultRegistry = undefined;
|
|
30
18
|
}
|
|
31
19
|
constructor() {
|
|
32
20
|
this.index = new Index();
|
|
@@ -63,8 +51,8 @@ export class Registry {
|
|
|
63
51
|
return this;
|
|
64
52
|
}
|
|
65
53
|
getElementById(id) {
|
|
66
|
-
var
|
|
67
|
-
return (
|
|
54
|
+
var _a, _b;
|
|
55
|
+
return (_b = (_a = this.index.id) === null || _a === void 0 ? void 0 : _a[id]) === null || _b === void 0 ? void 0 : _b[id];
|
|
68
56
|
}
|
|
69
57
|
getElementsByAttribute(attribute, value) {
|
|
70
58
|
const indexAttr = this.index[attribute];
|
|
@@ -91,5 +79,3 @@ export class Registry {
|
|
|
91
79
|
return this;
|
|
92
80
|
}
|
|
93
81
|
}
|
|
94
|
-
_a = Registry;
|
|
95
|
-
_Registry_defaultRegistry = { value: void 0 };
|
package/build/esm/src/stave.js
CHANGED
|
@@ -425,7 +425,7 @@ export class Stave extends Element {
|
|
|
425
425
|
widths.right = (_a = layoutMetrics.xMax) !== null && _a !== void 0 ? _a : 0;
|
|
426
426
|
widths.paddingRight = (_b = layoutMetrics.paddingRight) !== null && _b !== void 0 ? _b : 0;
|
|
427
427
|
}
|
|
428
|
-
widths.left = (_c =
|
|
428
|
+
widths.left = -((_c = layoutMetrics.xMin) !== null && _c !== void 0 ? _c : 0);
|
|
429
429
|
widths.paddingLeft = (_d = layoutMetrics.paddingLeft) !== null && _d !== void 0 ? _d : 0;
|
|
430
430
|
if (i === endModifiers.length - 1) {
|
|
431
431
|
widths.paddingLeft = 0;
|
|
@@ -473,11 +473,9 @@ export class Stave extends Element {
|
|
|
473
473
|
this.restoreStyle();
|
|
474
474
|
for (let i = 0; i < this.modifiers.length; i++) {
|
|
475
475
|
const modifier = this.modifiers[i];
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
modifier.restoreStyle(ctx);
|
|
480
|
-
}
|
|
476
|
+
modifier.applyStyle(ctx);
|
|
477
|
+
modifier.draw(this, this.getModifierXShift(i));
|
|
478
|
+
modifier.restoreStyle(ctx);
|
|
481
479
|
}
|
|
482
480
|
if (this.measure > 0) {
|
|
483
481
|
ctx.save();
|
|
@@ -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 _StaveNote_noteHeads, _StaveNote_sortedKeyProps;
|
|
13
1
|
import { BoundingBox } from './boundingbox.js';
|
|
14
2
|
import { Glyphs } from './glyphs.js';
|
|
15
3
|
import { Metrics } from './metrics.js';
|
|
@@ -54,7 +42,7 @@ export class StaveNote extends StemmableNote {
|
|
|
54
42
|
return false;
|
|
55
43
|
const notesList = [];
|
|
56
44
|
for (let i = 0; i < notes.length; i++) {
|
|
57
|
-
const props =
|
|
45
|
+
const props = notes[i].sortedKeyProps;
|
|
58
46
|
const line = props[0].keyProps.line;
|
|
59
47
|
let minL = props[props.length - 1].keyProps.line;
|
|
60
48
|
const stemDirection = notes[i].getStemDirection();
|
|
@@ -64,10 +52,10 @@ export class StaveNote extends StemmableNote {
|
|
|
64
52
|
if (notes[i].isRest()) {
|
|
65
53
|
maxL =
|
|
66
54
|
line +
|
|
67
|
-
Math.ceil(
|
|
55
|
+
Math.ceil(notes[i]._noteHeads[0].getTextMetrics().actualBoundingBoxAscent / Tables.STAVE_LINE_DISTANCE);
|
|
68
56
|
minL =
|
|
69
57
|
line -
|
|
70
|
-
Math.ceil(
|
|
58
|
+
Math.ceil(notes[i]._noteHeads[0].getTextMetrics().actualBoundingBoxDescent / Tables.STAVE_LINE_DISTANCE);
|
|
71
59
|
}
|
|
72
60
|
else {
|
|
73
61
|
maxL =
|
|
@@ -140,8 +128,8 @@ export class StaveNote extends StemmableNote {
|
|
|
140
128
|
else {
|
|
141
129
|
const lineDiff = Math.abs(noteU.line - noteL.line);
|
|
142
130
|
if (noteU.note.hasStem() && noteL.note.hasStem()) {
|
|
143
|
-
const noteUHead =
|
|
144
|
-
const noteLHead =
|
|
131
|
+
const noteUHead = noteU.note.sortedKeyProps[0].keyProps.code;
|
|
132
|
+
const noteLHead = noteL.note.sortedKeyProps[noteL.note.sortedKeyProps.length - 1].keyProps.code;
|
|
145
133
|
if (!Tables.UNISON ||
|
|
146
134
|
noteUHead !== noteLHead ||
|
|
147
135
|
noteU.note.getModifiers().filter((item) => item.getCategory() === "Dot" && item.getIndex() === 0)
|
|
@@ -264,8 +252,7 @@ export class StaveNote extends StemmableNote {
|
|
|
264
252
|
super(noteStruct);
|
|
265
253
|
this.minLine = 0;
|
|
266
254
|
this.maxLine = 0;
|
|
267
|
-
|
|
268
|
-
_StaveNote_sortedKeyProps.set(this, []);
|
|
255
|
+
this.sortedKeyProps = [];
|
|
269
256
|
this.ledgerLineStyle = {};
|
|
270
257
|
this.clef = (_a = noteStruct.clef) !== null && _a !== void 0 ? _a : 'treble';
|
|
271
258
|
this.octaveShift = (_b = noteStruct.octaveShift) !== null && _b !== void 0 ? _b : 0;
|
|
@@ -274,7 +261,7 @@ export class StaveNote extends StemmableNote {
|
|
|
274
261
|
this.displaced = false;
|
|
275
262
|
this.dotShiftY = 0;
|
|
276
263
|
this.useDefaultHeadX = false;
|
|
277
|
-
|
|
264
|
+
this._noteHeads = [];
|
|
278
265
|
this.modifiers = [];
|
|
279
266
|
this.renderOptions = Object.assign(Object.assign({}, this.renderOptions), { strokePx: noteStruct.strokePx || StaveNote.LEDGER_LINE_OFFSET });
|
|
280
267
|
this.calculateKeyProps();
|
|
@@ -290,9 +277,9 @@ export class StaveNote extends StemmableNote {
|
|
|
290
277
|
}
|
|
291
278
|
reset() {
|
|
292
279
|
super.reset();
|
|
293
|
-
const noteHeadStyles =
|
|
280
|
+
const noteHeadStyles = this._noteHeads.map((noteHead) => noteHead.getStyle());
|
|
294
281
|
this.buildNoteHeads();
|
|
295
|
-
|
|
282
|
+
this._noteHeads.forEach((noteHead, index) => {
|
|
296
283
|
const noteHeadStyle = noteHeadStyles[index];
|
|
297
284
|
if (noteHeadStyle)
|
|
298
285
|
noteHead.setStyle(noteHeadStyle);
|
|
@@ -317,7 +304,7 @@ export class StaveNote extends StemmableNote {
|
|
|
317
304
|
return this;
|
|
318
305
|
}
|
|
319
306
|
buildNoteHeads() {
|
|
320
|
-
|
|
307
|
+
this._noteHeads = [];
|
|
321
308
|
const stemDirection = this.getStemDirection();
|
|
322
309
|
const keys = this.getKeys();
|
|
323
310
|
let lastLine = undefined;
|
|
@@ -337,7 +324,7 @@ export class StaveNote extends StemmableNote {
|
|
|
337
324
|
step = -1;
|
|
338
325
|
}
|
|
339
326
|
for (let i = start; i !== end; i += step) {
|
|
340
|
-
const noteProps =
|
|
327
|
+
const noteProps = this.sortedKeyProps[i].keyProps;
|
|
341
328
|
const line = noteProps.line;
|
|
342
329
|
if (lastLine === undefined) {
|
|
343
330
|
lastLine = line;
|
|
@@ -363,16 +350,16 @@ export class StaveNote extends StemmableNote {
|
|
|
363
350
|
});
|
|
364
351
|
notehead.fontInfo = this.fontInfo;
|
|
365
352
|
this.addChildElement(notehead);
|
|
366
|
-
|
|
353
|
+
this._noteHeads[this.sortedKeyProps[i].index] = notehead;
|
|
367
354
|
}
|
|
368
|
-
return
|
|
355
|
+
return this._noteHeads;
|
|
369
356
|
}
|
|
370
357
|
autoStem() {
|
|
371
358
|
this.setStemDirection(this.calculateOptimalStemDirection());
|
|
372
359
|
}
|
|
373
360
|
calculateOptimalStemDirection() {
|
|
374
|
-
this.minLine =
|
|
375
|
-
this.maxLine =
|
|
361
|
+
this.minLine = this.sortedKeyProps[0].keyProps.line;
|
|
362
|
+
this.maxLine = this.sortedKeyProps[this.keyProps.length - 1].keyProps.line;
|
|
376
363
|
const MIDDLE_LINE = 3;
|
|
377
364
|
const decider = (this.minLine + this.maxLine) / 2;
|
|
378
365
|
const stemDirection = decider < MIDDLE_LINE ? Stem.UP : Stem.DOWN;
|
|
@@ -413,13 +400,13 @@ export class StaveNote extends StemmableNote {
|
|
|
413
400
|
this.keyProps.push(props);
|
|
414
401
|
}
|
|
415
402
|
this.keyProps.forEach((keyProps, index) => {
|
|
416
|
-
|
|
403
|
+
this.sortedKeyProps.push({ keyProps, index });
|
|
417
404
|
});
|
|
418
|
-
|
|
405
|
+
this.sortedKeyProps.sort((a, b) => a.keyProps.line - b.keyProps.line);
|
|
419
406
|
}
|
|
420
407
|
getBoundingBox() {
|
|
421
408
|
const boundingBox = new BoundingBox(this.getAbsoluteX(), this.ys[0], 0, 0);
|
|
422
|
-
|
|
409
|
+
this._noteHeads.forEach((notehead) => {
|
|
423
410
|
boundingBox.mergeWith(notehead.getBoundingBox());
|
|
424
411
|
});
|
|
425
412
|
const { yTop, yBottom } = this.getNoteHeadBounds();
|
|
@@ -489,7 +476,7 @@ export class StaveNote extends StemmableNote {
|
|
|
489
476
|
}
|
|
490
477
|
setStave(stave) {
|
|
491
478
|
super.setStave(stave);
|
|
492
|
-
const ys =
|
|
479
|
+
const ys = this._noteHeads.map((notehead) => {
|
|
493
480
|
notehead.setStave(stave);
|
|
494
481
|
return notehead.getY();
|
|
495
482
|
});
|
|
@@ -553,7 +540,7 @@ export class StaveNote extends StemmableNote {
|
|
|
553
540
|
x = this.getGlyphWidth() / 2;
|
|
554
541
|
}
|
|
555
542
|
let restShift = 0;
|
|
556
|
-
switch (
|
|
543
|
+
switch (this._noteHeads[index].getText()) {
|
|
557
544
|
case Glyphs.restDoubleWhole:
|
|
558
545
|
case Glyphs.restWhole:
|
|
559
546
|
restShift += 0.5;
|
|
@@ -606,7 +593,7 @@ export class StaveNote extends StemmableNote {
|
|
|
606
593
|
return this.noteHeads[0].getWidth();
|
|
607
594
|
}
|
|
608
595
|
setKeyStyle(index, style) {
|
|
609
|
-
|
|
596
|
+
this._noteHeads[index].setStyle(style);
|
|
610
597
|
return this;
|
|
611
598
|
}
|
|
612
599
|
setKeyLine(index, line) {
|
|
@@ -652,7 +639,7 @@ export class StaveNote extends StemmableNote {
|
|
|
652
639
|
let lowestDisplacedLine;
|
|
653
640
|
let highestNonDisplacedLine = highestLine;
|
|
654
641
|
let lowestNonDisplacedLine = lowestLine;
|
|
655
|
-
|
|
642
|
+
this._noteHeads.forEach((notehead) => {
|
|
656
643
|
const line = notehead.getLine();
|
|
657
644
|
const y = notehead.getY();
|
|
658
645
|
yTop = Math.min(y, yTop);
|
|
@@ -695,7 +682,7 @@ export class StaveNote extends StemmableNote {
|
|
|
695
682
|
return xBegin + this.getGlyphWidth();
|
|
696
683
|
}
|
|
697
684
|
get noteHeads() {
|
|
698
|
-
return
|
|
685
|
+
return this._noteHeads.slice();
|
|
699
686
|
}
|
|
700
687
|
drawLedgerLines() {
|
|
701
688
|
const stave = this.checkStave();
|
|
@@ -745,7 +732,7 @@ export class StaveNote extends StemmableNote {
|
|
|
745
732
|
for (let i = 0; i < this.modifiers.length; i++) {
|
|
746
733
|
const modifier = this.modifiers[i];
|
|
747
734
|
const index = modifier.checkIndex();
|
|
748
|
-
const notehead =
|
|
735
|
+
const notehead = this._noteHeads[index];
|
|
749
736
|
if (notehead === noteheadParam) {
|
|
750
737
|
const noteheadStyle = notehead.getStyle();
|
|
751
738
|
notehead.applyStyle(ctx, noteheadStyle);
|
|
@@ -782,7 +769,7 @@ export class StaveNote extends StemmableNote {
|
|
|
782
769
|
}
|
|
783
770
|
drawNoteHeads() {
|
|
784
771
|
const ctx = this.checkContext();
|
|
785
|
-
|
|
772
|
+
this._noteHeads.forEach((notehead) => {
|
|
786
773
|
notehead.applyStyle(ctx);
|
|
787
774
|
ctx.openGroup('notehead', notehead.getAttribute('id'));
|
|
788
775
|
notehead.setContext(ctx).draw();
|
|
@@ -840,7 +827,7 @@ export class StaveNote extends StemmableNote {
|
|
|
840
827
|
const ctx = this.checkContext();
|
|
841
828
|
const xBegin = this.getNoteHeadBeginX();
|
|
842
829
|
const shouldRenderStem = this.hasStem() && !this.beam;
|
|
843
|
-
|
|
830
|
+
this._noteHeads.forEach((notehead) => notehead.setX(xBegin));
|
|
844
831
|
if (this.stem) {
|
|
845
832
|
const stemX = this.getStemX();
|
|
846
833
|
this.stem.setNoteHeadXBounds(stemX, stemX);
|
|
@@ -860,5 +847,4 @@ export class StaveNote extends StemmableNote {
|
|
|
860
847
|
this.setRendered();
|
|
861
848
|
}
|
|
862
849
|
}
|
|
863
|
-
_StaveNote_noteHeads = new WeakMap(), _StaveNote_sortedKeyProps = new WeakMap();
|
|
864
850
|
StaveNote.DEBUG = false;
|
|
@@ -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 _StaveTempo_durationToCode;
|
|
7
1
|
import { Element } from './element.js';
|
|
8
2
|
import { Glyphs } from './glyphs.js';
|
|
9
3
|
import { Metrics } from './metrics.js';
|
|
@@ -14,7 +8,7 @@ export class StaveTempo extends StaveModifier {
|
|
|
14
8
|
}
|
|
15
9
|
constructor(tempo, x, shiftY) {
|
|
16
10
|
super();
|
|
17
|
-
|
|
11
|
+
this.durationToCode = {
|
|
18
12
|
'1/4': Glyphs.metNoteDoubleWholeSquare,
|
|
19
13
|
long: Glyphs.metNoteDoubleWholeSquare,
|
|
20
14
|
'1/2': Glyphs.metNoteDoubleWhole,
|
|
@@ -44,7 +38,7 @@ export class StaveTempo extends StaveModifier {
|
|
|
44
38
|
'512th': Glyphs.metNote512thUp,
|
|
45
39
|
1024: Glyphs.metNote1024thUp,
|
|
46
40
|
'1024th': Glyphs.metNote1024thUp,
|
|
47
|
-
}
|
|
41
|
+
};
|
|
48
42
|
this.tempo = tempo;
|
|
49
43
|
this.position = StaveModifierPosition.ABOVE;
|
|
50
44
|
this.x = x;
|
|
@@ -75,7 +69,7 @@ export class StaveTempo extends StaveModifier {
|
|
|
75
69
|
x += elText.getWidth() + 3;
|
|
76
70
|
}
|
|
77
71
|
if (duration) {
|
|
78
|
-
el.setText(
|
|
72
|
+
el.setText(this.durationToCode[duration]);
|
|
79
73
|
el.renderText(ctx, x + this.xShift, y + this.yShift);
|
|
80
74
|
x += el.getWidth() + 3;
|
|
81
75
|
if (dots) {
|
|
@@ -89,7 +83,7 @@ export class StaveTempo extends StaveModifier {
|
|
|
89
83
|
elText.renderText(ctx, x + this.xShift, y + this.yShift);
|
|
90
84
|
x += elText.getWidth() + 3;
|
|
91
85
|
if (duration2) {
|
|
92
|
-
el.setText(
|
|
86
|
+
el.setText(this.durationToCode[duration2]);
|
|
93
87
|
el.renderText(ctx, x + this.xShift, y + this.yShift);
|
|
94
88
|
x += el.getWidth() + 3;
|
|
95
89
|
if (dots2) {
|
|
@@ -113,4 +107,3 @@ export class StaveTempo extends StaveModifier {
|
|
|
113
107
|
return this;
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
|
-
_StaveTempo_durationToCode = new WeakMap();
|