Skip to content

Commit

Permalink
Minor cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfe committed Apr 21, 2020
1 parent 00ec15c commit f4753d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
2 changes: 0 additions & 2 deletions src/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ export class Formatter {
});
}


function shiftToIdealDistances(idealDistances) {
// Distribute ticks to the contexts based on the calculated distance error.
const centerX = adjustedJustifyWidth / 2;
Expand Down Expand Up @@ -597,7 +596,6 @@ export class Formatter {
return lastContext.getX() - firstContext.getX();
}


const adjustedJustifyWidth = justifyWidth -
lastContext.getMetrics().notePx -
lastContext.getMetrics().totalRightPx -
Expand Down
41 changes: 8 additions & 33 deletions tests/formatter_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,16 +518,12 @@ VF.Test.Formatter = (function() {
title: '460px,softmax:100'
}];

// Configure the rendering context.

var adjX = 11;
var rowSize = 140;
var beats = 12;
var beatsPer = 8;
var beamGroup = 3;

var durations = ['8d', '16', '8', '8d', '16', '8', '8d', '16', '8', '4', '8'];

var beams = [];
var y = 40;

Expand All @@ -539,13 +535,8 @@ VF.Test.Formatter = (function() {
y += rowSize;

durations.forEach((dd) => {
var newNote = new VF.StaveNote({
keys: ['b/4'],
duration: dd
});
if (dd.indexOf('d') >= 0) {
newNote.addDotToAll();
}
var newNote = new VF.StaveNote({ keys: ['b/4'], duration: dd });
if (dd.indexOf('d') >= 0) { newNote.addDotToAll(); }
if (sm.lyrics.length > iii) {
newNote.addAnnotation(0,
new VF.Annotation(sm.lyrics[iii])
Expand All @@ -556,11 +547,9 @@ VF.Test.Formatter = (function() {
iii += 1;
});

notes.forEach((note) => {
if (note.duration.indexOf('d') >= 0) {
note.addDotToAll();
}
});
notes.forEach((note) => { if (note.duration.indexOf('d') >= 0) { note.addDotToAll(); } });

// Don't beam the last group
var beam = [];
notes.forEach((note) => {
if (note.intrinsicTicks < 4096) {
Expand All @@ -576,28 +565,14 @@ VF.Test.Formatter = (function() {
}
});

var voice1 = new VF.Voice({
num_beats: beats,
beat_value: beatsPer
}).setMode(Vex.Flow.Voice.Mode.SOFT).addTickables(notes);

var fmt = new VF.Formatter({
softmaxFactor: sm.sm
}).joinVoices([voice1]);

fmt.format([voice1], sm.width - adjX);
var voice1 = new VF.Voice({ num_beats: beats, beat_value: beatsPer }).setMode(Vex.Flow.Voice.Mode.SOFT).addTickables(notes);

var group = context.openGroup();
group.id = 'mm-' + sm.sm;
var fmt = new VF.Formatter({ softmaxFactor: sm.sm }).joinVoices([voice1]);
fmt.format([voice1], sm.width - 11);


// Connect it to the rendering context and draw!
stave.setContext(context).draw();

voice1.draw(context, stave);

context.closeGroup();

beams.forEach(function(b) {
b.setContext(context).draw();
});
Expand Down

0 comments on commit f4753d3

Please sign in to comment.