File size: 1,028 Bytes
af6912c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
var printStaffLine = require('./staff-line');
function printStaff(renderer, startx, endx, numLines, linePitch, dy) {
var klass = "abcjs-top-line";
var pitch = 2;
if (linePitch) {
pitch = linePitch;
}
renderer.paper.openGroup({ prepend: true, klass: renderer.controller.classes.generate("abcjs-staff") });
// If there is one line, it is the B line. Otherwise, the bottom line is the E line.
var firstYLine = 0;
var lastYLine = 0;
if (numLines === 1) {
printStaffLine(renderer, startx, endx, 6, klass, null, dy + renderer.lineThickness);
firstYLine = renderer.calcY(10);
lastYLine = renderer.calcY(2);
} else {
for (var i = numLines - 1; i >= 0; i--) {
var curpitch = (i + 1) * pitch;
lastYLine = renderer.calcY(curpitch);
if (firstYLine === 0) {
firstYLine = lastYLine;
}
printStaffLine(renderer, startx, endx, curpitch, klass, null, dy + renderer.lineThickness);
klass = undefined;
}
}
renderer.paper.closeGroup();
return [firstYLine, lastYLine];
}
module.exports = printStaff;
|