vexflow 5.0.0-alpha.2 → 5.0.0-alpha.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.
Files changed (112) hide show
  1. package/build/cjs/vexflow-bravura.js +2 -2
  2. package/build/cjs/vexflow-bravura.js.map +1 -1
  3. package/build/cjs/vexflow-core.js +2 -2
  4. package/build/cjs/vexflow-core.js.map +1 -1
  5. package/build/cjs/vexflow-debug-with-tests.js +4 -4
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +4 -4
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow.js +2 -2
  10. package/build/cjs/vexflow.js.map +1 -1
  11. package/build/esm/src/version.js +3 -3
  12. package/package.json +1 -3
  13. package/entry/vexflow-bravura.ts +0 -25
  14. package/entry/vexflow-core.ts +0 -16
  15. package/entry/vexflow-debug-with-tests.ts +0 -64
  16. package/entry/vexflow-debug.ts +0 -54
  17. package/entry/vexflow.ts +0 -47
  18. package/src/accidental.ts +0 -570
  19. package/src/annotation.ts +0 -294
  20. package/src/articulation.ts +0 -383
  21. package/src/barnote.ts +0 -95
  22. package/src/beam.ts +0 -999
  23. package/src/bend.ts +0 -268
  24. package/src/boundingbox.ts +0 -108
  25. package/src/canvascontext.ts +0 -348
  26. package/src/chordsymbol.ts +0 -473
  27. package/src/clef.ts +0 -164
  28. package/src/clefnote.ts +0 -50
  29. package/src/crescendo.ts +0 -132
  30. package/src/curve.ts +0 -195
  31. package/src/dot.ts +0 -171
  32. package/src/easyscore.ts +0 -538
  33. package/src/element.ts +0 -692
  34. package/src/factory.ts +0 -694
  35. package/src/font.ts +0 -343
  36. package/src/fonts/academico.ts +0 -2
  37. package/src/fonts/academicobold.ts +0 -2
  38. package/src/fonts/bravura.ts +0 -2
  39. package/src/fonts/gonville.ts +0 -2
  40. package/src/fonts/petaluma.ts +0 -2
  41. package/src/fonts/petalumascript.ts +0 -2
  42. package/src/formatter.ts +0 -1107
  43. package/src/fraction.ts +0 -245
  44. package/src/frethandfinger.ts +0 -180
  45. package/src/ghostnote.ts +0 -75
  46. package/src/glyphnote.ts +0 -68
  47. package/src/glyphs.ts +0 -5880
  48. package/src/gracenote.ts +0 -146
  49. package/src/gracenotegroup.ts +0 -194
  50. package/src/gracetabnote.ts +0 -30
  51. package/src/index.ts +0 -90
  52. package/src/keymanager.ts +0 -153
  53. package/src/keysignature.ts +0 -272
  54. package/src/keysignote.ts +0 -46
  55. package/src/metrics.ts +0 -222
  56. package/src/modifier.ts +0 -216
  57. package/src/modifiercontext.ts +0 -177
  58. package/src/multimeasurerest.ts +0 -229
  59. package/src/music.ts +0 -443
  60. package/src/note.ts +0 -690
  61. package/src/notehead.ts +0 -158
  62. package/src/notesubgroup.ts +0 -88
  63. package/src/ornament.ts +0 -301
  64. package/src/parenthesis.ts +0 -89
  65. package/src/parser.ts +0 -263
  66. package/src/pedalmarking.ts +0 -273
  67. package/src/registry.ts +0 -146
  68. package/src/rendercontext.ts +0 -98
  69. package/src/renderer.ts +0 -166
  70. package/src/repeatnote.ts +0 -25
  71. package/src/stave.ts +0 -885
  72. package/src/stavebarline.ts +0 -231
  73. package/src/staveconnector.ts +0 -281
  74. package/src/stavehairpin.ts +0 -209
  75. package/src/staveline.ts +0 -343
  76. package/src/stavemodifier.ts +0 -93
  77. package/src/stavenote.ts +0 -1230
  78. package/src/staverepetition.ts +0 -148
  79. package/src/stavesection.ts +0 -54
  80. package/src/stavetempo.ts +0 -162
  81. package/src/stavetext.ts +0 -69
  82. package/src/stavetie.ts +0 -235
  83. package/src/stavevolta.ts +0 -66
  84. package/src/stem.ts +0 -225
  85. package/src/stemmablenote.ts +0 -248
  86. package/src/stringnumber.ts +0 -286
  87. package/src/strokes.ts +0 -214
  88. package/src/svgcontext.ts +0 -639
  89. package/src/system.ts +0 -327
  90. package/src/tables.ts +0 -796
  91. package/src/tabnote.ts +0 -449
  92. package/src/tabslide.ts +0 -115
  93. package/src/tabstave.ts +0 -31
  94. package/src/tabtie.ts +0 -44
  95. package/src/textbracket.ts +0 -231
  96. package/src/textdynamics.ts +0 -101
  97. package/src/textnote.ts +0 -175
  98. package/src/tickable.ts +0 -374
  99. package/src/tickcontext.ts +0 -280
  100. package/src/timesignature.ts +0 -229
  101. package/src/timesignote.ts +0 -45
  102. package/src/tremolo.ts +0 -51
  103. package/src/tuning.ts +0 -90
  104. package/src/tuplet.ts +0 -349
  105. package/src/typeguard.ts +0 -136
  106. package/src/util.ts +0 -169
  107. package/src/version.ts +0 -4
  108. package/src/vexflow.ts +0 -378
  109. package/src/vibrato.ts +0 -99
  110. package/src/vibratobracket.ts +0 -81
  111. package/src/voice.ts +0 -302
  112. package/src/web.ts +0 -35
@@ -1,231 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- // @author Cyril Silverman
3
- //
4
- // This file implements `TextBrackets` which extend between two notes.
5
- // The octave transposition markings (8va, 8vb, 15va, 15vb) can be created
6
- // using this class.
7
-
8
- import { Element } from './element';
9
- import { Font } from './font';
10
- import { Note } from './note';
11
- import { RenderContext } from './rendercontext';
12
- import { Renderer } from './renderer';
13
- import { Tables } from './tables';
14
- import { Category } from './typeguard';
15
- import { log, RuntimeError } from './util';
16
-
17
- export interface TextBracketParams {
18
- start: Note;
19
- stop: Note;
20
- text?: string;
21
- superscript?: string;
22
- position?: number | string;
23
- }
24
-
25
- // To enable logging for this class. Set `VexFlow.TextBracket.DEBUG` to `true`.
26
- // eslint-disable-next-line
27
- function L(...args: any[]) {
28
- if (TextBracket.DEBUG) log('VexFlow.TextBracket', args);
29
- }
30
-
31
- export enum TextBracketPosition {
32
- TOP = 1,
33
- BOTTOM = -1,
34
- }
35
-
36
- export class TextBracket extends Element {
37
- static DEBUG: boolean = false;
38
-
39
- static get CATEGORY(): string {
40
- return Category.TextBracket;
41
- }
42
-
43
- public renderOptions: {
44
- dashed: boolean;
45
- color: string;
46
- lineWidth: number;
47
- underlineSuperscript: boolean;
48
- showBracket: boolean;
49
- dash: number[];
50
- bracketHeight: number;
51
- };
52
-
53
- protected textElement: Element;
54
- protected superscriptElement: Element;
55
-
56
- protected line: number;
57
-
58
- readonly position: TextBracketPosition;
59
- readonly start: Note;
60
- readonly stop: Note;
61
-
62
- static get Position(): typeof TextBracketPosition {
63
- return TextBracketPosition;
64
- }
65
-
66
- static get PositionString(): Record<string, number> {
67
- return {
68
- top: TextBracketPosition.TOP,
69
- bottom: TextBracketPosition.BOTTOM,
70
- };
71
- }
72
-
73
- constructor({ start, stop, text = '', superscript = '', position = TextBracketPosition.TOP }: TextBracketParams) {
74
- super();
75
-
76
- this.start = start;
77
- this.stop = stop;
78
-
79
- this.textElement = new Element('TextBracket');
80
- this.textElement.setText(text);
81
- this.superscriptElement = new Element('TextBracket');
82
- this.superscriptElement.setText(superscript);
83
- const smallerFontSize = Font.scaleSize(this.fontInfo.size, 0.714286);
84
- this.superscriptElement.setFontSize(smallerFontSize);
85
-
86
- this.position = typeof position === 'string' ? TextBracket.PositionString[position] : position;
87
-
88
- this.line = 1;
89
-
90
- this.renderOptions = {
91
- dashed: true,
92
- dash: [5],
93
- color: 'black',
94
- lineWidth: 1,
95
- showBracket: true,
96
- bracketHeight: 8,
97
-
98
- // In the BOTTOM position, the bracket line can extend
99
- // under the superscript.
100
- underlineSuperscript: true,
101
- };
102
- }
103
-
104
- /**
105
- * Apply the text backet styling to the provided context.
106
- * @param ctx
107
- * @returns this
108
- */
109
- applyStyle(ctx: RenderContext): this {
110
- this.textElement.setFont(this.fontInfo);
111
- // We called this.resetFont() in the constructor, so we know this.textFont is available.
112
- const { family, size, weight, style } = this.fontInfo;
113
- // To draw the superscript, we scale the font size by 1/1.4.
114
- const smallerFontSize = Font.scaleSize(size, 0.714286);
115
- this.superscriptElement.setFont(family, smallerFontSize, weight, style);
116
-
117
- const options = this.renderOptions;
118
- ctx.setStrokeStyle(options.color);
119
- ctx.setFillStyle(options.color);
120
- ctx.setLineWidth(options.lineWidth);
121
-
122
- return this;
123
- }
124
-
125
- // Set whether the bracket line should be `dashed`. You can also
126
- // optionally set the `dash` pattern by passing in an array of numbers
127
- setDashed(dashed: boolean, dash?: number[]): this {
128
- this.renderOptions.dashed = dashed;
129
- if (dash) this.renderOptions.dash = dash;
130
- return this;
131
- }
132
-
133
- // Set the rendering `context` for the octave bracket
134
- setLine(line: number): this {
135
- this.line = line;
136
- return this;
137
- }
138
-
139
- // Draw the octave bracket on the rendering context
140
- draw(): void {
141
- const ctx = this.checkContext();
142
- this.setRendered();
143
-
144
- let y = 0;
145
- switch (this.position) {
146
- case TextBracketPosition.TOP:
147
- y = this.start.checkStave().getYForTopText(this.line);
148
- break;
149
- case TextBracketPosition.BOTTOM:
150
- y = this.start.checkStave().getYForBottomText(this.line + Tables.TEXT_HEIGHT_OFFSET_HACK);
151
- break;
152
- default:
153
- throw new RuntimeError('InvalidPosition', `The position ${this.position} is invalid.`);
154
- }
155
-
156
- // Get the preliminary start and stop coordintates for the bracket
157
- const start = { x: this.start.getAbsoluteX(), y };
158
- const stop = { x: this.stop.getAbsoluteX(), y };
159
-
160
- L('Rendering TextBracket: start:', start, 'stop:', stop, 'y:', y);
161
-
162
- const bracketHeight = this.renderOptions.bracketHeight * this.position;
163
-
164
- ctx.save();
165
- this.applyStyle(ctx);
166
-
167
- // Draw text
168
- this.textElement.renderText(ctx, start.x, start.y);
169
-
170
- // Get the width and height for the octave number
171
- const mainWidth = this.textElement.getWidth();
172
- const mainHeight = this.textElement.getHeight();
173
-
174
- // Calculate the y position for the super script
175
- const superY = start.y - mainHeight / 2.5;
176
-
177
- // To draw the superscript, we scale the font size by 1/1.4.
178
- this.superscriptElement.renderText(ctx, start.x + mainWidth + 1, superY);
179
-
180
- // Determine width and height of the superscript
181
- const superWidth = this.superscriptElement.getWidth();
182
- const superHeight = this.superscriptElement.getHeight();
183
-
184
- // Setup initial coordinates for the bracket line
185
- let startX = start.x;
186
- let lineY = superY;
187
- const endX = stop.x + this.stop.getGlyphWidth();
188
-
189
- // Adjust x and y coordinates based on position
190
- if (this.position === TextBracketPosition.TOP) {
191
- startX += mainWidth + superWidth + 5;
192
- lineY -= superHeight / 2.7;
193
- } else if (this.position === TextBracketPosition.BOTTOM) {
194
- lineY += superHeight / 2.7;
195
- startX += mainWidth + 2;
196
-
197
- if (!this.renderOptions.underlineSuperscript) {
198
- startX += superWidth;
199
- }
200
- }
201
-
202
- if (this.renderOptions.dashed) {
203
- // Main line
204
- Renderer.drawDashedLine(ctx, startX, lineY, endX, lineY, this.renderOptions.dash);
205
- // Ending Bracket
206
- if (this.renderOptions.showBracket) {
207
- Renderer.drawDashedLine(
208
- ctx,
209
- endX,
210
- lineY + 1 * this.position,
211
- endX,
212
- lineY + bracketHeight,
213
- this.renderOptions.dash
214
- );
215
- }
216
- } else {
217
- ctx.beginPath();
218
- ctx.moveTo(startX, lineY);
219
- // Main line
220
- ctx.lineTo(endX, lineY);
221
- if (this.renderOptions.showBracket) {
222
- // Ending bracket
223
- ctx.lineTo(endX, lineY + bracketHeight);
224
- }
225
- ctx.stroke();
226
- ctx.closePath();
227
- }
228
-
229
- ctx.restore();
230
- }
231
- }
@@ -1,101 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- // MIT License
3
-
4
- import { Glyphs } from './glyphs';
5
- import { Note } from './note';
6
- import { TextNoteStruct } from './textnote';
7
- import { Category } from './typeguard';
8
- import { log, RuntimeError } from './util';
9
-
10
- // eslint-disable-next-line
11
- function L(...args: any[]) {
12
- if (TextDynamics.DEBUG) log('VexFlow.TextDynamics', args);
13
- }
14
-
15
- /**
16
- * `TextDynamics` renders traditional
17
- * text dynamics markings, **ie: p, f, sfz, rfz, ppp**
18
- *
19
- * You can render any dynamics string that contains a combination of
20
- * the following letters: P, M, F, Z, R, S
21
- */
22
- export class TextDynamics extends Note {
23
- /** To enable logging for this class. Set `VexFlow.TextDynamics.DEBUG` to `true`. */
24
- static DEBUG: boolean = false;
25
-
26
- static get CATEGORY(): string {
27
- return Category.TextDynamics;
28
- }
29
-
30
- protected sequence: string;
31
-
32
- protected line: number;
33
-
34
- /** The glyph data for each dynamics letter. */
35
- static get GLYPHS(): Record<string, string> {
36
- return {
37
- f: Glyphs.dynamicForte,
38
- p: Glyphs.dynamicPiano,
39
- m: Glyphs.dynamicMezzo,
40
- s: Glyphs.dynamicSforzando,
41
- z: Glyphs.dynamicZ,
42
- r: Glyphs.dynamicRinforzando,
43
- };
44
- }
45
-
46
- /**
47
- * Create the dynamics marking.
48
- *
49
- * A `TextDynamics` object inherits from `Note` so that it can be formatted
50
- * within a `Voice`.
51
- *
52
- * @param noteStruct an object that contains a `duration` property and a
53
- * `sequence` of letters that represents the letters to render.
54
- */
55
- constructor(noteStruct: TextNoteStruct) {
56
- super(noteStruct);
57
-
58
- this.sequence = (noteStruct.text ?? '').toLowerCase();
59
- this.line = noteStruct.line ?? 0;
60
- this.text = '';
61
-
62
- L('New Dynamics Text: ', this.sequence);
63
- }
64
-
65
- /** Set the Stave line on which the note should be placed. */
66
- setLine(line: number): this {
67
- this.line = line;
68
- return this;
69
- }
70
-
71
- /** Preformat the dynamics text. */
72
- preFormat(): this {
73
- // length of this.glyphs must be <=
74
- // length of this.sequence, so if we're formatted before
75
- // create new glyphs.
76
- this.text = '';
77
- // Iterate through each letter
78
- this.sequence.split('').forEach((letter) => {
79
- // Get the glyph data for the letter
80
- const glyph = TextDynamics.GLYPHS[letter];
81
- if (!glyph) throw new RuntimeError('Invalid dynamics character: ' + letter);
82
-
83
- // Add the glyph
84
- this.text += glyph;
85
- });
86
-
87
- this.preFormatted = true;
88
- return this;
89
- }
90
-
91
- /** Draw the dynamics text on the rendering context. */
92
- draw(): void {
93
- this.setRendered();
94
- const x = this.getAbsoluteX();
95
- const y = this.checkStave().getYForLine(this.line + -3);
96
-
97
- L('Rendering Dynamics: ', this.sequence);
98
-
99
- this.renderText(this.checkContext(), x, y);
100
- }
101
- }
package/src/textnote.ts DELETED
@@ -1,175 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- // MIT License
3
-
4
- import { Element } from './element';
5
- import { Font, FontInfo } from './font';
6
- import { Glyphs } from './glyphs';
7
- import { Metrics } from './metrics';
8
- import { Note, NoteStruct } from './note';
9
- import { Category } from './typeguard';
10
-
11
- export enum TextJustification {
12
- LEFT = 1,
13
- CENTER = 2,
14
- RIGHT = 3,
15
- }
16
-
17
- export interface TextNoteStruct extends NoteStruct {
18
- text?: string;
19
- glyph?: string;
20
- ignoreTicks?: boolean;
21
- smooth?: boolean;
22
- font?: FontInfo;
23
- subscript?: string;
24
- superscript?: string;
25
- }
26
-
27
- /**
28
- * `TextNote` is a notation element that is positioned in time. Generally
29
- * meant for objects that sit above/below the staff and inline with each other.
30
- * `TextNote` has to be assigned to a `Stave` before rendering by means of `setStave`.
31
- * Examples of this would be such as dynamics, lyrics, chord changes, etc.
32
- */
33
- export class TextNote extends Note {
34
- static get CATEGORY(): string {
35
- return Category.TextNote;
36
- }
37
-
38
- static readonly Justification = TextJustification;
39
-
40
- /** Glyph data. */
41
- static get GLYPHS(): Record<string, string> {
42
- return {
43
- segno: Glyphs.segno,
44
- tr: Glyphs.ornamentTrill,
45
- mordent: Glyphs.ornamentMordent,
46
- mordentUpper: Glyphs.ornamentShortTrill,
47
- mordentLower: Glyphs.ornamentMordent,
48
- f: Glyphs.dynamicForte,
49
- p: Glyphs.dynamicPiano,
50
- m: Glyphs.dynamicMezzo,
51
- s: Glyphs.dynamicSforzando,
52
- z: Glyphs.dynamicZ,
53
- coda: Glyphs.coda,
54
- pedalOpen: Glyphs.keyboardPedalPed,
55
- pedalClose: Glyphs.keyboardPedalUp,
56
- caesuraStraight: Glyphs.caesura,
57
- caesuraCurved: Glyphs.caesuraCurved,
58
- breath: Glyphs.breathMarkComma,
59
- tick: Glyphs.breathMarkTick,
60
- turn: Glyphs.ornamentTurn,
61
- turnInverted: Glyphs.ornamentTurnSlash,
62
- };
63
- }
64
-
65
- protected superscript?: Element;
66
- protected subscript?: Element;
67
- protected smooth: boolean;
68
- protected justification: TextJustification;
69
- protected line: number;
70
-
71
- constructor(noteStruct: TextNoteStruct) {
72
- super(noteStruct);
73
-
74
- this.text = noteStruct.text ?? '';
75
- if (noteStruct.glyph) {
76
- this.text += TextNote.GLYPHS[noteStruct.glyph] || noteStruct.glyph;
77
- }
78
- if (noteStruct.font) {
79
- this.setFont(noteStruct.font);
80
- } else if (noteStruct.glyph === undefined) {
81
- this.setFont(Metrics.getFontInfo('TextNote.text.fontSize'));
82
- }
83
-
84
- // Scale the font size by 1/1.3.
85
- const smallerFontSize = Font.convertSizeToPointValue(this.fontInfo.size) * 0.769231;
86
- if (noteStruct.superscript) {
87
- this.superscript = new Element('TexNote.subSuper');
88
- this.superscript.setText(noteStruct.superscript);
89
- this.superscript.setFontSize(smallerFontSize);
90
- }
91
- if (noteStruct.subscript) {
92
- this.subscript = new Element('TexNote.subSuper');
93
- this.subscript.setText(noteStruct.subscript);
94
- this.subscript.setFontSize(smallerFontSize);
95
- }
96
-
97
- this.line = noteStruct.line ?? 0;
98
- this.smooth = noteStruct.smooth || false;
99
- this.ignoreTicks = noteStruct.ignoreTicks || false;
100
- this.justification = TextJustification.LEFT;
101
- }
102
-
103
- /** Set the horizontal justification of the TextNote. */
104
- setJustification(just: TextJustification): this {
105
- this.justification = just;
106
- return this;
107
- }
108
-
109
- /** Set the Stave line on which the note should be placed. */
110
- setLine(line: number): this {
111
- this.line = line;
112
- return this;
113
- }
114
-
115
- /** Return the Stave line on which the TextNote is placed. */
116
- getLine(): number {
117
- return this.line;
118
- }
119
-
120
- /** Pre-render formatting. */
121
- preFormat(): void {
122
- if (this.preFormatted) return;
123
- const tickContext = this.checkTickContext(`Can't preformat without a TickContext.`);
124
-
125
- if (this.justification === TextJustification.CENTER) {
126
- this.leftDisplacedHeadPx = this.width / 2;
127
- } else if (this.justification === TextJustification.RIGHT) {
128
- this.leftDisplacedHeadPx = this.width;
129
- }
130
-
131
- // We reposition to the center of the note head
132
- this.rightDisplacedHeadPx = tickContext.getMetrics().glyphPx / 2;
133
- this.preFormatted = true;
134
- }
135
-
136
- /**
137
- * Renders the TextNote.
138
- * `TextNote` has to be assigned to a `Stave` before rendering by means of `setStave`.
139
- */
140
- draw(): void {
141
- const ctx = this.checkContext();
142
- const stave = this.checkStave();
143
- const tickContext = this.checkTickContext(`Can't draw without a TickContext.`);
144
-
145
- this.setRendered();
146
-
147
- // Reposition to center of note head
148
- let x = this.getAbsoluteX() + tickContext.getMetrics().glyphPx / 2;
149
-
150
- // Align based on tick-context width.
151
- const width = this.getWidth();
152
-
153
- if (this.justification === TextJustification.CENTER) {
154
- x -= width / 2;
155
- } else if (this.justification === TextJustification.RIGHT) {
156
- x -= width;
157
- }
158
-
159
- const y = stave.getYForLine(this.line + -3);
160
- this.applyStyle(ctx);
161
- this.renderText(ctx, x, y);
162
-
163
- const height = this.getHeight();
164
-
165
- if (this.superscript) {
166
- this.superscript.renderText(ctx, x + this.width + 2, y - height / 2.2);
167
- }
168
-
169
- if (this.subscript) {
170
- this.subscript.renderText(ctx, x + this.width + 2, y + height / 2.2 - 1);
171
- }
172
-
173
- this.restoreStyle(ctx);
174
- }
175
- }