Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added function to make an svg for each chant system rather than a sin… #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Exsurge.Chant.ChantLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
30 changes: 30 additions & 0 deletions src/Exsurge.Chant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down