vexflow 5.0.0-alpha.2 → 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 -4
- package/tests/flow.html +2 -2
- package/entry/vexflow-bravura.ts +0 -25
- package/entry/vexflow-core.ts +0 -16
- package/entry/vexflow-debug-with-tests.ts +0 -64
- package/entry/vexflow-debug.ts +0 -54
- package/entry/vexflow.ts +0 -47
- package/src/accidental.ts +0 -570
- package/src/annotation.ts +0 -294
- package/src/articulation.ts +0 -383
- package/src/barnote.ts +0 -95
- package/src/beam.ts +0 -999
- package/src/bend.ts +0 -268
- package/src/boundingbox.ts +0 -108
- package/src/canvascontext.ts +0 -348
- package/src/chordsymbol.ts +0 -473
- package/src/clef.ts +0 -164
- package/src/clefnote.ts +0 -50
- package/src/crescendo.ts +0 -132
- package/src/curve.ts +0 -195
- package/src/dot.ts +0 -171
- package/src/easyscore.ts +0 -538
- package/src/element.ts +0 -692
- package/src/factory.ts +0 -694
- package/src/font.ts +0 -343
- package/src/fonts/academico.ts +0 -2
- package/src/fonts/academicobold.ts +0 -2
- package/src/fonts/bravura.ts +0 -2
- package/src/fonts/gonville.ts +0 -2
- package/src/fonts/petaluma.ts +0 -2
- package/src/fonts/petalumascript.ts +0 -2
- package/src/formatter.ts +0 -1107
- package/src/fraction.ts +0 -245
- package/src/frethandfinger.ts +0 -180
- package/src/ghostnote.ts +0 -75
- package/src/glyphnote.ts +0 -68
- package/src/glyphs.ts +0 -5880
- package/src/gracenote.ts +0 -146
- package/src/gracenotegroup.ts +0 -194
- package/src/gracetabnote.ts +0 -30
- package/src/index.ts +0 -90
- package/src/keymanager.ts +0 -153
- package/src/keysignature.ts +0 -272
- package/src/keysignote.ts +0 -46
- package/src/metrics.ts +0 -222
- package/src/modifier.ts +0 -216
- package/src/modifiercontext.ts +0 -177
- package/src/multimeasurerest.ts +0 -229
- package/src/music.ts +0 -443
- package/src/note.ts +0 -690
- package/src/notehead.ts +0 -158
- package/src/notesubgroup.ts +0 -88
- package/src/ornament.ts +0 -301
- package/src/parenthesis.ts +0 -89
- package/src/parser.ts +0 -263
- package/src/pedalmarking.ts +0 -273
- package/src/registry.ts +0 -146
- package/src/rendercontext.ts +0 -98
- package/src/renderer.ts +0 -166
- package/src/repeatnote.ts +0 -25
- package/src/stave.ts +0 -885
- package/src/stavebarline.ts +0 -231
- package/src/staveconnector.ts +0 -281
- package/src/stavehairpin.ts +0 -209
- package/src/staveline.ts +0 -343
- package/src/stavemodifier.ts +0 -93
- package/src/stavenote.ts +0 -1230
- package/src/staverepetition.ts +0 -148
- package/src/stavesection.ts +0 -54
- package/src/stavetempo.ts +0 -162
- package/src/stavetext.ts +0 -69
- package/src/stavetie.ts +0 -235
- package/src/stavevolta.ts +0 -66
- package/src/stem.ts +0 -225
- package/src/stemmablenote.ts +0 -248
- package/src/stringnumber.ts +0 -286
- package/src/strokes.ts +0 -214
- package/src/svgcontext.ts +0 -639
- package/src/system.ts +0 -327
- package/src/tables.ts +0 -796
- package/src/tabnote.ts +0 -449
- package/src/tabslide.ts +0 -115
- package/src/tabstave.ts +0 -31
- package/src/tabtie.ts +0 -44
- package/src/textbracket.ts +0 -231
- package/src/textdynamics.ts +0 -101
- package/src/textnote.ts +0 -175
- package/src/tickable.ts +0 -374
- package/src/tickcontext.ts +0 -280
- package/src/timesignature.ts +0 -229
- package/src/timesignote.ts +0 -45
- package/src/tremolo.ts +0 -51
- package/src/tuning.ts +0 -90
- package/src/tuplet.ts +0 -349
- package/src/typeguard.ts +0 -136
- package/src/util.ts +0 -169
- package/src/version.ts +0 -4
- package/src/vexflow.ts +0 -378
- package/src/vibrato.ts +0 -99
- package/src/vibratobracket.ts +0 -81
- package/src/voice.ts +0 -302
- package/src/web.ts +0 -35
package/src/vexflow.ts
DELETED
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import { Accidental } from './accidental';
|
|
2
|
-
import { Annotation, AnnotationHorizontalJustify, AnnotationVerticalJustify } from './annotation';
|
|
3
|
-
import { Articulation } from './articulation';
|
|
4
|
-
import { BarNote } from './barnote';
|
|
5
|
-
import { Beam } from './beam';
|
|
6
|
-
import { Bend } from './bend';
|
|
7
|
-
import { BoundingBox } from './boundingbox';
|
|
8
|
-
import { CanvasContext } from './canvascontext';
|
|
9
|
-
import { ChordSymbol, ChordSymbolHorizontalJustify, ChordSymbolVerticalJustify, SymbolModifiers } from './chordsymbol';
|
|
10
|
-
import { Clef } from './clef';
|
|
11
|
-
import { ClefNote } from './clefnote';
|
|
12
|
-
import { Crescendo } from './crescendo';
|
|
13
|
-
import { Curve, CurvePosition } from './curve';
|
|
14
|
-
import { Dot } from './dot';
|
|
15
|
-
import { EasyScore } from './easyscore';
|
|
16
|
-
import { Element } from './element';
|
|
17
|
-
import { Factory } from './factory';
|
|
18
|
-
import { Font, FontStyle, FontWeight } from './font';
|
|
19
|
-
import { Formatter } from './formatter';
|
|
20
|
-
import { Fraction } from './fraction';
|
|
21
|
-
import { FretHandFinger } from './frethandfinger';
|
|
22
|
-
import { GhostNote } from './ghostnote';
|
|
23
|
-
import { GlyphNote } from './glyphnote';
|
|
24
|
-
import { Glyphs } from './glyphs';
|
|
25
|
-
import { GraceNote } from './gracenote';
|
|
26
|
-
import { GraceNoteGroup } from './gracenotegroup';
|
|
27
|
-
import { GraceTabNote } from './gracetabnote';
|
|
28
|
-
import { KeyManager } from './keymanager';
|
|
29
|
-
import { KeySignature } from './keysignature';
|
|
30
|
-
import { KeySigNote } from './keysignote';
|
|
31
|
-
import { Metrics, MetricsDefaults } from './metrics';
|
|
32
|
-
import { Modifier, ModifierPosition } from './modifier';
|
|
33
|
-
import { ModifierContext } from './modifiercontext';
|
|
34
|
-
import { MultiMeasureRest } from './multimeasurerest';
|
|
35
|
-
import { Music } from './music';
|
|
36
|
-
import { Note } from './note';
|
|
37
|
-
import { NoteHead } from './notehead';
|
|
38
|
-
import { NoteSubGroup } from './notesubgroup';
|
|
39
|
-
import { Ornament } from './ornament';
|
|
40
|
-
import { Parenthesis } from './parenthesis';
|
|
41
|
-
import { Parser } from './parser';
|
|
42
|
-
import { PedalMarking } from './pedalmarking';
|
|
43
|
-
import { Registry } from './registry';
|
|
44
|
-
import { RenderContext } from './rendercontext';
|
|
45
|
-
import { Renderer, RendererBackends, RendererLineEndType } from './renderer';
|
|
46
|
-
import { RepeatNote } from './repeatnote';
|
|
47
|
-
import { Stave } from './stave';
|
|
48
|
-
import { Barline, BarlineType } from './stavebarline';
|
|
49
|
-
import { StaveConnector } from './staveconnector';
|
|
50
|
-
import { StaveHairpin } from './stavehairpin';
|
|
51
|
-
import { StaveLine } from './staveline';
|
|
52
|
-
import { StaveModifier, StaveModifierPosition } from './stavemodifier';
|
|
53
|
-
import { StaveNote } from './stavenote';
|
|
54
|
-
import { Repetition } from './staverepetition';
|
|
55
|
-
import { StaveTempo } from './stavetempo';
|
|
56
|
-
import { StaveText } from './stavetext';
|
|
57
|
-
import { StaveTie } from './stavetie';
|
|
58
|
-
import { Volta, VoltaType } from './stavevolta';
|
|
59
|
-
import { Stem } from './stem';
|
|
60
|
-
import { StringNumber } from './stringnumber';
|
|
61
|
-
import { Stroke } from './strokes';
|
|
62
|
-
import { SVGContext } from './svgcontext';
|
|
63
|
-
import { System } from './system';
|
|
64
|
-
import { Tables } from './tables';
|
|
65
|
-
import { TabNote } from './tabnote';
|
|
66
|
-
import { TabSlide } from './tabslide';
|
|
67
|
-
import { TabStave } from './tabstave';
|
|
68
|
-
import { TabTie } from './tabtie';
|
|
69
|
-
import { TextBracket, TextBracketPosition } from './textbracket';
|
|
70
|
-
import { TextDynamics } from './textdynamics';
|
|
71
|
-
import { TextJustification, TextNote } from './textnote';
|
|
72
|
-
import { TickContext } from './tickcontext';
|
|
73
|
-
import { TimeSignature } from './timesignature';
|
|
74
|
-
import { TimeSigNote } from './timesignote';
|
|
75
|
-
import { Tremolo } from './tremolo';
|
|
76
|
-
import { Tuning } from './tuning';
|
|
77
|
-
import { Tuplet } from './tuplet';
|
|
78
|
-
import { RuntimeError } from './util';
|
|
79
|
-
import { DATE, ID, VERSION } from './version';
|
|
80
|
-
import { Vibrato } from './vibrato';
|
|
81
|
-
import { VibratoBracket } from './vibratobracket';
|
|
82
|
-
import { Voice, VoiceMode, VoiceTime } from './voice';
|
|
83
|
-
|
|
84
|
-
export class VexFlow {
|
|
85
|
-
// VERSION, ID, and DATE are imported from version.ts.
|
|
86
|
-
// INFO is set by the entry file in vexflow/entry/.
|
|
87
|
-
static BUILD = {
|
|
88
|
-
// version number.
|
|
89
|
-
VERSION: VERSION,
|
|
90
|
-
// git commit ID that this library was built from.
|
|
91
|
-
ID: ID,
|
|
92
|
-
// The date when this library was compiled.
|
|
93
|
-
DATE: DATE,
|
|
94
|
-
// Which build is this? vexflow, vexflow-bravura, vexflow-core, etc.
|
|
95
|
-
INFO: '',
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
static Accidental = Accidental;
|
|
99
|
-
static Annotation = Annotation;
|
|
100
|
-
static Articulation = Articulation;
|
|
101
|
-
static Barline = Barline;
|
|
102
|
-
static BarNote = BarNote;
|
|
103
|
-
static Beam = Beam;
|
|
104
|
-
static Bend = Bend;
|
|
105
|
-
static BoundingBox = BoundingBox;
|
|
106
|
-
static CanvasContext = CanvasContext;
|
|
107
|
-
static ChordSymbol = ChordSymbol;
|
|
108
|
-
static Clef = Clef;
|
|
109
|
-
static ClefNote = ClefNote;
|
|
110
|
-
static Crescendo = Crescendo;
|
|
111
|
-
static Curve = Curve;
|
|
112
|
-
static Dot = Dot;
|
|
113
|
-
static EasyScore = EasyScore;
|
|
114
|
-
static Element = Element;
|
|
115
|
-
static Factory = Factory;
|
|
116
|
-
static Font = Font;
|
|
117
|
-
static Formatter = Formatter;
|
|
118
|
-
static Fraction = Fraction;
|
|
119
|
-
static FretHandFinger = FretHandFinger;
|
|
120
|
-
static GhostNote = GhostNote;
|
|
121
|
-
static GlyphNote = GlyphNote;
|
|
122
|
-
static GraceNote = GraceNote;
|
|
123
|
-
static GraceNoteGroup = GraceNoteGroup;
|
|
124
|
-
static GraceTabNote = GraceTabNote;
|
|
125
|
-
static KeyManager = KeyManager;
|
|
126
|
-
static KeySignature = KeySignature;
|
|
127
|
-
static KeySigNote = KeySigNote;
|
|
128
|
-
static Modifier = Modifier;
|
|
129
|
-
static ModifierContext = ModifierContext;
|
|
130
|
-
static MultiMeasureRest = MultiMeasureRest;
|
|
131
|
-
static Music = Music;
|
|
132
|
-
static Note = Note;
|
|
133
|
-
static NoteHead = NoteHead;
|
|
134
|
-
static NoteSubGroup = NoteSubGroup;
|
|
135
|
-
static Ornament = Ornament;
|
|
136
|
-
static Parenthesis = Parenthesis;
|
|
137
|
-
static Parser = Parser;
|
|
138
|
-
static PedalMarking = PedalMarking;
|
|
139
|
-
static Registry = Registry;
|
|
140
|
-
static RenderContext = RenderContext;
|
|
141
|
-
static Renderer = Renderer;
|
|
142
|
-
static RepeatNote = RepeatNote;
|
|
143
|
-
static Repetition = Repetition;
|
|
144
|
-
static Stave = Stave;
|
|
145
|
-
static StaveConnector = StaveConnector;
|
|
146
|
-
static StaveHairpin = StaveHairpin;
|
|
147
|
-
static StaveLine = StaveLine;
|
|
148
|
-
static StaveModifier = StaveModifier;
|
|
149
|
-
static StaveNote = StaveNote;
|
|
150
|
-
static StaveTempo = StaveTempo;
|
|
151
|
-
static StaveText = StaveText;
|
|
152
|
-
static StaveTie = StaveTie;
|
|
153
|
-
static Stem = Stem;
|
|
154
|
-
static StringNumber = StringNumber;
|
|
155
|
-
static Stroke = Stroke;
|
|
156
|
-
static SVGContext = SVGContext;
|
|
157
|
-
static System = System;
|
|
158
|
-
static TabNote = TabNote;
|
|
159
|
-
static TabSlide = TabSlide;
|
|
160
|
-
static TabStave = TabStave;
|
|
161
|
-
static TabTie = TabTie;
|
|
162
|
-
static TextBracket = TextBracket;
|
|
163
|
-
static TextDynamics = TextDynamics;
|
|
164
|
-
static TextNote = TextNote;
|
|
165
|
-
static TickContext = TickContext;
|
|
166
|
-
static TimeSignature = TimeSignature;
|
|
167
|
-
static TimeSigNote = TimeSigNote;
|
|
168
|
-
static Tremolo = Tremolo;
|
|
169
|
-
static Tuning = Tuning;
|
|
170
|
-
static Tuplet = Tuplet;
|
|
171
|
-
static Vibrato = Vibrato;
|
|
172
|
-
static VibratoBracket = VibratoBracket;
|
|
173
|
-
static Voice = Voice;
|
|
174
|
-
static Volta = Volta;
|
|
175
|
-
|
|
176
|
-
static RuntimeError = RuntimeError;
|
|
177
|
-
|
|
178
|
-
static Test = undefined; // Set by vexflow_test_helpers.ts in the debug version of this library.
|
|
179
|
-
|
|
180
|
-
// Exported Enums.
|
|
181
|
-
// Sorted by the module / file they are exported from.
|
|
182
|
-
static AnnotationHorizontalJustify = AnnotationHorizontalJustify;
|
|
183
|
-
static AnnotationVerticalJustify = AnnotationVerticalJustify;
|
|
184
|
-
static ChordSymbolHorizontalJustify = ChordSymbolHorizontalJustify;
|
|
185
|
-
static ChordSymbolVerticalJustify = ChordSymbolVerticalJustify;
|
|
186
|
-
static SymbolModifiers = SymbolModifiers;
|
|
187
|
-
static CurvePosition = CurvePosition;
|
|
188
|
-
static FontWeight = FontWeight;
|
|
189
|
-
static FontStyle = FontStyle;
|
|
190
|
-
static Glyphs = Glyphs;
|
|
191
|
-
static ModifierPosition = ModifierPosition;
|
|
192
|
-
static RendererBackends = RendererBackends;
|
|
193
|
-
static RendererLineEndType = RendererLineEndType;
|
|
194
|
-
static BarlineType = BarlineType;
|
|
195
|
-
static StaveModifierPosition = StaveModifierPosition;
|
|
196
|
-
static VoltaType = VoltaType;
|
|
197
|
-
static TextBracketPosition = TextBracketPosition;
|
|
198
|
-
static TextJustification = TextJustification;
|
|
199
|
-
static VoiceMode = VoiceMode;
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Load the fonts that are used by your app.
|
|
203
|
-
*
|
|
204
|
-
* Call this if you are using `vexflow-core.js` to take advantage of lazy loading for fonts.
|
|
205
|
-
*
|
|
206
|
-
* If you are using `vexflow.js` or `vexflow-bravura.js`, this method is unnecessary, since
|
|
207
|
-
* they already call loadFonts(...) and setFonts(...) for you.
|
|
208
|
-
*
|
|
209
|
-
* If `fontNames` is undefined, all fonts in Font.FILES will be loaded.
|
|
210
|
-
* This is useful for debugging, but not recommended for production because it will load lots of fonts.
|
|
211
|
-
*
|
|
212
|
-
* For example, on the `flow.html` test page, you could call:
|
|
213
|
-
* `await VexFlow.loadFonts();`
|
|
214
|
-
*
|
|
215
|
-
* Alternatively, you may load web fonts with a stylesheet link (e.g., from Google Fonts),
|
|
216
|
-
* and a @font-face { font-family: ... } rule in your CSS.
|
|
217
|
-
*
|
|
218
|
-
* Customize `Font.HOST_URL` and `Font.FILES` to load different fonts for your app.
|
|
219
|
-
*/
|
|
220
|
-
static async loadFonts(...fontNames: string[]): Promise<void> {
|
|
221
|
-
if (!fontNames) {
|
|
222
|
-
fontNames = Object.keys(Font.FILES);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const fontLoadPromises: Promise<FontFace>[] = [];
|
|
226
|
-
for (const fontName of fontNames) {
|
|
227
|
-
fontLoadPromises.push(Font.load(fontName));
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
await Promise.all(fontLoadPromises);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Call this if you are using `vexflow-core.js` to take advantage of lazy loading for fonts.
|
|
235
|
-
*
|
|
236
|
-
* `vexflow.js` and `vexflow-bravura.js` already call setFonts('Bravura', 'Academico'), so you only
|
|
237
|
-
* need to call this when switching fonts.
|
|
238
|
-
*
|
|
239
|
-
* Example:
|
|
240
|
-
* ```
|
|
241
|
-
* await VexFlow.loadFonts('Bravura', 'Academico', 'Petaluma', 'Petaluma Script');
|
|
242
|
-
* VexFlow.setFonts('Bravura', 'Academico');
|
|
243
|
-
* ... render a score in Bravura ...
|
|
244
|
-
* VexFlow.setFonts('Petaluma', 'Petaluma Script');
|
|
245
|
-
* ... render a score in Petaluma...
|
|
246
|
-
* ```
|
|
247
|
-
* See `demos/fonts/` for more examples.
|
|
248
|
-
*/
|
|
249
|
-
static setFonts(...fontNames: string[]): void {
|
|
250
|
-
// Convert the array of font names into an array of Font objects.
|
|
251
|
-
MetricsDefaults.fontFamily = fontNames.join(',');
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
static getFonts(): string[] {
|
|
255
|
-
return Metrics.get('fontFamily').split(',');
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
static get RENDER_PRECISION_PLACES(): number {
|
|
259
|
-
return Tables.RENDER_PRECISION_PLACES;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
static set RENDER_PRECISION_PLACES(precision: number) {
|
|
263
|
-
Tables.RENDER_PRECISION_PLACES = precision;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
static get SOFTMAX_FACTOR(): number {
|
|
267
|
-
return Tables.SOFTMAX_FACTOR;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
static set SOFTMAX_FACTOR(factor: number) {
|
|
271
|
-
Tables.SOFTMAX_FACTOR = factor;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
static get UNISON(): boolean {
|
|
275
|
-
return Tables.UNISON;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
static set UNISON(unison: boolean) {
|
|
279
|
-
Tables.UNISON = unison;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
static get NOTATION_FONT_SCALE(): number {
|
|
283
|
-
return Tables.NOTATION_FONT_SCALE;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
static set NOTATION_FONT_SCALE(value: number) {
|
|
287
|
-
Tables.NOTATION_FONT_SCALE = value;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
static get TABLATURE_FONT_SCALE(): number {
|
|
291
|
-
return Tables.TABLATURE_FONT_SCALE;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
static set TABLATURE_FONT_SCALE(value: number) {
|
|
295
|
-
Tables.TABLATURE_FONT_SCALE = value;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
static get RESOLUTION(): number {
|
|
299
|
-
return Tables.RESOLUTION;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
static set RESOLUTION(value: number) {
|
|
303
|
-
Tables.RESOLUTION = value;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
static get SLASH_NOTEHEAD_WIDTH(): number {
|
|
307
|
-
return Tables.SLASH_NOTEHEAD_WIDTH;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
static set SLASH_NOTEHEAD_WIDTH(value: number) {
|
|
311
|
-
Tables.SLASH_NOTEHEAD_WIDTH = value;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
static get STAVE_LINE_DISTANCE(): number {
|
|
315
|
-
return Tables.STAVE_LINE_DISTANCE;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
static set STAVE_LINE_DISTANCE(value: number) {
|
|
319
|
-
Tables.STAVE_LINE_DISTANCE = value;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
static get STAVE_LINE_THICKNESS(): number {
|
|
323
|
-
return Tables.STAVE_LINE_THICKNESS;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
static set STAVE_LINE_THICKNESS(value: number) {
|
|
327
|
-
Tables.STAVE_LINE_THICKNESS = value;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
static get STEM_HEIGHT(): number {
|
|
331
|
-
return Tables.STEM_HEIGHT;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
static set STEM_HEIGHT(value: number) {
|
|
335
|
-
Tables.STEM_HEIGHT = value;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
static get STEM_WIDTH(): number {
|
|
339
|
-
return Tables.STEM_WIDTH;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
static set STEM_WIDTH(value: number) {
|
|
343
|
-
Tables.STEM_WIDTH = value;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
static get TIME4_4(): VoiceTime {
|
|
347
|
-
return Tables.TIME4_4;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
static get unicode(): Record<string, string> {
|
|
351
|
-
return Tables.unicode;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
static keySignature(spec: string): { type: string; line: number }[] {
|
|
355
|
-
return Tables.keySignature(spec);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
static hasKeySignature(spec: string): boolean {
|
|
359
|
-
return Tables.hasKeySignature(spec);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
static getKeySignatures(): Record<string, { acc?: string; num: number }> {
|
|
363
|
-
return Tables.getKeySignatures();
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
static clefProperties(clef: string): { lineShift: number } {
|
|
367
|
-
return Tables.clefProperties(clef);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// eslint-disable-next-line
|
|
371
|
-
static keyProperties(key: string, clef?: string, params?: any): any {
|
|
372
|
-
return Tables.keyProperties(key, clef, params);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
static durationToTicks(duration: string): number {
|
|
376
|
-
return Tables.durationToTicks(duration);
|
|
377
|
-
}
|
|
378
|
-
}
|
package/src/vibrato.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
// MIT License
|
|
3
|
-
|
|
4
|
-
import { Bend } from './bend';
|
|
5
|
-
import { Modifier } from './modifier';
|
|
6
|
-
import { ModifierContext, ModifierContextState } from './modifiercontext';
|
|
7
|
-
import { Tables } from './tables';
|
|
8
|
-
import { Category } from './typeguard';
|
|
9
|
-
|
|
10
|
-
export interface VibratoRenderOptions {
|
|
11
|
-
code: number;
|
|
12
|
-
width: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** `Vibrato` implements diverse vibratos. */
|
|
16
|
-
export class Vibrato extends Modifier {
|
|
17
|
-
static get CATEGORY(): string {
|
|
18
|
-
return Category.Vibrato;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
protected renderOptions: VibratoRenderOptions;
|
|
22
|
-
|
|
23
|
-
/** Arrange vibratos inside a `ModifierContext`. */
|
|
24
|
-
static format(vibratos: Vibrato[], state: ModifierContextState, context: ModifierContext): boolean {
|
|
25
|
-
if (!vibratos || vibratos.length === 0) return false;
|
|
26
|
-
|
|
27
|
-
// Vibratos are always on top.
|
|
28
|
-
let textLine = state.topTextLine;
|
|
29
|
-
let width = 0;
|
|
30
|
-
let shift = state.rightShift - 7;
|
|
31
|
-
|
|
32
|
-
// If there's a bend, drop the text line
|
|
33
|
-
const bends = context.getMembers(Bend.CATEGORY) as Bend[];
|
|
34
|
-
if (bends && bends.length > 0) {
|
|
35
|
-
const bendHeight =
|
|
36
|
-
bends.map((bb) => bb.getTextHeight()).reduce((a, b) => (a > b ? a : b)) / Tables.STAVE_LINE_DISTANCE;
|
|
37
|
-
textLine = textLine - (bendHeight + 1);
|
|
38
|
-
} else {
|
|
39
|
-
state.topTextLine += 1;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Format Vibratos
|
|
43
|
-
for (let i = 0; i < vibratos.length; ++i) {
|
|
44
|
-
const vibrato = vibratos[i];
|
|
45
|
-
vibrato.setXShift(shift);
|
|
46
|
-
vibrato.setTextLine(textLine);
|
|
47
|
-
width += vibrato.getWidth();
|
|
48
|
-
shift += width;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
state.rightShift += width;
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
constructor() {
|
|
56
|
-
super();
|
|
57
|
-
|
|
58
|
-
this.position = Modifier.Position.RIGHT;
|
|
59
|
-
this.renderOptions = {
|
|
60
|
-
code: 0xeab0,
|
|
61
|
-
width: 20,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
this.setVibratoWidth(this.renderOptions.width);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Set vibrato width in pixels. */
|
|
68
|
-
setVibratoWidth(width: number): this {
|
|
69
|
-
this.renderOptions.width = width;
|
|
70
|
-
this.text = String.fromCodePoint(this.renderOptions.code);
|
|
71
|
-
|
|
72
|
-
const items = Math.round(this.renderOptions.width / this.getWidth());
|
|
73
|
-
for (let i = 1; i < items; i++) {
|
|
74
|
-
this.text += String.fromCodePoint(this.renderOptions.code);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Set vibrato code. */
|
|
81
|
-
setVibratoCode(code: number): this {
|
|
82
|
-
this.renderOptions.code = code;
|
|
83
|
-
return this.setVibratoWidth(this.renderOptions.width);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** Draw the vibrato on the rendering context. */
|
|
87
|
-
draw(): void {
|
|
88
|
-
const ctx = this.checkContext();
|
|
89
|
-
const note = this.checkAttachedNote();
|
|
90
|
-
this.setRendered();
|
|
91
|
-
|
|
92
|
-
const start = note.getModifierStartXY(Modifier.Position.RIGHT, this.index);
|
|
93
|
-
|
|
94
|
-
const vx = start.x;
|
|
95
|
-
const vy = note.getYForTopText(this.textLine) + 5;
|
|
96
|
-
|
|
97
|
-
this.renderText(ctx, vx, vy);
|
|
98
|
-
}
|
|
99
|
-
}
|
package/src/vibratobracket.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
// @author Balazs Forian-Szabo
|
|
3
|
-
// MIT License
|
|
4
|
-
|
|
5
|
-
import { Element } from './element';
|
|
6
|
-
import { Note } from './note';
|
|
7
|
-
import { Category } from './typeguard';
|
|
8
|
-
import { log } from './util';
|
|
9
|
-
import { Vibrato } from './vibrato';
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line
|
|
12
|
-
function L(...args: any[]) {
|
|
13
|
-
if (VibratoBracket.DEBUG) log('VexFlow.VibratoBracket', args);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** `VibratoBracket` renders vibrato effect between two notes. */
|
|
17
|
-
export class VibratoBracket extends Element {
|
|
18
|
-
/** To enable logging for this class. Set `VexFlow.VibratoBracket.DEBUG` to `true`. */
|
|
19
|
-
static DEBUG: boolean = false;
|
|
20
|
-
|
|
21
|
-
static get CATEGORY(): string {
|
|
22
|
-
return Category.VibratoBracket;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
protected line: number;
|
|
26
|
-
protected vibrato = new Vibrato();
|
|
27
|
-
|
|
28
|
-
protected start?: Note;
|
|
29
|
-
protected stop?: Note;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Either the stop or start note must be set, or both of them.
|
|
33
|
-
* An undefined value for the start or stop note indicates that the vibrato
|
|
34
|
-
* is drawn from the beginning or until the end of the stave accordingly.
|
|
35
|
-
*/
|
|
36
|
-
constructor(bracketData: { stop?: Note | null; start?: Note | null }) {
|
|
37
|
-
super();
|
|
38
|
-
|
|
39
|
-
if (bracketData.start) this.start = bracketData.start;
|
|
40
|
-
if (bracketData.stop) this.stop = bracketData.stop;
|
|
41
|
-
|
|
42
|
-
this.line = 1;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Set line position of the vibrato bracket. */
|
|
46
|
-
setLine(line: number): this {
|
|
47
|
-
this.line = line;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Set vibrato code. */
|
|
52
|
-
setVibratoCode(code: number): this {
|
|
53
|
-
this.vibrato.setVibratoCode(code);
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Draw the vibrato bracket on the rendering context. */
|
|
58
|
-
draw(): void {
|
|
59
|
-
const ctx = this.checkContext();
|
|
60
|
-
this.setRendered();
|
|
61
|
-
const y: number =
|
|
62
|
-
(this.start && this.start.checkStave().getYForTopText(this.line)) ||
|
|
63
|
-
(this.stop && this.stop.checkStave().getYForTopText(this.line)) ||
|
|
64
|
-
0;
|
|
65
|
-
// If start note is not set then vibrato will be drawn
|
|
66
|
-
// from the beginning of the stave
|
|
67
|
-
const startX: number =
|
|
68
|
-
(this.start && this.start.getAbsoluteX()) || (this.stop && this.stop.checkStave().getTieStartX()) || 0;
|
|
69
|
-
// If stop note is not set then vibrato will be drawn
|
|
70
|
-
// until the end of the stave
|
|
71
|
-
const stopX: number =
|
|
72
|
-
(this.stop && this.stop.getAbsoluteX() - this.stop.getWidth() - 5) ||
|
|
73
|
-
(this.start && this.start.checkStave().getTieEndX() - 10) ||
|
|
74
|
-
0;
|
|
75
|
-
|
|
76
|
-
this.vibrato.setVibratoWidth(stopX - startX);
|
|
77
|
-
|
|
78
|
-
L('Rendering VibratoBracket: startX:', startX, 'stopX:', stopX, 'y:', y);
|
|
79
|
-
this.vibrato.renderText(ctx, startX, y);
|
|
80
|
-
}
|
|
81
|
-
}
|