diff --git a/src/Exsurge.Chant.ChantLine.js b/src/Exsurge.Chant.ChantLine.js index abbb3c4..fa404b5 100644 --- a/src/Exsurge.Chant.ChantLine.js +++ b/src/Exsurge.Chant.ChantLine.js @@ -226,7 +226,7 @@ export class ChantLine extends ChantLayoutElement { canvasCtxt.translate(-this.bounds.x, -this.bounds.y); } - createSvgFragment(ctxt) { + createSvgFragment(ctxt, top = 0) { var inner = ""; // add the chant lines @@ -291,7 +291,7 @@ export class ChantLine extends ChantLayoutElement { return QuickSvg.createFragment('g', { 'class': 'chantLine', - 'transform': 'translate(' + this.bounds.x + ',' + this.bounds.y + ')' + 'transform': 'translate(' + this.bounds.x + ',' + (this.bounds.y - top) + ')' }, inner); } diff --git a/src/Exsurge.Chant.js b/src/Exsurge.Chant.js index 0fff14a..819fd40 100644 --- a/src/Exsurge.Chant.js +++ b/src/Exsurge.Chant.js @@ -592,6 +592,36 @@ export class ChantScore { return fragment; } + createSvgForEachLine(ctxt) { + + var fragment = "", + fragmentDefs = ""; + + // create defs section + for (var def in ctxt.defs) + if (ctxt.defs.hasOwnProperty(def)) + fragmentDefs += ctxt.defs[def]; + + fragmentDefs = QuickSvg.createFragment('defs', {}, fragmentDefs); + var top = 0; + for (var i = 0; i < this.lines.length; i++) { + var lineFragment = fragmentDefs + this.lines[i].createSvgFragment(ctxt, top); + var height = this.lines[i].bounds.height + ctxt.staffInterval * 1.5; + lineFragment = QuickSvg.createFragment('g', {}, lineFragment); + lineFragment = QuickSvg.createFragment('svg', { + 'xmlns': 'http://www.w3.org/2000/svg', + 'version': '1.1', + 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + 'class': 'ChantScore', + 'width': this.bounds.width, + 'height': height + }, lineFragment); + fragment += lineFragment; + top += height; + } + return fragment; + } + unserializeFromJson(data) { this.autoColoring = data['auto-coloring'];