Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rvilarl committed Jun 5, 2021
1 parent 794669f commit c6628f0
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 60 deletions.
16 changes: 9 additions & 7 deletions src/notehead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//
// See `tests/notehead_tests.js` for usage examples.

import { Vex } from './vex';
import { RuntimeError, log } from './util';
import { Flow } from './tables';
import { Note, NoteStruct } from './note';
Expand Down Expand Up @@ -156,12 +155,15 @@ export class NoteHead extends Note {
this.style = head_options.style;
this.slashed = head_options.slashed || false;

Vex.Merge(this.render_options, {
// font size for note heads
glyph_font_scale: head_options.glyph_font_scale || Flow.DEFAULT_NOTATION_FONT_SCALE,
// number of stroke px to the left and right of head
stroke_px: 3,
});
this.render_options = {
...this.render_options,
...{
// font size for note heads
glyph_font_scale: head_options.glyph_font_scale || Flow.DEFAULT_NOTATION_FONT_SCALE,
// number of stroke px to the left and right of head
stroke_px: 3,
},
};

this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale));
}
Expand Down
8 changes: 5 additions & 3 deletions src/stave.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.

import { Vex } from './vex';
import { RuntimeError } from './util';
import { Element, ElementStyle } from './element';
import { Flow } from './tables';
Expand Down Expand Up @@ -101,7 +100,7 @@ export class Stave extends Element {
line_config: [],
};
this.bounds = { x: this.x, y: this.y, w: this.width, h: 0 };
Vex.Merge(this.options, options);
this.options = { ...this.options, ...options };

this.resetLines();

Expand Down Expand Up @@ -781,7 +780,10 @@ export class Stave extends Element {
if (!lines_configuration[line_config]) {
lines_configuration[line_config] = this.options.line_config[line_config];
}
Vex.Merge(this.options.line_config[line_config], lines_configuration[line_config]);
this.options.line_config[line_config] = {
...this.options.line_config[line_config],
...lines_configuration[line_config],
};
}

this.options.line_config = lines_configuration;
Expand Down
5 changes: 2 additions & 3 deletions src/staveconnector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.

import { Vex } from './vex';
import { RuntimeError } from './util';
import { Element } from './element';
import { Flow } from './tables';
Expand Down Expand Up @@ -112,13 +111,13 @@ export class StaveConnector extends Element {
): this {
this.texts.push({
content: text,
options: Vex.Merge({ shift_x: 0, shift_y: 0 }, options),
options: { ...{ shift_x: 0, shift_y: 0 }, ...options },
});
return this;
}

setFont(font: FontInfo): void {
Vex.Merge(this.font, font);
this.font = { ...this.font, ...font };
}

setXShift(x_shift: number): this {
Expand Down
15 changes: 9 additions & 6 deletions src/stavenote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,15 @@ export class StaveNote extends StemmableNote {
this.note_heads = [];
this.modifiers = [];

Vex.Merge(this.render_options, {
// font size for note heads and rests
glyph_font_scale: noteStruct.glyph_font_scale || Flow.DEFAULT_NOTATION_FONT_SCALE,
// number of stroke px to the left and right of head
stroke_px: noteStruct.stroke_px || StaveNote.DEFAULT_LEDGER_LINE_OFFSET,
});
this.render_options = {
...this.render_options,
...{
// font size for note heads and rests
glyph_font_scale: noteStruct.glyph_font_scale || Flow.DEFAULT_NOTATION_FONT_SCALE,
// number of stroke px to the left and right of head
stroke_px: noteStruct.stroke_px || StaveNote.DEFAULT_LEDGER_LINE_OFFSET,
},
};

this.calculateKeyProps();
this.buildStem();
Expand Down
3 changes: 1 addition & 2 deletions src/stavetext.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
// Author Taehoon Moon 2014

import { Vex } from './vex';
import { RuntimeError } from './util';
import { StaveModifier } from './stavemodifier';
import { TextNote } from './textnote';
Expand Down Expand Up @@ -44,7 +43,7 @@ export class StaveText extends StaveModifier {
shift_y: 0,
justification: TextNote.Justification.CENTER,
};
Vex.Merge(this.options, options);
this.options = { ...this.options, ...options };

this.font = {
family: 'times',
Expand Down
36 changes: 19 additions & 17 deletions src/tabnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//
// See `tests/tabnote_tests.js` for usage examples

import { Vex } from './vex';
import { RuntimeError } from './util';
import { Flow } from './tables';
import { Modifier } from './modifier';
Expand Down Expand Up @@ -136,22 +135,25 @@ export class TabNote extends StemmableNote {
this.positions = tab_struct.positions;

// Render Options
Vex.Merge(this.render_options, {
// font size for note heads and rests
glyph_font_scale: Flow.DEFAULT_TABLATURE_FONT_SCALE,
// Flag to draw a stem
draw_stem,
// Flag to draw dot modifiers
draw_dots: draw_stem,
// Flag to extend the main stem through the stave and fret positions
draw_stem_through_stave: false,
// vertical shift from stave line
y_shift: 0,
// normal glyph scale
scale: 1.0,
// default tablature font
font: '10pt Arial',
});
this.render_options = {
...this.render_options,
...{
// font size for note heads and rests
glyph_font_scale: Flow.DEFAULT_TABLATURE_FONT_SCALE,
// Flag to draw a stem
draw_stem,
// Flag to draw dot modifiers
draw_dots: draw_stem,
// Flag to extend the main stem through the stave and fret positions
draw_stem_through_stave: false,
// vertical shift from stave line
y_shift: 0,
// normal glyph scale
scale: 1.0,
// default tablature font
font: '10pt Arial',
},
};

this.glyph = Flow.getGlyphProps(this.duration, this.noteType);

Expand Down
10 changes: 6 additions & 4 deletions src/textdynamics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// You can render any dynamics string that contains a combination of
// the following letters: P, M, F, Z, R, S

import { Vex } from './vex';
import { RuntimeError, log } from './util';
import { Note } from './note';
import { Glyph } from './glyph';
Expand Down Expand Up @@ -72,9 +71,12 @@ export class TextDynamics extends Note {
this.line = text_struct.line || 0;
this.glyphs = [];

Vex.Merge(this.render_options, {
glyph_font_size: 40,
});
this.render_options = {
...this.render_options,
...{
glyph_font_size: 40,
},
};

L('New Dynamics Text: ', this.sequence);
}
Expand Down
24 changes: 11 additions & 13 deletions src/tuplet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
* }
*/

import { Vex } from './vex';
import { RuntimeError } from './util';
import { Element } from './element';
import { Formatter } from './formatter';
Expand All @@ -55,13 +54,13 @@ import { StemmableNote } from './stemmablenote';
import { check } from './common';

export interface TupletOptions {
beats_occupied: number;
bracketed: boolean;
location: number;
notes_occupied: number;
num_notes: number;
ratioed: boolean;
y_offset: number;
beats_occupied?: number;
bracketed?: boolean;
location?: number;
notes_occupied?: number;
num_notes?: number;
ratioed?: boolean;
y_offset?: number;
}

export class Tuplet extends Element {
Expand Down Expand Up @@ -98,24 +97,23 @@ export class Tuplet extends Element {
throw new RuntimeError('BadArguments', 'No notes provided for tuplet.');
}

this.options = Vex.Merge({}, options);
this.options = { ...options };
this.notes = notes;
this.num_notes = 'num_notes' in this.options ? this.options.num_notes : notes.length;
this.num_notes = this.options.num_notes ? this.options.num_notes : notes.length;

// We accept beats_occupied, but warn that it's deprecated:
// the preferred property name is now notes_occupied.
if (this.options.beats_occupied) {
this.beatsOccupiedDeprecationWarning();
}
this.notes_occupied = this.options.notes_occupied || this.options.beats_occupied || 2;
if ('bracketed' in this.options) {
if (this.options.bracketed) {
this.bracketed = this.options.bracketed;
} else {
this.bracketed = notes.some((note) => !note.hasBeam());
}

this.ratioed =
'ratioed' in this.options ? this.options.ratioed : Math.abs(this.notes_occupied - this.num_notes) > 1;
this.ratioed = this.options.ratioed ? this.options.ratioed : Math.abs(this.notes_occupied - this.num_notes) > 1;
this.point = this.musicFont.lookupMetric('digits.tupletPoint');
this.y_pos = 16;
this.x_pos = 100;
Expand Down
9 changes: 4 additions & 5 deletions src/voice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// This file implements the main Voice class. It's mainly a container
// object to group `Tickables` for formatting.

import { Vex } from './vex';
import { RuntimeError } from './util';
import { Element } from './element';
import { Flow } from './tables';
Expand Down Expand Up @@ -78,14 +77,14 @@ export class Voice extends Element {
}

// Default time sig is 4/4
this.time = Vex.Merge(
{
this.time = {
...{
num_beats: 4,
beat_value: 4,
resolution: Flow.RESOLUTION,
},
time
);
...(time as VoiceTime),
};

// Recalculate total ticks.
this.totalTicks = new Fraction(this.time.num_beats * (this.time.resolution / this.time.beat_value), 1);
Expand Down

0 comments on commit c6628f0

Please sign in to comment.