multiple lines

master
Matt Huntington 5 years ago
parent 5cbde05129
commit 27d8aa6d7d

@ -3,6 +3,8 @@ const numBeats = 7;
const beatValue = 8;
const widthPerBeat = 40;
let numBars = 0;
let numBarsOnCurrentLine = 0;
let numLines = 0;
// Create an SVG renderer and attach it to the DIV element named "boo".
const musicSection = document.querySelector("#music");
@ -41,7 +43,7 @@ const returnNewNote = () => {
const createBar = () => {
const staveWidth = numBeats*widthPerBeat;
const stave = new VF.Stave(numBars*staveWidth, 40, staveWidth);
const stave = new VF.Stave(numBarsOnCurrentLine*staveWidth, 40 + (numLines * 150), staveWidth);
// Add a clef and time signature.
if(numBars === 0){
@ -80,8 +82,13 @@ const createBar = () => {
Vex.Flow.Formatter.FormatAndDraw(context, stave, allNotes);
beams.forEach(function(b) {b.setContext(context).draw()})
numBars++;
numBarsOnCurrentLine++;
if(numBarsOnCurrentLine === 4){
numLines++;
numBarsOnCurrentLine = 0;
}
}
for(let i = 0; i < 4; i++){
for(let i = 0; i < 13; i++){
createBar();
}

Loading…
Cancel
Save