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
package/src/tabnote.ts DELETED
@@ -1,449 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- //
3
- // ## Description
4
- //
5
- // The file implements notes for Tablature notation. This consists of one or
6
- // more fret positions, and can either be drawn with or without stems.
7
- //
8
- // See `tests/tabnote_tests.ts` for usage examples.
9
-
10
- import { Element } from './element';
11
- import { Glyphs } from './glyphs';
12
- import { Modifier } from './modifier';
13
- import { Note } from './note';
14
- import { Stave } from './stave';
15
- import { StaveNoteStruct } from './stavenote';
16
- import { Stem } from './stem';
17
- import { StemmableNote } from './stemmablenote';
18
- import { Category, isDot } from './typeguard';
19
- import { defined, RuntimeError } from './util';
20
-
21
- export interface TabNotePosition {
22
- // For example, on a six stringed instrument, `str` ranges from 1 to 6.
23
- str: number;
24
-
25
- // fret: 'X' indicates an unused/muted string.
26
- // fret: 3 indicates the third fret.
27
- fret: number | string;
28
- }
29
-
30
- export interface TabNoteStruct extends StaveNoteStruct {
31
- positions: TabNotePosition[];
32
- }
33
-
34
- /**
35
- * Gets the unused strings grouped together if consecutive.
36
- * @param numLines The number of lines.
37
- * @param stringsUsed An array of numbers representing which strings have fret positions.
38
- * @returns
39
- */
40
- function getUnusedStringGroups(numLines: number, stringsUsed: number[]): number[][] {
41
- const stemThrough = [];
42
- let group = [];
43
- for (let string = 1; string <= numLines; string++) {
44
- const isUsed = stringsUsed.indexOf(string) > -1;
45
-
46
- if (!isUsed) {
47
- group.push(string);
48
- } else {
49
- stemThrough.push(group);
50
- group = [];
51
- }
52
- }
53
- if (group.length > 0) stemThrough.push(group);
54
-
55
- return stemThrough;
56
- }
57
-
58
- // Gets groups of points that outline the partial stem lines
59
- // between fret positions
60
- //
61
- // Parameters:
62
- // * stemY - The `y` coordinate the stem is located on
63
- // * unusedStrings - An array of groups of unused strings
64
- // * stave - The stave to use for reference
65
- // * stemDirection - The direction of the stem
66
- function getPartialStemLines(stemY: number, unusedStrings: number[][], stave: Stave, stemDirection: number) {
67
- const upStem = stemDirection !== 1;
68
- const downStem = stemDirection !== -1;
69
-
70
- const lineSpacing = stave.getSpacingBetweenLines();
71
- const totalLines = stave.getNumLines();
72
-
73
- const stemLines: number[][] = [];
74
-
75
- unusedStrings.forEach((strings) => {
76
- const containsLastString = strings.indexOf(totalLines) > -1;
77
- const containsFirstString = strings.indexOf(1) > -1;
78
-
79
- if ((upStem && containsFirstString) || (downStem && containsLastString)) {
80
- return;
81
- }
82
-
83
- // If there's only one string in the group, push a duplicate value.
84
- // We do this because we need 2 strings to convert into upper/lower y
85
- // values.
86
- if (strings.length === 1) {
87
- strings.push(strings[0]);
88
- }
89
-
90
- const lineYs: number[] = [];
91
- // Iterate through each group string and store it's y position
92
- strings.forEach((string, index, strings) => {
93
- const isTopBound = string === 1;
94
- const isBottomBound = string === totalLines;
95
-
96
- // Get the y value for the appropriate staff line,
97
- // we adjust for a 0 index array, since string numbers are index 1
98
- let y = stave.getYForLine(string - 1);
99
-
100
- // Unless the string is the first or last, add padding to each side
101
- // of the line
102
- if (index === 0 && !isTopBound) {
103
- y -= lineSpacing / 2 - 1;
104
- } else if (index === strings.length - 1 && !isBottomBound) {
105
- y += lineSpacing / 2 - 1;
106
- }
107
-
108
- // Store the y value
109
- lineYs.push(y);
110
-
111
- // Store a subsequent y value connecting this group to the main
112
- // stem above/below the stave if it's the top/bottom string
113
- if (stemDirection === 1 && isTopBound) {
114
- lineYs.push(stemY - 2);
115
- } else if (stemDirection === -1 && isBottomBound) {
116
- lineYs.push(stemY + 2);
117
- }
118
- });
119
-
120
- // Add the sorted y values to the
121
- stemLines.push(lineYs.sort((a, b) => a - b));
122
- });
123
-
124
- return stemLines;
125
- }
126
-
127
- export class TabNote extends StemmableNote {
128
- static get CATEGORY(): string {
129
- return Category.TabNote;
130
- }
131
-
132
- protected ghost: boolean;
133
- protected fretElement: Element[] = [];
134
- protected positions: TabNotePosition[];
135
-
136
- // Initialize the TabNote with a `noteStruct` full of properties
137
- // and whether to `drawStem` when rendering the note
138
- constructor(noteStruct: TabNoteStruct, drawStem: boolean = false) {
139
- super(noteStruct);
140
-
141
- this.ghost = false; // Renders parenthesis around notes
142
-
143
- // Note properties
144
- // The fret positions in the note. An array of `{ str: X, fret: X }`
145
- this.positions = noteStruct.positions || [];
146
-
147
- // Render Options
148
- this.renderOptions = {
149
- ...this.renderOptions,
150
- // Flag to draw a stem
151
- drawStem,
152
- // Flag to draw dot modifiers
153
- drawDots: drawStem,
154
- // Flag to extend the main stem through the stave and fret positions
155
- drawStemThroughStave: false,
156
- // vertical shift from stave line
157
- yShift: 0,
158
- };
159
-
160
- this.glyphProps = Note.getGlyphProps(this.duration, this.noteType);
161
- defined(
162
- this.glyphProps,
163
- 'BadArguments',
164
- `No glyph found for duration '${this.duration}' and type '${this.noteType}'`
165
- );
166
-
167
- this.buildStem();
168
-
169
- if (noteStruct.stemDirection) {
170
- this.setStemDirection(noteStruct.stemDirection);
171
- } else {
172
- this.setStemDirection(Stem.UP);
173
- }
174
-
175
- // Renders parenthesis around notes
176
- this.ghost = false;
177
- this.updateWidth();
178
- }
179
- // Return the number of the greatest string, which is the string lowest on the display
180
- greatestString = (): number => {
181
- return this.positions.map((x) => x.str).reduce((a, b) => (a > b ? a : b));
182
- };
183
- // Return the number of the least string, which is the string highest on the display
184
- leastString = (): number => {
185
- return this.positions.map((x) => x.str).reduce((a, b) => (a < b ? a : b));
186
- };
187
-
188
- reset(): this {
189
- super.reset();
190
- if (this.stave) this.setStave(this.stave);
191
- return this;
192
- }
193
-
194
- // Set as ghost `TabNote`, surrounds the fret positions with parenthesis.
195
- // Often used for indicating frets that are being bent to
196
- setGhost(ghost: boolean): this {
197
- this.ghost = ghost;
198
- this.updateWidth();
199
- return this;
200
- }
201
-
202
- // Determine if the note has a stem
203
- hasStem(): boolean {
204
- if (this.renderOptions.drawStem) return true;
205
- return false;
206
- }
207
-
208
- // Get the default stem extension for the note
209
- getStemExtension(): number {
210
- if (this.stemExtensionOverride !== undefined) {
211
- return this.stemExtensionOverride;
212
- }
213
-
214
- return this.flag.getHeight() > Stem.HEIGHT ? this.flag.getHeight() - Stem.HEIGHT : 0;
215
- }
216
-
217
- static tabToElement(fret: string): Element {
218
- let el: Element;
219
-
220
- if (fret.toUpperCase() === 'X') {
221
- el = new Element('TabNote');
222
- el.setText(Glyphs.accidentalDoubleSharp);
223
- } else {
224
- el = new Element('TabNote.text');
225
- el.setText(fret);
226
- el.setYShift(el.getHeight() / 2);
227
- }
228
-
229
- return el;
230
- }
231
-
232
- // Calculate and store the width of the note
233
- updateWidth(): void {
234
- this.fretElement = [];
235
- this.width = 0;
236
- for (let i = 0; i < this.positions.length; ++i) {
237
- let fret = this.positions[i].fret;
238
- if (this.ghost) fret = '(' + fret + ')';
239
- const el = TabNote.tabToElement(fret.toString());
240
- this.fretElement.push(el);
241
- this.width = Math.max(el.getWidth(), this.width);
242
- }
243
- }
244
-
245
- // Set the `stave` to the note
246
- setStave(stave: Stave): this {
247
- super.setStave(stave);
248
- const ctx = stave.getContext();
249
- this.setContext(ctx);
250
-
251
- // we subtract 1 from `line` because getYForLine expects a 0-based index,
252
- // while the position.str is a 1-based index
253
- const ys = this.positions.map(({ str: line }) => stave.getYForLine(Number(line) - 1));
254
-
255
- this.setYs(ys);
256
-
257
- if (this.stem) {
258
- this.stem.setYBounds(this.getStemY(), this.getStemY());
259
- }
260
-
261
- return this;
262
- }
263
-
264
- // Get the fret positions for the note
265
- getPositions(): TabNotePosition[] {
266
- return this.positions;
267
- }
268
-
269
- // Get the default `x` and `y` coordinates for a modifier at a specific
270
- // `position` at a fret position `index`
271
- getModifierStartXY(position: number, index: number): { x: number; y: number } {
272
- if (!this.preFormatted) {
273
- throw new RuntimeError('UnformattedNote', "Can't call GetModifierStartXY on an unformatted note");
274
- }
275
-
276
- if (this.ys.length === 0) {
277
- throw new RuntimeError('NoYValues', 'No Y-Values calculated for this note.');
278
- }
279
-
280
- let x = 0;
281
- if (position === Modifier.Position.LEFT) {
282
- x = -1 * 2; // FIXME: modifier padding, move to font file
283
- } else if (position === Modifier.Position.RIGHT) {
284
- x = this.width + 2; // FIXME: modifier padding, move to font file
285
- } else if (position === Modifier.Position.BELOW || position === Modifier.Position.ABOVE) {
286
- const noteGlyphWidth = this.width;
287
- x = noteGlyphWidth / 2;
288
- }
289
-
290
- return {
291
- x: this.getAbsoluteX() + x,
292
- y: this.ys[index],
293
- };
294
- }
295
-
296
- // Get the default line for rest
297
- getLineForRest(): number {
298
- return Number(this.positions[0].str);
299
- }
300
-
301
- // Pre-render formatting
302
- preFormat(): void {
303
- if (this.preFormatted) return;
304
- if (this.modifierContext) this.modifierContext.preFormat();
305
- // width is already set during init()
306
- this.preFormatted = true;
307
- }
308
-
309
- // Get the x position for the stem
310
- getStemX(): number {
311
- return this.getCenterGlyphX();
312
- }
313
-
314
- // Get the y position for the stem
315
- getStemY(): number {
316
- const numLines = this.checkStave().getNumLines();
317
-
318
- // The decimal staff line amounts provide optimal spacing between the
319
- // fret number and the stem
320
- const stemUpLine = -0.5;
321
- const stemDownLine = numLines - 0.5;
322
- const stemStartLine = Stem.UP === this.stemDirection ? stemUpLine : stemDownLine;
323
-
324
- return this.checkStave().getYForLine(stemStartLine);
325
- }
326
-
327
- // Get the stem extents for the tabnote
328
- getStemExtents(): { topY: number; baseY: number } {
329
- return this.checkStem().getExtents();
330
- }
331
-
332
- // Draw the fal onto the context
333
- drawFlag(): void {
334
- const {
335
- beam,
336
- glyphProps,
337
- renderOptions: { drawStem },
338
- } = this;
339
- const context = this.checkContext();
340
-
341
- const shouldDrawFlag = beam === undefined && drawStem;
342
-
343
- // Now it's the flag's turn.
344
- if (glyphProps.codeFlagUp && shouldDrawFlag) {
345
- const flagX = this.getStemX();
346
- const flagY =
347
- this.getStemDirection() === Stem.DOWN
348
- ? // Down stems are below the note head and have flags on the right.
349
- this.getStemY() - this.checkStem().getHeight() - this.getStemExtension()
350
- : // Up stems are above the note head and have flags on the right.
351
- this.getStemY() - this.checkStem().getHeight() + this.getStemExtension();
352
-
353
- // Draw the Flag
354
- this.applyStyle(context, this.flagStyle);
355
- this.flag.renderText(context, flagX, flagY);
356
- this.restoreStyle(context, this.flagStyle);
357
- }
358
- }
359
-
360
- // Render the modifiers onto the context.
361
- drawModifiers(): void {
362
- this.modifiers.forEach((modifier) => {
363
- // Only draw the dots if enabled.
364
- if (isDot(modifier) && !this.renderOptions.drawDots) {
365
- return;
366
- }
367
-
368
- modifier.setContext(this.getContext());
369
- modifier.drawWithStyle();
370
- });
371
- }
372
-
373
- // Render the stem extension through the fret positions
374
- drawStemThrough(): void {
375
- const stemX = this.getStemX();
376
- const stemY = this.getStemY();
377
- const ctx = this.checkContext();
378
-
379
- const drawStem = this.renderOptions.drawStem;
380
- const stemThrough = this.renderOptions.drawStemThroughStave;
381
- if (drawStem && stemThrough) {
382
- const numLines = this.checkStave().getNumLines();
383
- const stringsUsed = this.positions.map((position) => Number(position.str));
384
-
385
- const unusedStrings = getUnusedStringGroups(numLines, stringsUsed);
386
- const stemLines = getPartialStemLines(stemY, unusedStrings, this.checkStave(), this.getStemDirection());
387
-
388
- ctx.save();
389
- ctx.setLineWidth(Stem.WIDTH);
390
- stemLines.forEach((bounds) => {
391
- if (bounds.length === 0) return;
392
-
393
- ctx.beginPath();
394
- ctx.moveTo(stemX, bounds[0]);
395
- ctx.lineTo(stemX, bounds[bounds.length - 1]);
396
- ctx.stroke();
397
- ctx.closePath();
398
- });
399
- ctx.restore();
400
- }
401
- }
402
-
403
- // Render the fret positions onto the context
404
- drawPositions(): void {
405
- const ctx = this.checkContext();
406
- const x = this.getAbsoluteX();
407
- const ys = this.ys;
408
- for (let i = 0; i < this.positions.length; ++i) {
409
- const y = ys[i] + this.renderOptions.yShift;
410
- const el = this.fretElement[i];
411
-
412
- // Center the fret text beneath the stem
413
- const tabX = x - el.getWidth() / 2;
414
-
415
- // FIXME: Magic numbers.
416
- ctx.clearRect(tabX - 2, y - 3, el.getWidth() + 4, 6);
417
-
418
- el.renderText(ctx, tabX, y);
419
- }
420
- }
421
-
422
- // The main rendering function for the entire note.
423
- draw(): void {
424
- const ctx = this.checkContext();
425
-
426
- if (this.ys.length === 0) {
427
- throw new RuntimeError('NoYValues', "Can't draw note without Y values.");
428
- }
429
-
430
- this.setRendered();
431
- const renderStem = this.beam === undefined && this.renderOptions.drawStem;
432
-
433
- this.applyStyle();
434
- ctx.openGroup('tabnote', this.getAttribute('id'));
435
- this.drawPositions();
436
- this.drawStemThrough();
437
-
438
- if (this.stem && renderStem) {
439
- const stemX = this.getStemX();
440
- this.stem.setNoteHeadXBounds(stemX, stemX);
441
- this.stem.setContext(ctx).draw();
442
- }
443
-
444
- this.drawFlag();
445
- this.drawModifiers();
446
- ctx.closeGroup();
447
- this.restoreStyle();
448
- }
449
- }
package/src/tabslide.ts DELETED
@@ -1,115 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- // MIT License
3
- //
4
- // This class implements varies types of ties between contiguous notes. The
5
- // ties include: regular ties, hammer ons, pull offs, and slides.
6
-
7
- import { TieNotes } from './stavetie';
8
- import { TabNote } from './tabnote';
9
- import { TabTie } from './tabtie';
10
- import { Category } from './typeguard';
11
- import { RuntimeError } from './util';
12
-
13
- export class TabSlide extends TabTie {
14
- static get CATEGORY(): string {
15
- return Category.TabSlide;
16
- }
17
-
18
- static get SLIDE_UP(): number {
19
- return 1;
20
- }
21
-
22
- static get SLIDE_DOWN(): number {
23
- return -1;
24
- }
25
-
26
- static createSlideUp(notes: TieNotes): TabSlide {
27
- return new TabSlide(notes, TabSlide.SLIDE_UP);
28
- }
29
-
30
- static createSlideDown(notes: TieNotes): TabSlide {
31
- return new TabSlide(notes, TabSlide.SLIDE_DOWN);
32
- }
33
-
34
- /**
35
- * @param notes is a struct of the form:
36
- * {
37
- * firstNote: Note,
38
- * lastNote: Note,
39
- * firstIndexes: [n1, n2, n3],
40
- * lastIndexes: [n1, n2, n3]
41
- * }
42
- * @param notes.firstNote the starting note of the slide
43
- * @param notes.lastNote the ending note of the slide
44
- * @param notes.firstIndexes specifies which string + fret positions of the TabNote are used in this slide. zero indexed.
45
- * @param notes.lastIndexes currently unused. we assume it's the same as firstIndexes.
46
- *
47
- * @param direction TabSlide.SLIDE_UP or TabSlide.SLIDE_DOWN
48
- */
49
- constructor(notes: TieNotes, direction?: number) {
50
- super(notes, 'sl.');
51
-
52
- // Determine the direction automatically if it is not provided.
53
- if (!direction) {
54
- let firstFret = (notes.firstNote as TabNote).getPositions()[0].fret;
55
- if (typeof firstFret === 'string') {
56
- firstFret = parseInt(firstFret, 10);
57
- }
58
- let lastFret = (notes.lastNote as TabNote).getPositions()[0].fret;
59
- if (typeof lastFret === 'string') {
60
- lastFret = parseInt(lastFret, 10);
61
- }
62
-
63
- // If either of the frets are 'X', parseInt() above will return NaN.
64
- // Choose TabSlide.SLIDE_UP by default.
65
- if (isNaN(firstFret) || isNaN(lastFret)) {
66
- direction = TabSlide.SLIDE_UP;
67
- } else {
68
- direction = firstFret > lastFret ? TabSlide.SLIDE_DOWN : TabSlide.SLIDE_UP;
69
- }
70
- }
71
-
72
- this.direction = direction;
73
- this.renderOptions.cp1 = 11;
74
- this.renderOptions.cp2 = 14;
75
- this.renderOptions.yShift = 0.5;
76
- }
77
-
78
- /**
79
- * @param params.firstX is specified in pixels.
80
- * @param params.lastX is specified in pixels.
81
- */
82
- renderTie(params: { direction: number; firstX: number; lastX: number; lastYs: number[]; firstYs: number[] }): void {
83
- if (params.firstYs.length === 0 || params.lastYs.length === 0) {
84
- throw new RuntimeError('BadArguments', 'No Y-values to render');
85
- }
86
-
87
- const ctx = this.checkContext();
88
- const firstX = params.firstX; // pixel units
89
- const firstYs = params.firstYs;
90
- const lastX = params.lastX; // pixel units
91
-
92
- const direction = params.direction;
93
- if (direction !== TabSlide.SLIDE_UP && direction !== TabSlide.SLIDE_DOWN) {
94
- throw new RuntimeError('BadSlide', 'Invalid slide direction');
95
- }
96
-
97
- // eslint-disable-next-line
98
- const firstIndexes = this.notes.firstIndexes!;
99
- for (let i = 0; i < firstIndexes.length; ++i) {
100
- const slideY = firstYs[firstIndexes[i]] + this.renderOptions.yShift;
101
-
102
- if (isNaN(slideY)) {
103
- throw new RuntimeError('BadArguments', 'Bad indexes for slide rendering.');
104
- }
105
-
106
- ctx.beginPath();
107
- ctx.moveTo(firstX, slideY + 3 * direction);
108
- ctx.lineTo(lastX, slideY - 3 * direction);
109
- ctx.closePath();
110
- ctx.stroke();
111
- }
112
-
113
- this.setRendered();
114
- }
115
- }
package/src/tabstave.ts DELETED
@@ -1,31 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
-
3
- import { Stave, StaveOptions } from './stave';
4
- import { Category } from './typeguard';
5
-
6
- export class TabStave extends Stave {
7
- static get CATEGORY(): string {
8
- return Category.TabStave;
9
- }
10
-
11
- constructor(x: number, y: number, width: number, options?: StaveOptions) {
12
- const tabOptions = {
13
- spacingBetweenLinesPx: 13,
14
- numLines: 6,
15
- topTextPosition: 1,
16
- ...options,
17
- };
18
-
19
- super(x, y, width, tabOptions);
20
- }
21
-
22
- getYForGlyphs(): number {
23
- return this.getYForLine(2.5);
24
- }
25
-
26
- // Deprecated
27
- addTabGlyph(): this {
28
- this.addClef('tab');
29
- return this;
30
- }
31
- }
package/src/tabtie.ts DELETED
@@ -1,44 +0,0 @@
1
- // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
- // MIT License
3
- //
4
- // ## Description
5
- // This class implements varies types of ties between contiguous notes. The
6
- // ties include: regular ties, hammer ons, pull offs, and slides.
7
-
8
- import { StaveTie, TieNotes } from './stavetie';
9
- import { Category } from './typeguard';
10
-
11
- export class TabTie extends StaveTie {
12
- static get CATEGORY(): string {
13
- return Category.TabTie;
14
- }
15
-
16
- static createHammeron(notes: TieNotes): TabTie {
17
- return new TabTie(notes, 'H');
18
- }
19
-
20
- static createPulloff(notes: TieNotes): TabTie {
21
- return new TabTie(notes, 'P');
22
- }
23
-
24
- /**
25
- * @param notes is a struct that has:
26
- * {
27
- * firstNote: Note,
28
- * lastNote: Note,
29
- * firstIndexes: [n1, n2, n3],
30
- * lastIndexes: [n1, n2, n3]
31
- * }
32
- *
33
- * @param text
34
- */
35
- constructor(notes: TieNotes, text?: string) {
36
- super(notes, text);
37
-
38
- this.renderOptions.cp1 = 9;
39
- this.renderOptions.cp2 = 11;
40
- this.renderOptions.yShift = 3;
41
-
42
- this.direction = -1; // Tab tie's are always face up.
43
- }
44
- }