vexflow 4.0.2 → 4.0.3
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 +3 -1
- 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 +508 -265
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +232 -127
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow-font-bravura.js +1 -1
- package/build/cjs/vexflow-font-bravura.js.map +1 -1
- package/build/cjs/vexflow-font-gonville.js +1 -1
- package/build/cjs/vexflow-font-gonville.js.map +1 -1
- package/build/cjs/vexflow-font-petaluma.js +1 -1
- package/build/cjs/vexflow-font-petaluma.js.map +1 -1
- package/build/cjs/vexflow-gonville.js +2 -2
- package/build/cjs/vexflow-gonville.js.map +1 -1
- package/build/cjs/vexflow-petaluma.js +2 -2
- package/build/cjs/vexflow-petaluma.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/src/annotation.js +1 -1
- package/build/esm/src/chordsymbol.js +33 -9
- package/build/esm/src/element.js +10 -0
- package/build/esm/src/factory.js +20 -2
- package/build/esm/src/flow.js +6 -0
- package/build/esm/src/fonts/bravura_metrics.js +12 -12
- package/build/esm/src/fonts/gonville_metrics.js +8 -8
- package/build/esm/src/fonts/petaluma_metrics.js +8 -8
- package/build/esm/src/formatter.js +1 -1
- package/build/esm/src/gracenotegroup.js +3 -2
- package/build/esm/src/ornament.js +6 -2
- package/build/esm/src/stavenote.js +34 -9
- package/build/esm/src/stemmablenote.js +1 -0
- package/build/esm/src/stringnumber.js +12 -5
- package/build/esm/src/tables.js +1 -0
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/voice.js +4 -2
- package/build/esm/tests/chordsymbol_tests.js +91 -9
- package/build/esm/tests/ornament_tests.js +98 -94
- package/build/esm/tests/stavenote_tests.js +36 -0
- package/build/esm/tests/stringnumber_tests.js +28 -23
- package/build/types/src/chordsymbol.d.ts +1 -0
- package/build/types/src/element.d.ts +4 -1
- package/build/types/src/factory.d.ts +8 -4
- package/build/types/src/flow.d.ts +2 -0
- package/build/types/src/ornament.d.ts +1 -0
- package/build/types/src/stringnumber.d.ts +3 -1
- package/build/types/src/tables.d.ts +1 -0
- package/build/types/src/voice.d.ts +1 -3
- package/package.json +1 -1
- package/src/annotation.ts +1 -1
- package/src/chordsymbol.ts +35 -10
- package/src/element.ts +13 -1
- package/src/factory.ts +30 -3
- package/src/flow.ts +8 -0
- package/src/fonts/bravura_metrics.ts +12 -12
- package/src/fonts/gonville_metrics.ts +8 -8
- package/src/fonts/petaluma_metrics.ts +8 -8
- package/src/formatter.ts +1 -1
- package/src/gracenotegroup.ts +5 -2
- package/src/ornament.ts +6 -2
- package/src/stavenote.ts +36 -8
- package/src/stemmablenote.ts +1 -0
- package/src/stringnumber.ts +15 -6
- package/src/tables.ts +1 -0
- package/src/voice.ts +2 -3
|
@@ -59,7 +59,7 @@ export class Annotation extends Modifier {
|
|
|
59
59
|
leftWidth = Math.max(leftWidth, textWidth) + Annotation.minAnnotationPadding;
|
|
60
60
|
}
|
|
61
61
|
else if (annotation.horizontalJustification === AnnotationHorizontalJustify.RIGHT) {
|
|
62
|
-
maxRightGlyphWidth = Math.max(glyphWidth,
|
|
62
|
+
maxRightGlyphWidth = Math.max(glyphWidth, maxRightGlyphWidth);
|
|
63
63
|
rightWidth = Math.max(rightWidth, textWidth);
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
@@ -3,6 +3,7 @@ import { Glyph } from './glyph.js';
|
|
|
3
3
|
import { Modifier } from './modifier.js';
|
|
4
4
|
import { Tables } from './tables.js';
|
|
5
5
|
import { TextFormatter } from './textformatter.js';
|
|
6
|
+
import { isStemmableNote } from './typeguard.js';
|
|
6
7
|
import { log } from './util.js';
|
|
7
8
|
function L(...args) {
|
|
8
9
|
if (ChordSymbol.DEBUG)
|
|
@@ -111,17 +112,26 @@ export class ChordSymbol extends Modifier {
|
|
|
111
112
|
static isSubscript(block) {
|
|
112
113
|
return block.symbolModifier !== undefined && block.symbolModifier === SymbolModifiers.SUBSCRIPT;
|
|
113
114
|
}
|
|
115
|
+
static get minPadding() {
|
|
116
|
+
const musicFont = Tables.currentMusicFont();
|
|
117
|
+
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
|
|
118
|
+
}
|
|
114
119
|
static format(symbols, state) {
|
|
115
120
|
var _a;
|
|
116
121
|
if (!symbols || symbols.length === 0)
|
|
117
122
|
return false;
|
|
118
123
|
let width = 0;
|
|
119
124
|
let nonSuperWidth = 0;
|
|
120
|
-
|
|
125
|
+
let leftWidth = 0;
|
|
126
|
+
let rightWidth = 0;
|
|
127
|
+
let maxLeftGlyphWidth = 0;
|
|
128
|
+
let maxRightGlyphWidth = 0;
|
|
121
129
|
for (const symbol of symbols) {
|
|
122
130
|
const fontSize = Font.convertSizeToPointValue((_a = symbol.textFont) === null || _a === void 0 ? void 0 : _a.size);
|
|
123
131
|
const fontAdj = Font.scaleSize(fontSize, 0.05);
|
|
124
132
|
const glyphAdj = fontAdj * 2;
|
|
133
|
+
const note = symbol.checkAttachedNote();
|
|
134
|
+
let symbolWidth = 0;
|
|
125
135
|
let lineSpaces = 1;
|
|
126
136
|
let vAlign = false;
|
|
127
137
|
for (let j = 0; j < symbol.symbolBlocks.length; ++j) {
|
|
@@ -169,6 +179,7 @@ export class ChordSymbol extends Modifier {
|
|
|
169
179
|
}
|
|
170
180
|
block.vAlign = vAlign;
|
|
171
181
|
width += block.width;
|
|
182
|
+
symbolWidth = width;
|
|
172
183
|
}
|
|
173
184
|
symbol.updateKerningAdjustments();
|
|
174
185
|
symbol.updateOverBarAdjustments();
|
|
@@ -180,16 +191,29 @@ export class ChordSymbol extends Modifier {
|
|
|
180
191
|
symbol.setTextLine(state.text_line + 1);
|
|
181
192
|
state.text_line += lineSpaces + 1;
|
|
182
193
|
}
|
|
183
|
-
if (symbol.getReportWidth()) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
194
|
+
if (symbol.getReportWidth() && isStemmableNote(note)) {
|
|
195
|
+
const glyphWidth = note.getGlyph().getWidth();
|
|
196
|
+
if (symbol.getHorizontal() === ChordSymbolHorizontalJustify.LEFT) {
|
|
197
|
+
maxLeftGlyphWidth = Math.max(glyphWidth, maxLeftGlyphWidth);
|
|
198
|
+
leftWidth = Math.max(leftWidth, symbolWidth) + ChordSymbol.minPadding;
|
|
199
|
+
}
|
|
200
|
+
else if (symbol.getHorizontal() === ChordSymbolHorizontalJustify.RIGHT) {
|
|
201
|
+
maxRightGlyphWidth = Math.max(glyphWidth, maxRightGlyphWidth);
|
|
202
|
+
rightWidth = Math.max(rightWidth, symbolWidth);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
leftWidth = Math.max(leftWidth, symbolWidth / 2) + ChordSymbol.minPadding;
|
|
206
|
+
rightWidth = Math.max(rightWidth, symbolWidth / 2);
|
|
207
|
+
maxLeftGlyphWidth = Math.max(glyphWidth / 2, maxLeftGlyphWidth);
|
|
208
|
+
maxRightGlyphWidth = Math.max(glyphWidth / 2, maxRightGlyphWidth);
|
|
209
|
+
}
|
|
188
210
|
}
|
|
211
|
+
width = 0;
|
|
189
212
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
state.
|
|
213
|
+
const rightOverlap = Math.min(Math.max(rightWidth - maxRightGlyphWidth, 0), Math.max(rightWidth - state.right_shift, 0));
|
|
214
|
+
const leftOverlap = Math.min(Math.max(leftWidth - maxLeftGlyphWidth, 0), Math.max(leftWidth - state.left_shift, 0));
|
|
215
|
+
state.left_shift += leftOverlap;
|
|
216
|
+
state.right_shift += rightOverlap;
|
|
193
217
|
return true;
|
|
194
218
|
}
|
|
195
219
|
static get TEXT_FONT() {
|
package/build/esm/src/element.js
CHANGED
|
@@ -4,6 +4,7 @@ import { defined } from './util.js';
|
|
|
4
4
|
export class Element {
|
|
5
5
|
constructor() {
|
|
6
6
|
var _a;
|
|
7
|
+
this.children = [];
|
|
7
8
|
this.attrs = {
|
|
8
9
|
id: Element.newID(),
|
|
9
10
|
el: undefined,
|
|
@@ -19,6 +20,10 @@ export class Element {
|
|
|
19
20
|
static newID() {
|
|
20
21
|
return `auto${Element.ID++}`;
|
|
21
22
|
}
|
|
23
|
+
addChildElement(child) {
|
|
24
|
+
this.children.push(child);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
22
27
|
getCategory() {
|
|
23
28
|
return this.constructor.CATEGORY;
|
|
24
29
|
}
|
|
@@ -26,6 +31,11 @@ export class Element {
|
|
|
26
31
|
this.style = style;
|
|
27
32
|
return this;
|
|
28
33
|
}
|
|
34
|
+
setGroupStyle(style) {
|
|
35
|
+
this.style = style;
|
|
36
|
+
this.children.forEach((child) => child.setGroupStyle(style));
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
29
39
|
getStyle() {
|
|
30
40
|
return this.style;
|
|
31
41
|
}
|
package/build/esm/src/factory.js
CHANGED
|
@@ -18,6 +18,7 @@ import { KeySigNote } from './keysignote.js';
|
|
|
18
18
|
import { ModifierContext } from './modifiercontext.js';
|
|
19
19
|
import { MultiMeasureRest } from './multimeasurerest.js';
|
|
20
20
|
import { NoteSubGroup } from './notesubgroup.js';
|
|
21
|
+
import { Ornament } from './ornament.js';
|
|
21
22
|
import { PedalMarking } from './pedalmarking.js';
|
|
22
23
|
import { Renderer } from './renderer.js';
|
|
23
24
|
import { RepeatNote } from './repeatnote.js';
|
|
@@ -265,6 +266,22 @@ export class Factory {
|
|
|
265
266
|
articulation.setContext(this.context);
|
|
266
267
|
return articulation;
|
|
267
268
|
}
|
|
269
|
+
Ornament(type, params) {
|
|
270
|
+
const options = Object.assign({ type, position: 0, accidental: '' }, params);
|
|
271
|
+
const ornament = new Ornament(type);
|
|
272
|
+
ornament.setPosition(options.position);
|
|
273
|
+
if (options.upperAccidental) {
|
|
274
|
+
ornament.setUpperAccidental(options.upperAccidental);
|
|
275
|
+
}
|
|
276
|
+
if (options.lowerAccidental) {
|
|
277
|
+
ornament.setLowerAccidental(options.lowerAccidental);
|
|
278
|
+
}
|
|
279
|
+
if (typeof options.delayed !== 'undefined') {
|
|
280
|
+
ornament.setDelayed(options.delayed);
|
|
281
|
+
}
|
|
282
|
+
ornament.setContext(this.context);
|
|
283
|
+
return ornament;
|
|
284
|
+
}
|
|
268
285
|
TextDynamics(params) {
|
|
269
286
|
const p = Object.assign({ text: 'p', duration: 'q', dots: 0, line: 0 }, params);
|
|
270
287
|
const text = new TextDynamics({
|
|
@@ -286,10 +303,11 @@ export class Factory {
|
|
|
286
303
|
fingering.setContext(this.context);
|
|
287
304
|
return fingering;
|
|
288
305
|
}
|
|
289
|
-
StringNumber(params) {
|
|
306
|
+
StringNumber(params, drawCircle = true) {
|
|
290
307
|
const stringNumber = new StringNumber(params.number);
|
|
291
308
|
stringNumber.setPosition(params.position);
|
|
292
309
|
stringNumber.setContext(this.context);
|
|
310
|
+
stringNumber.setDrawCircle(drawCircle);
|
|
293
311
|
return stringNumber;
|
|
294
312
|
}
|
|
295
313
|
TickContext() {
|
|
@@ -307,7 +325,7 @@ export class Factory {
|
|
|
307
325
|
}
|
|
308
326
|
Voice(params) {
|
|
309
327
|
const p = Object.assign({ time: '4/4' }, params);
|
|
310
|
-
const voice = new Voice(p.time
|
|
328
|
+
const voice = new Voice(p.time);
|
|
311
329
|
this.voices.push(voice);
|
|
312
330
|
return voice;
|
|
313
331
|
}
|
package/build/esm/src/flow.js
CHANGED
|
@@ -112,6 +112,12 @@ export class Flow {
|
|
|
112
112
|
const fonts = Tables.MUSIC_FONT_STACK;
|
|
113
113
|
return fonts.map((font) => font.getName());
|
|
114
114
|
}
|
|
115
|
+
static get SOFTMAX_FACTOR() {
|
|
116
|
+
return Tables.SOFTMAX_FACTOR;
|
|
117
|
+
}
|
|
118
|
+
static set SOFTMAX_FACTOR(factor) {
|
|
119
|
+
Tables.SOFTMAX_FACTOR = factor;
|
|
120
|
+
}
|
|
115
121
|
static get NOTATION_FONT_SCALE() {
|
|
116
122
|
return Tables.NOTATION_FONT_SCALE;
|
|
117
123
|
}
|
|
@@ -424,21 +424,21 @@ export const BravuraMetrics = {
|
|
|
424
424
|
xOffset: -12,
|
|
425
425
|
yOffset: 0,
|
|
426
426
|
stemUpYOffset: 0,
|
|
427
|
-
reportedWidth:
|
|
427
|
+
reportedWidth: 20,
|
|
428
428
|
},
|
|
429
429
|
brassDoitMedium: {
|
|
430
430
|
scale: 1.0,
|
|
431
431
|
xOffset: 16,
|
|
432
432
|
yOffset: 0,
|
|
433
433
|
stemUpYOffset: 0,
|
|
434
|
-
reportedWidth:
|
|
434
|
+
reportedWidth: 22,
|
|
435
435
|
},
|
|
436
436
|
brassFallLipShort: {
|
|
437
437
|
scale: 1.0,
|
|
438
438
|
xOffset: 16,
|
|
439
439
|
yOffset: 0,
|
|
440
440
|
stemUpYOffset: 0,
|
|
441
|
-
reportedWidth:
|
|
441
|
+
reportedWidth: 15,
|
|
442
442
|
},
|
|
443
443
|
brassLiftMedium: {
|
|
444
444
|
scale: 1.0,
|
|
@@ -478,22 +478,22 @@ export const BravuraMetrics = {
|
|
|
478
478
|
brassFlip: {
|
|
479
479
|
scale: 1.0,
|
|
480
480
|
xOffset: 10,
|
|
481
|
-
yOffset:
|
|
482
|
-
stemUpYOffset:
|
|
483
|
-
reportedWidth:
|
|
481
|
+
yOffset: 0,
|
|
482
|
+
stemUpYOffset: 7,
|
|
483
|
+
reportedWidth: 10,
|
|
484
484
|
},
|
|
485
485
|
brassJazzTurn: {
|
|
486
486
|
scale: 1.0,
|
|
487
|
-
xOffset:
|
|
488
|
-
yOffset:
|
|
489
|
-
stemUpYOffset:
|
|
490
|
-
reportedWidth:
|
|
487
|
+
xOffset: 0,
|
|
488
|
+
yOffset: 0,
|
|
489
|
+
stemUpYOffset: 8,
|
|
490
|
+
reportedWidth: 31,
|
|
491
491
|
},
|
|
492
492
|
brassSmear: {
|
|
493
493
|
scale: 1.0,
|
|
494
494
|
xOffset: 10,
|
|
495
|
-
yOffset:
|
|
496
|
-
stemUpYOffset:
|
|
495
|
+
yOffset: 0,
|
|
496
|
+
stemUpYOffset: 8,
|
|
497
497
|
reportedWidth: 5,
|
|
498
498
|
},
|
|
499
499
|
},
|
|
@@ -330,21 +330,21 @@ export const GonvilleMetrics = {
|
|
|
330
330
|
xOffset: -12,
|
|
331
331
|
yOffset: 0,
|
|
332
332
|
stemUpYOffset: 0,
|
|
333
|
-
reportedWidth:
|
|
333
|
+
reportedWidth: 15,
|
|
334
334
|
},
|
|
335
335
|
brassDoitMedium: {
|
|
336
336
|
scale: 1.0,
|
|
337
337
|
xOffset: 16,
|
|
338
338
|
yOffset: 0,
|
|
339
339
|
stemUpYOffset: 0,
|
|
340
|
-
reportedWidth:
|
|
340
|
+
reportedWidth: 22,
|
|
341
341
|
},
|
|
342
342
|
brassFallLipShort: {
|
|
343
343
|
scale: 1.0,
|
|
344
344
|
xOffset: 17,
|
|
345
345
|
yOffset: 0,
|
|
346
346
|
stemUpYOffset: 0,
|
|
347
|
-
reportedWidth:
|
|
347
|
+
reportedWidth: 15,
|
|
348
348
|
},
|
|
349
349
|
brassLiftMedium: {
|
|
350
350
|
scale: 1.0,
|
|
@@ -385,21 +385,21 @@ export const GonvilleMetrics = {
|
|
|
385
385
|
scale: 1.0,
|
|
386
386
|
xOffset: 10,
|
|
387
387
|
yOffset: -4,
|
|
388
|
-
stemUpYOffset:
|
|
388
|
+
stemUpYOffset: 7,
|
|
389
389
|
reportedWidth: 5,
|
|
390
390
|
},
|
|
391
391
|
brassJazzTurn: {
|
|
392
392
|
scale: 1.0,
|
|
393
|
-
xOffset:
|
|
393
|
+
xOffset: 3,
|
|
394
394
|
yOffset: -4,
|
|
395
|
-
stemUpYOffset:
|
|
396
|
-
reportedWidth:
|
|
395
|
+
stemUpYOffset: 10,
|
|
396
|
+
reportedWidth: 28,
|
|
397
397
|
},
|
|
398
398
|
brassSmear: {
|
|
399
399
|
scale: 1.0,
|
|
400
400
|
xOffset: 10,
|
|
401
401
|
yOffset: -4,
|
|
402
|
-
stemUpYOffset:
|
|
402
|
+
stemUpYOffset: 9,
|
|
403
403
|
reportedWidth: 5,
|
|
404
404
|
},
|
|
405
405
|
},
|
|
@@ -453,28 +453,28 @@ export const PetalumaMetrics = {
|
|
|
453
453
|
xOffset: -12,
|
|
454
454
|
yOffset: 0,
|
|
455
455
|
stemUpYOffset: 0,
|
|
456
|
-
reportedWidth:
|
|
456
|
+
reportedWidth: 15,
|
|
457
457
|
},
|
|
458
458
|
brassDoitMedium: {
|
|
459
459
|
scale: 1.0,
|
|
460
460
|
xOffset: 16,
|
|
461
461
|
yOffset: 0,
|
|
462
462
|
stemUpYOffset: 0,
|
|
463
|
-
reportedWidth:
|
|
463
|
+
reportedWidth: 19,
|
|
464
464
|
},
|
|
465
465
|
brassFallLipShort: {
|
|
466
466
|
scale: 1.0,
|
|
467
467
|
xOffset: 16,
|
|
468
468
|
yOffset: 0,
|
|
469
469
|
stemUpYOffset: 0,
|
|
470
|
-
reportedWidth:
|
|
470
|
+
reportedWidth: 19,
|
|
471
471
|
},
|
|
472
472
|
brassLiftMedium: {
|
|
473
473
|
scale: 1.0,
|
|
474
474
|
xOffset: 16,
|
|
475
475
|
yOffset: 5,
|
|
476
476
|
stemUpYOffset: 0,
|
|
477
|
-
reportedWidth:
|
|
477
|
+
reportedWidth: 15,
|
|
478
478
|
},
|
|
479
479
|
brassFallRoughMedium: {
|
|
480
480
|
scale: 1.0,
|
|
@@ -508,21 +508,21 @@ export const PetalumaMetrics = {
|
|
|
508
508
|
scale: 1.0,
|
|
509
509
|
xOffset: 10,
|
|
510
510
|
yOffset: -4,
|
|
511
|
-
stemUpYOffset:
|
|
511
|
+
stemUpYOffset: 7,
|
|
512
512
|
reportedWidth: 5,
|
|
513
513
|
},
|
|
514
514
|
brassJazzTurn: {
|
|
515
515
|
scale: 1.0,
|
|
516
516
|
xOffset: 6,
|
|
517
517
|
yOffset: -4,
|
|
518
|
-
stemUpYOffset:
|
|
519
|
-
reportedWidth:
|
|
518
|
+
stemUpYOffset: 5,
|
|
519
|
+
reportedWidth: 30,
|
|
520
520
|
},
|
|
521
521
|
brassSmear: {
|
|
522
522
|
scale: 1.0,
|
|
523
523
|
xOffset: 10,
|
|
524
524
|
yOffset: -4,
|
|
525
|
-
stemUpYOffset:
|
|
525
|
+
stemUpYOffset: 5,
|
|
526
526
|
reportedWidth: 5,
|
|
527
527
|
},
|
|
528
528
|
},
|
|
@@ -58,7 +58,7 @@ function getRestLineForNextNoteGroup(notes, currRestLine, currNoteIndex, compare
|
|
|
58
58
|
}
|
|
59
59
|
export class Formatter {
|
|
60
60
|
constructor(options) {
|
|
61
|
-
this.formatterOptions = Object.assign({ globalSoftmax: false, softmaxFactor:
|
|
61
|
+
this.formatterOptions = Object.assign({ globalSoftmax: false, softmaxFactor: Tables.SOFTMAX_FACTOR, maxIterations: 5 }, options);
|
|
62
62
|
this.justifyWidth = 0;
|
|
63
63
|
this.totalCost = 0;
|
|
64
64
|
this.totalShift = 0;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Beam } from './beam.js';
|
|
2
2
|
import { Formatter } from './formatter.js';
|
|
3
3
|
import { Modifier } from './modifier.js';
|
|
4
|
+
import { StaveNote } from './stavenote.js';
|
|
4
5
|
import { StaveTie } from './stavetie.js';
|
|
5
6
|
import { Tables } from './tables.js';
|
|
6
7
|
import { TabTie } from './tabtie.js';
|
|
@@ -67,7 +68,7 @@ export class GraceNoteGroup extends Modifier {
|
|
|
67
68
|
for (let i = 0; i < group_list.length; ++i) {
|
|
68
69
|
const gracenote_group = group_list[i].gracenote_group;
|
|
69
70
|
formatWidth = gracenote_group.getWidth() + group_list[i].spacing;
|
|
70
|
-
gracenote_group.setSpacingFromNextModifier(group_shift - Math.min(formatWidth, group_shift));
|
|
71
|
+
gracenote_group.setSpacingFromNextModifier(group_shift - Math.min(formatWidth, group_shift) + StaveNote.minNoteheadPadding);
|
|
71
72
|
}
|
|
72
73
|
state.left_shift += group_shift;
|
|
73
74
|
return true;
|
|
@@ -97,7 +98,7 @@ export class GraceNoteGroup extends Modifier {
|
|
|
97
98
|
return this;
|
|
98
99
|
}
|
|
99
100
|
getWidth() {
|
|
100
|
-
return this.width;
|
|
101
|
+
return this.width + StaveNote.minNoteheadPadding;
|
|
101
102
|
}
|
|
102
103
|
getGraceNotes() {
|
|
103
104
|
return this.grace_notes;
|
|
@@ -43,6 +43,10 @@ export class Ornament extends Modifier {
|
|
|
43
43
|
static get CATEGORY() {
|
|
44
44
|
return "Ornament";
|
|
45
45
|
}
|
|
46
|
+
static get minPadding() {
|
|
47
|
+
const musicFont = Tables.currentMusicFont();
|
|
48
|
+
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
|
|
49
|
+
}
|
|
46
50
|
static format(ornaments, state) {
|
|
47
51
|
if (!ornaments || ornaments.length === 0)
|
|
48
52
|
return false;
|
|
@@ -62,8 +66,8 @@ export class Ornament extends Modifier {
|
|
|
62
66
|
if (ornament.reportedWidth && ornament.x_shift < 0) {
|
|
63
67
|
left_shift += ornament.reportedWidth;
|
|
64
68
|
}
|
|
65
|
-
else if (ornament.reportedWidth && ornament.x_shift
|
|
66
|
-
right_shift += ornament.reportedWidth;
|
|
69
|
+
else if (ornament.reportedWidth && ornament.x_shift >= 0) {
|
|
70
|
+
right_shift += ornament.reportedWidth + Ornament.minPadding;
|
|
67
71
|
}
|
|
68
72
|
else {
|
|
69
73
|
width = Math.max(ornament.getWidth(), width);
|
|
@@ -104,10 +104,38 @@ export class StaveNote extends StemmableNote {
|
|
|
104
104
|
note: notes[i],
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
let noteU =
|
|
109
|
-
|
|
110
|
-
let noteL =
|
|
107
|
+
let voices = 0;
|
|
108
|
+
let noteU = undefined;
|
|
109
|
+
let noteM = undefined;
|
|
110
|
+
let noteL = undefined;
|
|
111
|
+
const draw = [false, false, false];
|
|
112
|
+
for (let i = 0; i < notesList.length; i++) {
|
|
113
|
+
draw[i] = notesList[i].note.render_options.draw == false ? false : true;
|
|
114
|
+
}
|
|
115
|
+
if (draw[0] && draw[1] && draw[2]) {
|
|
116
|
+
voices = 3;
|
|
117
|
+
noteU = notesList[0];
|
|
118
|
+
noteM = notesList[1];
|
|
119
|
+
noteL = notesList[2];
|
|
120
|
+
}
|
|
121
|
+
else if (draw[0] && draw[1]) {
|
|
122
|
+
voices = 2;
|
|
123
|
+
noteU = notesList[0];
|
|
124
|
+
noteL = notesList[1];
|
|
125
|
+
}
|
|
126
|
+
else if (draw[0] && draw[2]) {
|
|
127
|
+
voices = 2;
|
|
128
|
+
noteU = notesList[0];
|
|
129
|
+
noteL = notesList[2];
|
|
130
|
+
}
|
|
131
|
+
else if (draw[1] && draw[2]) {
|
|
132
|
+
voices = 2;
|
|
133
|
+
noteU = notesList[1];
|
|
134
|
+
noteL = notesList[2];
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
111
139
|
if (voices === 2 && noteU.stemDirection === -1 && noteL.stemDirection === 1) {
|
|
112
140
|
noteU = notesList[1];
|
|
113
141
|
noteL = notesList[0];
|
|
@@ -340,6 +368,7 @@ export class StaveNote extends StemmableNote {
|
|
|
340
368
|
stem_down_x_offset: noteProps.stem_down_x_offset,
|
|
341
369
|
line: noteProps.line,
|
|
342
370
|
});
|
|
371
|
+
this.addChildElement(notehead);
|
|
343
372
|
this._noteHeads[i] = notehead;
|
|
344
373
|
}
|
|
345
374
|
}
|
|
@@ -564,11 +593,7 @@ export class StaveNote extends StemmableNote {
|
|
|
564
593
|
};
|
|
565
594
|
}
|
|
566
595
|
setStyle(style) {
|
|
567
|
-
super.
|
|
568
|
-
this._noteHeads.forEach((notehead) => notehead.setStyle(style));
|
|
569
|
-
if (this.stem)
|
|
570
|
-
this.stem.setStyle(style);
|
|
571
|
-
return this;
|
|
596
|
+
return super.setGroupStyle(style);
|
|
572
597
|
}
|
|
573
598
|
setStemStyle(style) {
|
|
574
599
|
const stem = this.getStem();
|
|
@@ -9,7 +9,6 @@ export class StringNumber extends Modifier {
|
|
|
9
9
|
constructor(number) {
|
|
10
10
|
super();
|
|
11
11
|
this.string_number = number;
|
|
12
|
-
this.setWidth(20);
|
|
13
12
|
this.position = Modifier.Position.ABOVE;
|
|
14
13
|
this.x_shift = 0;
|
|
15
14
|
this.y_shift = 0;
|
|
@@ -20,6 +19,8 @@ export class StringNumber extends Modifier {
|
|
|
20
19
|
this.dashed = true;
|
|
21
20
|
this.leg = Renderer.LineEndType.NONE;
|
|
22
21
|
this.radius = 8;
|
|
22
|
+
this.drawCircle = true;
|
|
23
|
+
this.setWidth(this.radius * 2 + 4);
|
|
23
24
|
this.resetFont();
|
|
24
25
|
}
|
|
25
26
|
static get CATEGORY() {
|
|
@@ -141,6 +142,10 @@ export class StringNumber extends Modifier {
|
|
|
141
142
|
this.dashed = dashed;
|
|
142
143
|
return this;
|
|
143
144
|
}
|
|
145
|
+
setDrawCircle(drawCircle) {
|
|
146
|
+
this.drawCircle = drawCircle;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
144
149
|
draw() {
|
|
145
150
|
const ctx = this.checkContext();
|
|
146
151
|
const note = this.checkAttachedNote();
|
|
@@ -184,10 +189,12 @@ export class StringNumber extends Modifier {
|
|
|
184
189
|
throw new RuntimeError('InvalidPosition', `The position ${this.position} is invalid`);
|
|
185
190
|
}
|
|
186
191
|
ctx.save();
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
192
|
+
if (this.drawCircle) {
|
|
193
|
+
ctx.beginPath();
|
|
194
|
+
ctx.arc(dot_x, dot_y, this.radius, 0, Math.PI * 2, false);
|
|
195
|
+
ctx.setLineWidth(1.5);
|
|
196
|
+
ctx.stroke();
|
|
197
|
+
}
|
|
191
198
|
ctx.setFont(this.textFont);
|
|
192
199
|
const x = dot_x - ctx.measureText(this.string_number).width / 2;
|
|
193
200
|
ctx.fillText('' + this.string_number, x, dot_y + 4.5);
|
package/build/esm/src/tables.js
CHANGED
|
@@ -682,6 +682,7 @@ export class Tables {
|
|
|
682
682
|
return Object.assign(Object.assign(Object.assign({}, code.common), { getWidth: getWidth }), glyphTypeProperties);
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
|
+
Tables.SOFTMAX_FACTOR = 100;
|
|
685
686
|
Tables.STEM_WIDTH = 1.5;
|
|
686
687
|
Tables.STEM_HEIGHT = 35;
|
|
687
688
|
Tables.STAVE_LINE_THICKNESS = 1;
|
package/build/esm/src/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const VERSION = '4.0.
|
|
2
|
-
export const ID = '
|
|
3
|
-
export const DATE = '2022-
|
|
1
|
+
export const VERSION = '4.0.3';
|
|
2
|
+
export const ID = '1874642be3f8ba11bf7b39ca94d9a36b32a6e8c0';
|
|
3
|
+
export const DATE = '2022-05-16T23:29:47.258Z';
|
package/build/esm/src/voice.js
CHANGED
|
@@ -9,7 +9,7 @@ export var VoiceMode;
|
|
|
9
9
|
VoiceMode[VoiceMode["FULL"] = 3] = "FULL";
|
|
10
10
|
})(VoiceMode || (VoiceMode = {}));
|
|
11
11
|
export class Voice extends Element {
|
|
12
|
-
constructor(time
|
|
12
|
+
constructor(time) {
|
|
13
13
|
super();
|
|
14
14
|
this.resolutionMultiplier = 1;
|
|
15
15
|
this.mode = VoiceMode.STRICT;
|
|
@@ -17,7 +17,9 @@ export class Voice extends Element {
|
|
|
17
17
|
this.ticksUsed = new Fraction(0, 1);
|
|
18
18
|
this.largestTickWidth = 0;
|
|
19
19
|
this.tickables = [];
|
|
20
|
-
this.options =
|
|
20
|
+
this.options = {
|
|
21
|
+
softmaxFactor: Tables.SOFTMAX_FACTOR,
|
|
22
|
+
};
|
|
21
23
|
let voiceTime;
|
|
22
24
|
if (typeof time === 'string') {
|
|
23
25
|
const match = time.match(/(\d+)\/(\d+)/);
|