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.
Files changed (157) 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 +528 -492
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +460 -452
  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/accidental.js +22 -28
  12. package/build/esm/src/beam.js +24 -42
  13. package/build/esm/src/clefnote.js +6 -1
  14. package/build/esm/src/element.js +83 -101
  15. package/build/esm/src/fonts/gonville.js +1 -1
  16. package/build/esm/src/formatter.js +9 -17
  17. package/build/esm/src/fraction.js +15 -22
  18. package/build/esm/src/glyphnote.js +3 -2
  19. package/build/esm/src/metrics.js +3 -0
  20. package/build/esm/src/modifier.js +6 -21
  21. package/build/esm/src/multimeasurerest.js +16 -25
  22. package/build/esm/src/note.js +7 -0
  23. package/build/esm/src/registry.js +5 -19
  24. package/build/esm/src/stave.js +4 -6
  25. package/build/esm/src/stavenote.js +26 -40
  26. package/build/esm/src/stavetempo.js +4 -11
  27. package/build/esm/src/stavetie.js +82 -36
  28. package/build/esm/src/svgcontext.js +5 -12
  29. package/build/esm/src/tickable.js +13 -26
  30. package/build/esm/src/tickcontext.js +20 -2
  31. package/build/esm/src/version.js +3 -3
  32. package/build/esm/src/vibrato.js +6 -1
  33. package/build/esm/tests/clef_tests.js +5 -1
  34. package/build/esm/tests/glyphnote_tests.js +6 -0
  35. package/build/esm/tests/stavetie_tests.js +29 -0
  36. package/build/esm/tests/tabstave_tests.js +1 -0
  37. package/build/esm/tests/vexflow_test_helpers.js +25 -39
  38. package/build/types/src/accidental.d.ts +19 -1
  39. package/build/types/src/annotation.d.ts +1 -1
  40. package/build/types/src/beam.d.ts +12 -1
  41. package/build/types/src/clefnote.d.ts +2 -0
  42. package/build/types/src/element.d.ts +13 -3
  43. package/build/types/src/fonts/gonville.d.ts +1 -1
  44. package/build/types/src/formatter.d.ts +5 -3
  45. package/build/types/src/fraction.d.ts +12 -7
  46. package/build/types/src/modifier.d.ts +2 -1
  47. package/build/types/src/multimeasurerest.d.ts +4 -1
  48. package/build/types/src/note.d.ts +2 -0
  49. package/build/types/src/registry.d.ts +1 -1
  50. package/build/types/src/stavenote.d.ts +2 -1
  51. package/build/types/src/stavetempo.d.ts +3 -3
  52. package/build/types/src/stavetie.d.ts +39 -2
  53. package/build/types/src/svgcontext.d.ts +1 -1
  54. package/build/types/src/tickable.d.ts +2 -1
  55. package/build/types/src/tickcontext.d.ts +30 -0
  56. package/package.json +2 -4
  57. package/tests/flow.html +2 -2
  58. package/entry/vexflow-bravura.ts +0 -25
  59. package/entry/vexflow-core.ts +0 -16
  60. package/entry/vexflow-debug-with-tests.ts +0 -64
  61. package/entry/vexflow-debug.ts +0 -54
  62. package/entry/vexflow.ts +0 -47
  63. package/src/accidental.ts +0 -570
  64. package/src/annotation.ts +0 -294
  65. package/src/articulation.ts +0 -383
  66. package/src/barnote.ts +0 -95
  67. package/src/beam.ts +0 -999
  68. package/src/bend.ts +0 -268
  69. package/src/boundingbox.ts +0 -108
  70. package/src/canvascontext.ts +0 -348
  71. package/src/chordsymbol.ts +0 -473
  72. package/src/clef.ts +0 -164
  73. package/src/clefnote.ts +0 -50
  74. package/src/crescendo.ts +0 -132
  75. package/src/curve.ts +0 -195
  76. package/src/dot.ts +0 -171
  77. package/src/easyscore.ts +0 -538
  78. package/src/element.ts +0 -692
  79. package/src/factory.ts +0 -694
  80. package/src/font.ts +0 -343
  81. package/src/fonts/academico.ts +0 -2
  82. package/src/fonts/academicobold.ts +0 -2
  83. package/src/fonts/bravura.ts +0 -2
  84. package/src/fonts/gonville.ts +0 -2
  85. package/src/fonts/petaluma.ts +0 -2
  86. package/src/fonts/petalumascript.ts +0 -2
  87. package/src/formatter.ts +0 -1107
  88. package/src/fraction.ts +0 -245
  89. package/src/frethandfinger.ts +0 -180
  90. package/src/ghostnote.ts +0 -75
  91. package/src/glyphnote.ts +0 -68
  92. package/src/glyphs.ts +0 -5880
  93. package/src/gracenote.ts +0 -146
  94. package/src/gracenotegroup.ts +0 -194
  95. package/src/gracetabnote.ts +0 -30
  96. package/src/index.ts +0 -90
  97. package/src/keymanager.ts +0 -153
  98. package/src/keysignature.ts +0 -272
  99. package/src/keysignote.ts +0 -46
  100. package/src/metrics.ts +0 -222
  101. package/src/modifier.ts +0 -216
  102. package/src/modifiercontext.ts +0 -177
  103. package/src/multimeasurerest.ts +0 -229
  104. package/src/music.ts +0 -443
  105. package/src/note.ts +0 -690
  106. package/src/notehead.ts +0 -158
  107. package/src/notesubgroup.ts +0 -88
  108. package/src/ornament.ts +0 -301
  109. package/src/parenthesis.ts +0 -89
  110. package/src/parser.ts +0 -263
  111. package/src/pedalmarking.ts +0 -273
  112. package/src/registry.ts +0 -146
  113. package/src/rendercontext.ts +0 -98
  114. package/src/renderer.ts +0 -166
  115. package/src/repeatnote.ts +0 -25
  116. package/src/stave.ts +0 -885
  117. package/src/stavebarline.ts +0 -231
  118. package/src/staveconnector.ts +0 -281
  119. package/src/stavehairpin.ts +0 -209
  120. package/src/staveline.ts +0 -343
  121. package/src/stavemodifier.ts +0 -93
  122. package/src/stavenote.ts +0 -1230
  123. package/src/staverepetition.ts +0 -148
  124. package/src/stavesection.ts +0 -54
  125. package/src/stavetempo.ts +0 -162
  126. package/src/stavetext.ts +0 -69
  127. package/src/stavetie.ts +0 -235
  128. package/src/stavevolta.ts +0 -66
  129. package/src/stem.ts +0 -225
  130. package/src/stemmablenote.ts +0 -248
  131. package/src/stringnumber.ts +0 -286
  132. package/src/strokes.ts +0 -214
  133. package/src/svgcontext.ts +0 -639
  134. package/src/system.ts +0 -327
  135. package/src/tables.ts +0 -796
  136. package/src/tabnote.ts +0 -449
  137. package/src/tabslide.ts +0 -115
  138. package/src/tabstave.ts +0 -31
  139. package/src/tabtie.ts +0 -44
  140. package/src/textbracket.ts +0 -231
  141. package/src/textdynamics.ts +0 -101
  142. package/src/textnote.ts +0 -175
  143. package/src/tickable.ts +0 -374
  144. package/src/tickcontext.ts +0 -280
  145. package/src/timesignature.ts +0 -229
  146. package/src/timesignote.ts +0 -45
  147. package/src/tremolo.ts +0 -51
  148. package/src/tuning.ts +0 -90
  149. package/src/tuplet.ts +0 -349
  150. package/src/typeguard.ts +0 -136
  151. package/src/util.ts +0 -169
  152. package/src/version.ts +0 -4
  153. package/src/vexflow.ts +0 -378
  154. package/src/vibrato.ts +0 -99
  155. package/src/vibratobracket.ts +0 -81
  156. package/src/voice.ts +0 -302
  157. package/src/web.ts +0 -35
package/src/fraction.ts DELETED
@@ -1,245 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- // MIT License
3
- //
4
- // @author Joshua Koo / @zz85
5
- // @author @incompleteopus
6
-
7
- import { Category } from './typeguard';
8
- import { RuntimeError } from './util';
9
-
10
- /** Fraction represents a rational number. */
11
- export class Fraction {
12
- static get CATEGORY(): string {
13
- return Category.Fraction;
14
- }
15
-
16
- // Cached objects for comparisons.
17
- static #fractionA = new Fraction();
18
- static #fractionB = new Fraction();
19
-
20
- /**
21
- * GCD: Greatest common divisor using the Euclidean algorithm.
22
- * Note: GCD(0, 0) => 0 and GCD(0, n) => n.
23
- */
24
- static GCD(a: number, b: number): number {
25
- if (typeof a !== 'number' || Number.isNaN(a) || typeof b !== 'number' || Number.isNaN(b)) {
26
- throw new RuntimeError('BadArgument', `Invalid numbers: ${a}, ${b}`);
27
- }
28
-
29
- let t;
30
-
31
- while (b !== 0) {
32
- t = b;
33
- b = a % b;
34
- a = t;
35
- }
36
-
37
- return a;
38
- }
39
-
40
- /** LCM: Lowest common multiple. */
41
- static LCM(a: number, b: number): number {
42
- return (a * b) / Fraction.GCD(a, b);
43
- }
44
-
45
- /** Lowest common multiple for more than two numbers. */
46
- static LCMM(args: number[]): number {
47
- if (args.length === 0) {
48
- return 0;
49
- } else if (args.length === 1) {
50
- return args[0];
51
- } else if (args.length === 2) {
52
- return Fraction.LCM(args[0], args[1]);
53
- } else {
54
- // args.shift() removes the first number.
55
- // LCM the first number with the rest of the numbers.
56
- return Fraction.LCM(args.shift() as number, Fraction.LCMM(args));
57
- }
58
- }
59
-
60
- numerator: number = 1;
61
- denominator: number = 1;
62
-
63
- /** Set the numerator and denominator. */
64
- constructor(numerator?: number, denominator?: number) {
65
- this.set(numerator, denominator);
66
- }
67
-
68
- /** Set the numerator and denominator. */
69
- set(numerator: number = 1, denominator: number = 1): this {
70
- this.numerator = numerator;
71
- this.denominator = denominator;
72
- return this;
73
- }
74
-
75
- /** Return the value of the fraction. */
76
- value(): number {
77
- return this.numerator / this.denominator;
78
- }
79
-
80
- /** Simplify numerator and denominator using GCD. */
81
- simplify(): this {
82
- let u = this.numerator;
83
- let d = this.denominator;
84
-
85
- const gcd = Fraction.GCD(u, d);
86
- u /= gcd;
87
- d /= gcd;
88
-
89
- if (d < 0) {
90
- d = -d;
91
- u = -u;
92
- }
93
- return this.set(u, d);
94
- }
95
-
96
- /** Add value of another fraction. */
97
- add(param1: Fraction | number = 0, param2: number = 1): this {
98
- const [otherNumerator, otherDenominator] = getNumeratorAndDenominator(param1, param2);
99
- const lcm = Fraction.LCM(this.denominator, otherDenominator);
100
- const a = lcm / this.denominator;
101
- const b = lcm / otherDenominator;
102
- const u = this.numerator * a + otherNumerator * b;
103
- return this.set(u, lcm);
104
- }
105
-
106
- /** Substract value of another fraction. */
107
- subtract(param1: Fraction | number = 0, param2: number = 1): this {
108
- const [otherNumerator, otherDenominator] = getNumeratorAndDenominator(param1, param2);
109
- const lcm = Fraction.LCM(this.denominator, otherDenominator);
110
- const a = lcm / this.denominator;
111
- const b = lcm / otherDenominator;
112
- const u = this.numerator * a - otherNumerator * b;
113
- return this.set(u, lcm);
114
- }
115
-
116
- /** Multiply by value of another fraction. */
117
- multiply(param1: Fraction | number = 1, param2: number = 1): this {
118
- const [otherNumerator, otherDenominator] = getNumeratorAndDenominator(param1, param2);
119
- return this.set(this.numerator * otherNumerator, this.denominator * otherDenominator);
120
- }
121
-
122
- /** Divide by value of another Fraction. */
123
- divide(param1: Fraction | number = 1, param2: number = 1): this {
124
- const [otherNumerator, otherDenominator] = getNumeratorAndDenominator(param1, param2);
125
- return this.set(this.numerator * otherDenominator, this.denominator * otherNumerator);
126
- }
127
-
128
- /** Simplify both sides and check if they are equal. */
129
- equals(compare: Fraction | number): boolean {
130
- const a = Fraction.#fractionA.copy(compare).simplify();
131
- const b = Fraction.#fractionB.copy(this).simplify();
132
-
133
- return a.numerator === b.numerator && a.denominator === b.denominator;
134
- }
135
-
136
- /** Greater than operator. */
137
- greaterThan(compare: Fraction | number): boolean {
138
- const a = Fraction.#fractionA.copy(this);
139
- a.subtract(compare);
140
- return a.numerator > 0;
141
- }
142
-
143
- /** Greater than or equals operator. */
144
- greaterThanEquals(compare: Fraction | number): boolean {
145
- const a = Fraction.#fractionA.copy(this);
146
- a.subtract(compare);
147
- return a.numerator >= 0;
148
- }
149
-
150
- /** Less than operator. */
151
- lessThan(compare: Fraction | number): boolean {
152
- return !this.greaterThanEquals(compare);
153
- }
154
-
155
- /** Less than or equals operator. */
156
- lessThanEquals(compare: Fraction | number): boolean {
157
- return !this.greaterThan(compare);
158
- }
159
-
160
- /** Return a new copy with current values. */
161
- clone(): Fraction {
162
- return new Fraction(this.numerator, this.denominator);
163
- }
164
-
165
- /** Copy value of another fraction. */
166
- copy(other: Fraction | number): this {
167
- if (typeof other === 'number') {
168
- return this.set(other);
169
- } else {
170
- return this.set(other.numerator, other.denominator);
171
- }
172
- }
173
-
174
- /** Return the integer component (eg. 5/2 => 2). */
175
- quotient(): number {
176
- return Math.floor(this.numerator / this.denominator);
177
- }
178
-
179
- /** Return the remainder component (eg. 5/2 => 1). */
180
- remainder(): number {
181
- return this.numerator % this.denominator;
182
- }
183
-
184
- /** Calculate absolute value. */
185
- makeAbs(): this {
186
- this.denominator = Math.abs(this.denominator);
187
- this.numerator = Math.abs(this.numerator);
188
- return this;
189
- }
190
-
191
- /** Return a raw string representation (eg. "5/2"). */
192
- toString(): string {
193
- return `${this.numerator}/${this.denominator}`;
194
- }
195
-
196
- /** Return a simplified string respresentation. */
197
- toSimplifiedString(): string {
198
- return Fraction.#fractionA.copy(this).simplify().toString();
199
- }
200
-
201
- /** Return string representation in mixed form. */
202
- toMixedString(): string {
203
- let s = '';
204
- const q = this.quotient();
205
- const f = Fraction.#fractionA.copy(this);
206
-
207
- if (q < 0) {
208
- f.makeAbs();
209
- }
210
-
211
- if (q !== 0) {
212
- s += q;
213
-
214
- if (f.numerator !== 0) {
215
- s += ` ${f.toSimplifiedString()}`;
216
- }
217
- } else if (f.numerator === 0) {
218
- s = '0';
219
- } else {
220
- s = f.toSimplifiedString();
221
- }
222
-
223
- return s;
224
- }
225
-
226
- /** Parse a fraction string. */
227
- parse(str: string): this {
228
- const i = str.split('/');
229
- const n = parseInt(i[0], 10);
230
- const d = i[1] ? parseInt(i[1], 10) : 1;
231
-
232
- return this.set(n, d);
233
- }
234
- }
235
-
236
- /** Helper function to extract the numerator and denominator from another fraction. */
237
- function getNumeratorAndDenominator(n: Fraction | number, d: number = 1): [number, number] {
238
- if (typeof n === 'number') {
239
- // Both params are numbers, so we return them as [numerator, denominator].
240
- return [n, d];
241
- } else {
242
- // First param is a Fraction object. We ignore the second param.
243
- return [n.numerator, n.denominator];
244
- }
245
- }
@@ -1,180 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- // @author Larry Kuhns 2013
3
- // Class to draws string numbers into the notation.
4
-
5
- import { Builder } from './easyscore';
6
- import { Metrics } from './metrics';
7
- import { Modifier, ModifierPosition } from './modifier';
8
- import { ModifierContextState } from './modifiercontext';
9
- import { StemmableNote } from './stemmablenote';
10
- import { Tables } from './tables';
11
- import { Category } from './typeguard';
12
- import { RuntimeError } from './util';
13
-
14
- export class FretHandFinger extends Modifier {
15
- static get CATEGORY(): string {
16
- return Category.FretHandFinger;
17
- }
18
-
19
- // Arrange fingerings inside a ModifierContext.
20
- static format(nums: FretHandFinger[], state: ModifierContextState): boolean {
21
- const { leftShift, rightShift } = state;
22
- const numSpacing = 1;
23
-
24
- if (!nums || nums.length === 0) return false;
25
-
26
- const numsList = [];
27
- let prevNote = null;
28
- let shiftLeft = 0;
29
- let shiftRight = 0;
30
-
31
- for (let i = 0; i < nums.length; ++i) {
32
- const num = nums[i];
33
- const note = num.getNote();
34
- const pos = num.getPosition();
35
- const index = num.checkIndex();
36
- const props = note.getKeyProps()[index];
37
- const textHeight = Metrics.get('FretHandFinger.fontSize');
38
- if (num.position === ModifierPosition.ABOVE) {
39
- state.topTextLine += textHeight / Tables.STAVE_LINE_DISTANCE + 0.5;
40
- }
41
- if (num.position === ModifierPosition.BELOW) {
42
- state.textLine += textHeight / Tables.STAVE_LINE_DISTANCE + 0.5;
43
- }
44
-
45
- if (note !== prevNote) {
46
- for (let n = 0; n < note.keys.length; ++n) {
47
- if (leftShift === 0) {
48
- shiftLeft = Math.max(note.getLeftDisplacedHeadPx(), shiftLeft);
49
- }
50
- if (rightShift === 0) {
51
- shiftRight = Math.max(note.getRightDisplacedHeadPx(), shiftRight);
52
- }
53
- }
54
- prevNote = note;
55
- }
56
-
57
- numsList.push({
58
- note,
59
- num,
60
- pos,
61
- line: props.line,
62
- shiftL: shiftLeft,
63
- shiftR: shiftRight,
64
- });
65
- }
66
-
67
- // Sort fingernumbers by line number.
68
- numsList.sort((a, b) => b.line - a.line);
69
-
70
- let numShiftL = 0;
71
- let numShiftR = 0;
72
- let xWidthL = 0;
73
- let xWidthR = 0;
74
- let lastLine = null;
75
- let lastNote = null;
76
-
77
- for (let i = 0; i < numsList.length; ++i) {
78
- let numShift = 0;
79
- const { note, pos, num, line, shiftL, shiftR } = numsList[i];
80
-
81
- // Reset the position of the string number every line.
82
- if (line !== lastLine || note !== lastNote) {
83
- numShiftL = leftShift + shiftL;
84
- numShiftR = rightShift + shiftR;
85
- }
86
-
87
- const numWidth = num.getWidth() + numSpacing;
88
- if (pos === Modifier.Position.LEFT) {
89
- num.setXShift(leftShift + numShiftL);
90
- numShift = leftShift + numWidth; // spacing
91
- xWidthL = numShift > xWidthL ? numShift : xWidthL;
92
- } else if (pos === Modifier.Position.RIGHT) {
93
- num.setXShift(numShiftR);
94
- numShift = shiftRight + numWidth; // spacing
95
- xWidthR = numShift > xWidthR ? numShift : xWidthR;
96
- }
97
- lastLine = line;
98
- lastNote = note;
99
- }
100
-
101
- state.leftShift += xWidthL;
102
- state.rightShift += xWidthR;
103
-
104
- return true;
105
- }
106
-
107
- static easyScoreHook({ fingerings }: { fingerings?: string } = {}, note: StemmableNote, builder: Builder): void {
108
- fingerings
109
- ?.split(',')
110
- .map((fingeringString: string) => {
111
- const split = fingeringString.trim().split('.');
112
- const params: { number: string; position?: string } = { number: split[0] };
113
- if (split[1]) params.position = split[1];
114
- return builder.getFactory().Fingering(params);
115
- })
116
- .map((fingering: Modifier, index: number) => note.addModifier(fingering, index));
117
- }
118
-
119
- protected xOffset: number;
120
- protected yOffset: number;
121
-
122
- constructor(finger: string) {
123
- super();
124
-
125
- this.setFretHandFinger(finger);
126
- this.position = Modifier.Position.LEFT; // Default position above stem or note head
127
- this.xOffset = 0; // Horizontal offset from default
128
- this.yOffset = 0; // Vertical offset from default
129
- }
130
-
131
- setFretHandFinger(finger: string): this {
132
- this.text = finger;
133
- return this;
134
- }
135
-
136
- getFretHandFinger(): string {
137
- return this.text;
138
- }
139
-
140
- setOffsetX(x: number): this {
141
- this.xOffset = x;
142
- return this;
143
- }
144
-
145
- setOffsetY(y: number): this {
146
- this.yOffset = y;
147
- return this;
148
- }
149
-
150
- draw(): void {
151
- const ctx = this.checkContext();
152
- const note = this.checkAttachedNote();
153
- this.setRendered();
154
-
155
- const start = note.getModifierStartXY(this.position, this.index);
156
- let dotX = start.x + this.xOffset;
157
- let dotY = start.y + this.yOffset + 5;
158
-
159
- switch (this.position) {
160
- case Modifier.Position.ABOVE:
161
- dotX -= 4;
162
- dotY -= 12;
163
- break;
164
- case Modifier.Position.BELOW:
165
- dotX -= 2;
166
- dotY += 10;
167
- break;
168
- case Modifier.Position.LEFT:
169
- dotX -= this.width;
170
- break;
171
- case Modifier.Position.RIGHT:
172
- dotX += 1;
173
- break;
174
- default:
175
- throw new RuntimeError('InvalidPosition', `The position ${this.position} does not exist`);
176
- }
177
-
178
- this.renderText(ctx, dotX, dotY);
179
- }
180
- }
package/src/ghostnote.ts DELETED
@@ -1,75 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- //
3
- // ## Description
4
-
5
- import { ModifierContext } from './modifiercontext';
6
- import { NoteStruct } from './note';
7
- import { Stave } from './stave';
8
- import { StemmableNote } from './stemmablenote';
9
- import { Category, isAnnotation } from './typeguard';
10
- import { RuntimeError } from './util';
11
-
12
- const ERROR_MSG = 'Ghost note must have valid initialization data to identify duration.';
13
-
14
- export class GhostNote extends StemmableNote {
15
- static get CATEGORY(): string {
16
- return Category.GhostNote;
17
- }
18
-
19
- constructor(parameter: string | NoteStruct) {
20
- if (!parameter) {
21
- throw new RuntimeError('BadArguments', ERROR_MSG);
22
- }
23
-
24
- let noteStruct;
25
- if (typeof parameter === 'string') {
26
- // Preserve backwards-compatibility
27
- noteStruct = { duration: parameter };
28
- } else if (typeof parameter === 'object') {
29
- noteStruct = parameter;
30
- } else {
31
- throw new RuntimeError('BadArguments', ERROR_MSG);
32
- }
33
-
34
- super(noteStruct);
35
-
36
- // Note properties
37
- this.setWidth(0);
38
- }
39
-
40
- /**
41
- * @returns true if this note is a type of rest. Rests don't have pitches, but take up space in the score.
42
- */
43
- isRest(): boolean {
44
- return true;
45
- }
46
-
47
- setStave(stave: Stave): this {
48
- super.setStave(stave);
49
- return this;
50
- }
51
-
52
- /* Overridden to ignore */
53
- // eslint-disable-next-line
54
- addToModifierContext(mc: ModifierContext): this {
55
- // DO NOTHING.
56
- return this;
57
- }
58
-
59
- preFormat(): this {
60
- this.preFormatted = true;
61
- return this;
62
- }
63
-
64
- draw(): void {
65
- // Draw Annotations
66
- this.setRendered();
67
- for (let i = 0; i < this.modifiers.length; ++i) {
68
- const modifier = this.modifiers[i];
69
- if (isAnnotation(modifier)) {
70
- modifier.setContext(this.getContext());
71
- modifier.drawWithStyle();
72
- }
73
- }
74
- }
75
- }
package/src/glyphnote.ts DELETED
@@ -1,68 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- //
3
- // Any glyph that is set to appear on a Stave and take up musical time and graphical space.
4
-
5
- import { Note, NoteStruct } from './note';
6
- import { Category } from './typeguard';
7
-
8
- export interface GlyphNoteOptions {
9
- ignoreTicks?: boolean;
10
- line?: number;
11
- }
12
-
13
- export class GlyphNote extends Note {
14
- static get CATEGORY(): string {
15
- return Category.GlyphNote;
16
- }
17
-
18
- protected options: Required<GlyphNoteOptions>;
19
-
20
- constructor(glyph: string, noteStruct: NoteStruct, options?: GlyphNoteOptions) {
21
- super(noteStruct);
22
- this.options = {
23
- ignoreTicks: false,
24
- line: 2,
25
- ...options,
26
- };
27
-
28
- // Note properties
29
- this.ignoreTicks = this.options.ignoreTicks;
30
- this.setGlyph(glyph);
31
- }
32
-
33
- setGlyph(glyph: string): this {
34
- this.text = glyph;
35
- return this;
36
- }
37
-
38
- preFormat(): this {
39
- if (!this.preFormatted && this.modifierContext) {
40
- this.modifierContext.preFormat();
41
- }
42
- this.preFormatted = true;
43
- return this;
44
- }
45
-
46
- drawModifiers(): void {
47
- const ctx = this.checkContext();
48
- for (let i = 0; i < this.modifiers.length; i++) {
49
- const modifier = this.modifiers[i];
50
- modifier.setContext(ctx);
51
- modifier.drawWithStyle();
52
- }
53
- }
54
-
55
- draw(): void {
56
- const stave = this.checkStave();
57
- const ctx = stave.checkContext();
58
- this.setRendered();
59
- this.applyStyle(ctx);
60
- ctx.openGroup('glyphNote', this.getAttribute('id'));
61
-
62
- const x = this.isCenterAligned() ? this.getAbsoluteX() - this.getWidth() / 2 : this.getAbsoluteX();
63
- this.renderText(ctx, x, stave.getYForLine(this.options.line));
64
- this.drawModifiers();
65
- ctx.closeGroup();
66
- this.restoreStyle(ctx);
67
- }
68
- }