Skip to content

Commit

Permalink
note_struct -> noteStruct
Browse files Browse the repository at this point in the history
  • Loading branch information
rvilarl committed Sep 9, 2021
1 parent 9cf148f commit cbca85c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions src/crescendo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ export class Crescendo extends Note {
};

// Initialize the crescendo's properties
constructor(note_struct: NoteStruct) {
super(note_struct);
constructor(noteStruct: NoteStruct) {
super(noteStruct);
this.setAttribute('type', 'Crescendo');

// Whether the object is a decrescendo
this.decrescendo = false;

// The staff line to be placed on
this.line = note_struct.line || 0;
this.line = noteStruct.line || 0;

// The height at the open end of the cresc/decresc
this.height = 15;
Expand Down
8 changes: 4 additions & 4 deletions src/ghostnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ export class GhostNote extends StemmableNote {
throw new RuntimeError('BadArguments', 'Ghost note must have valid initialization data to identify duration.');
}

let note_struct;
let noteStruct;

// Preserve backwards-compatibility
if (typeof parameter === 'string') {
note_struct = { duration: parameter };
noteStruct = { duration: parameter };
} else if (typeof parameter === 'object') {
note_struct = parameter;
noteStruct = parameter;
} else {
throw new RuntimeError(
'BadArguments',
'Ghost note must have valid initialization data to identify ' + 'duration.'
);
}

super(note_struct);
super(noteStruct);
this.setAttribute('type', 'GhostNote');

// Note properties
Expand Down
6 changes: 3 additions & 3 deletions src/gracenote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ export class GraceNote extends StaveNote {
return 0.66;
}

constructor(note_struct: Partial<GraceNoteStruct>) {
constructor(noteStruct: Partial<GraceNoteStruct>) {
super({
...{
glyph_font_scale: Flow.DEFAULT_NOTATION_FONT_SCALE * GraceNote.SCALE,
stroke_px: GraceNote.LEDGER_LINE_OFFSET,
},
...note_struct,
...noteStruct,
});
this.setAttribute('type', 'GraceNote');

this.slash = note_struct.slash || false;
this.slash = noteStruct.slash || false;
this.slur = true;

this.buildNoteHeads();
Expand Down
4 changes: 2 additions & 2 deletions src/gracetabnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class GraceTabNote extends TabNote {
return 'gracetabnotes';
}

constructor(note_struct: TabNoteStruct) {
super(note_struct, false);
constructor(noteStruct: TabNoteStruct) {
super(noteStruct, false);
this.setAttribute('type', 'GraceTabNote');

this.render_options = {
Expand Down
4 changes: 2 additions & 2 deletions src/stemmablenote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export abstract class StemmableNote extends Note {
protected flag?: Glyph;
protected stem_extension_override?: number;

constructor(note_struct: Partial<NoteStruct>) {
super(note_struct);
constructor(noteStruct: Partial<NoteStruct>) {
super(noteStruct);
this.setAttribute('type', 'StemmableNote');
}

Expand Down
38 changes: 19 additions & 19 deletions tests/stavenote_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function drawBasic(options: TestOptions, contextBuilder: ContextBuilder): void {

const restKeys = [restKey];

const note_structs: StaveNoteStruct[] = [
const noteStructs: StaveNoteStruct[] = [
{ clef: clef, keys: higherKeys, duration: '1/2' },
{ clef: clef, keys: lowerKeys, duration: 'w' },
{ clef: clef, keys: higherKeys, duration: 'h' },
Expand Down Expand Up @@ -390,16 +390,16 @@ function drawBasic(options: TestOptions, contextBuilder: ContextBuilder): void {
{ clef: clef, keys: restKeys, duration: '128r' },
{ keys: ['x/4'], duration: 'h' },
];
expect(note_structs.length * 2);
expect(noteStructs.length * 2);

const colorDescendants = (parentItem: SVGElement, color: string) => () =>
parentItem.querySelectorAll('*').forEach((child) => {
child.setAttribute('fill', color);
child.setAttribute('stroke', color);
});

for (let i = 0; i < note_structs.length; ++i) {
const note = draw(staveNote(note_structs[i]), stave, ctx, (i + 1) * 25);
for (let i = 0; i < noteStructs.length; ++i) {
const note = draw(staveNote(noteStructs[i]), stave, ctx, (i + 1) * 25);

// If this is an interactivity test (ui: true), then attach mouseover & mouseout handlers to the notes.
if (options.params.ui) {
Expand Down Expand Up @@ -432,7 +432,7 @@ function drawBoundingBoxes(options: TestOptions, contextBuilder: ContextBuilder)

const restKeys = [restKey];

const note_structs = [
const noteStructs = [
{ clef: clef, keys: higherKeys, duration: '1/2' },
{ clef: clef, keys: lowerKeys, duration: 'w' },
{ clef: clef, keys: higherKeys, duration: 'h' },
Expand Down Expand Up @@ -463,11 +463,11 @@ function drawBoundingBoxes(options: TestOptions, contextBuilder: ContextBuilder)
{ clef: clef, keys: restKeys, duration: '128r' },
{ keys: ['x/4'], duration: 'h' },
];
expect(note_structs.length * 2);
expect(noteStructs.length * 2);

for (let i = 0; i < note_structs.length; ++i) {
for (let i = 0; i < noteStructs.length; ++i) {
const note = draw(
staveNote(note_structs[i]),
staveNote(noteStructs[i]),
stave,
ctx,
(i + 1) * 25,
Expand All @@ -488,7 +488,7 @@ function drawBass(options: TestOptions, contextBuilder: ContextBuilder): void {
stave.addClef('bass');
stave.draw();

const note_structs: StaveNoteStruct[] = [
const noteStructs: StaveNoteStruct[] = [
{ clef: 'bass', keys: ['c/3', 'e/3', 'a/3'], duration: '1/2' },
{ clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: 'w' },
{ clef: 'bass', keys: ['c/3', 'e/3', 'a/3'], duration: 'h' },
Expand All @@ -512,8 +512,8 @@ function drawBass(options: TestOptions, contextBuilder: ContextBuilder): void {
{ keys: ['x/4'], duration: 'h' },
];

for (let i = 0; i < note_structs.length; ++i) {
const note = draw(staveNote(note_structs[i]), stave, ctx, (i + 1) * 25);
for (let i = 0; i < noteStructs.length; ++i) {
const note = draw(staveNote(noteStructs[i]), stave, ctx, (i + 1) * 25);

ok(note.getX() > 0, 'Note ' + i + ' has X value');
ok(note.getYs().length > 0, 'Note ' + i + ' has Y values');
Expand All @@ -530,7 +530,7 @@ function displacements(options: TestOptions, contextBuilder: ContextBuilder): vo
stave.setContext(ctx);
stave.draw();

const note_structs = [
const noteStructs = [
{ keys: ['g/3', 'a/3', 'c/4', 'd/4', 'e/4'], duration: '1/2' },
{ keys: ['g/3', 'a/3', 'c/4', 'd/4', 'e/4'], duration: 'w' },
{ keys: ['d/4', 'e/4', 'f/4'], duration: 'h' },
Expand All @@ -550,10 +550,10 @@ function displacements(options: TestOptions, contextBuilder: ContextBuilder): vo
stem_direction: Stem.DOWN,
},
];
expect(note_structs.length * 2);
expect(noteStructs.length * 2);

for (let i = 0; i < note_structs.length; ++i) {
const note = draw(staveNote(note_structs[i]), stave, ctx, (i + 1) * 45);
for (let i = 0; i < noteStructs.length; ++i) {
const note = draw(staveNote(noteStructs[i]), stave, ctx, (i + 1) * 45);

ok(note.getX() > 0, 'Note ' + i + ' has X value');
ok(note.getYs().length > 0, 'Note ' + i + ' has Y values');
Expand All @@ -566,7 +566,7 @@ function drawHarmonicAndMuted(options: TestOptions, contextBuilder: ContextBuild
stave.setContext(ctx);
stave.draw();

const note_structs = [
const noteStructs = [
{ keys: ['c/4', 'e/4', 'a/4'], duration: '1/2h' },
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'wh' },
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'hh' },
Expand Down Expand Up @@ -605,10 +605,10 @@ function drawHarmonicAndMuted(options: TestOptions, contextBuilder: ContextBuild
{ keys: ['c/4', 'e/4', 'a/4'], duration: '64m', stem_direction: Stem.DOWN },
{ keys: ['c/4', 'e/4', 'a/4'], duration: '128m', stem_direction: Stem.DOWN },
];
expect(note_structs.length * 2);
expect(noteStructs.length * 2);

for (let i = 0; i < note_structs.length; ++i) {
const note = draw(staveNote(note_structs[i]), stave, ctx, i * 25 + 5);
for (let i = 0; i < noteStructs.length; ++i) {
const note = draw(staveNote(noteStructs[i]), stave, ctx, i * 25 + 5);

ok(note.getX() > 0, 'Note ' + i + ' has X value');
ok(note.getYs().length > 0, 'Note ' + i + ' has Y values');
Expand Down

0 comments on commit cbca85c

Please sign in to comment.