abcjs-rails 2.0 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/abcjs/api/abc_animation.js +0 -19
- data/app/assets/javascripts/abcjs/api/abc_tunebook.js +0 -5
- data/app/assets/javascripts/abcjs/edit/abc_editor.js +0 -10
- data/app/assets/javascripts/abcjs/parse/abc_parse.js +11 -35
- data/app/assets/javascripts/abcjs/parse/abc_parse_directive.js +2 -18
- data/app/assets/javascripts/abcjs/write/abc_absolute_element.js +9 -25
- data/app/assets/javascripts/abcjs/write/abc_abstract_engraver.js +21 -16
- data/app/assets/javascripts/abcjs/write/abc_beam_element.js +5 -94
- data/app/assets/javascripts/abcjs/write/abc_crescendo_element.js +0 -16
- data/app/assets/javascripts/abcjs/write/abc_decoration.js +3 -2
- data/app/assets/javascripts/abcjs/write/abc_dynamic_decoration.js +0 -8
- data/app/assets/javascripts/abcjs/write/abc_ending_element.js +0 -20
- data/app/assets/javascripts/abcjs/write/abc_engraver_controller.js +1 -1
- data/app/assets/javascripts/abcjs/write/abc_relative_element.js +9 -46
- data/app/assets/javascripts/abcjs/write/abc_renderer.js +1 -1
- data/app/assets/javascripts/abcjs/write/abc_staff_group_element.js +4 -67
- data/app/assets/javascripts/abcjs/write/abc_tie_element.js +0 -24
- data/app/assets/javascripts/abcjs/write/abc_triplet_element.js +0 -54
- data/app/assets/javascripts/abcjs/write/abc_voice_element.js +24 -13
- data/lib/abcjs-rails/version.rb +1 -1
- metadata +2 -4
- data/app/assets/javascripts/abcjs/write/abc_layout.js +0 -1040
- data/app/assets/javascripts/abcjs/write/abc_write.js +0 -535
@@ -247,7 +247,8 @@ ABCJS.write.AbstractEngraver.prototype.createABCElement = function() {
|
|
247
247
|
break;
|
248
248
|
case "part":
|
249
249
|
var abselem = new ABCJS.write.AbsoluteElement(elem,0,0, 'part');
|
250
|
-
|
250
|
+
var dim = this.renderer.getTextSize(elem.title, 'partsfont', "part");
|
251
|
+
abselem.addChild(new ABCJS.write.RelativeElement(elem.title, 0, 0, undefined, {type:"part", height: dim.height/ABCJS.write.spacing.STEP}));
|
251
252
|
elemset[0] = abselem;
|
252
253
|
break;
|
253
254
|
case "tempo":
|
@@ -530,9 +531,9 @@ ABCJS.write.AbstractEngraver.prototype.createNote = function(elem, nostem, dontD
|
|
530
531
|
window.ABCJS.parse.each(elem.lyric, function(ly) {
|
531
532
|
lyricStr += ly.syllable + ly.divider + "\n";
|
532
533
|
});
|
533
|
-
|
534
|
+
var lyricDim = this.renderer.getTextSize(lyricStr, 'vocalfont', "abc-lyric");
|
534
535
|
var position = elem.positioning ? elem.positioning.vocalPosition : 'below';
|
535
|
-
abselem.
|
536
|
+
abselem.addCentered(new ABCJS.write.RelativeElement(lyricStr, 0, lyricDim.width, undefined, {type:"lyric", position: position, height: lyricDim.height / ABCJS.write.spacing.STEP }));
|
536
537
|
}
|
537
538
|
|
538
539
|
if (!dontDraw && elem.gracenotes !== undefined) {
|
@@ -613,48 +614,52 @@ ABCJS.write.AbstractEngraver.prototype.createNote = function(elem, nostem, dontD
|
|
613
614
|
if (dir === 'down') ofs = -ofs;
|
614
615
|
abselem.addChild(new ABCJS.write.RelativeElement(null, ofs-2, ABCJS.write.glyphs.getSymbolWidth(c)+4, additionalLedgers[i], {type:"ledger"}));
|
615
616
|
}
|
616
|
-
|
617
|
+
var chordMargin = 8; // If there are chords next to each other, this is how close they can get.
|
617
618
|
if (elem.chord !== undefined) {
|
618
619
|
for (i = 0; i < elem.chord.length; i++) {
|
619
620
|
var x = 0;
|
620
621
|
var y;
|
622
|
+
var dim = this.renderer.getTextSize(elem.chord[i].name, 'annotationfont', "annotation");
|
623
|
+
var chordWidth = dim.width;
|
624
|
+
var chordHeight = dim.height / ABCJS.write.spacing.STEP;
|
621
625
|
switch (elem.chord[i].position) {
|
622
626
|
case "left":
|
623
|
-
this.roomtaken+=7;
|
627
|
+
this.roomtaken+=chordWidth+7;
|
624
628
|
x = -this.roomtaken; // TODO-PER: This is just a guess from trial and error
|
625
629
|
y = elem.averagepitch;
|
626
|
-
|
627
|
-
abselem.addExtra(new ABCJS.write.RelativeElement(elem.chord[i].name, x, ABCJS.write.glyphs.getSymbolWidth(elem.chord[i].name[0])+4, y, {type:"text"}));
|
630
|
+
abselem.addExtra(new ABCJS.write.RelativeElement(elem.chord[i].name, x, chordWidth+4, y, {type:"text", height: chordHeight}));
|
628
631
|
break;
|
629
632
|
case "right":
|
630
633
|
this.roomtakenright+=4;
|
631
634
|
x = this.roomtakenright;// TODO-PER: This is just a guess from trial and error
|
632
635
|
y = elem.averagepitch;
|
633
|
-
|
634
|
-
abselem.addRight(new ABCJS.write.RelativeElement(elem.chord[i].name, x, ABCJS.write.glyphs.getSymbolWidth(elem.chord[i].name[0])+4, y, {type:"text"}));
|
636
|
+
abselem.addRight(new ABCJS.write.RelativeElement(elem.chord[i].name, x, chordWidth+4, y, {type:"text", height: chordHeight}));
|
635
637
|
break;
|
636
638
|
case "below":
|
637
|
-
// setting the y-coordinate to undefined for now: it will be overwritten later
|
639
|
+
// setting the y-coordinate to undefined for now: it will be overwritten later on, after we figure out what the highest element on the line is.
|
638
640
|
var eachLine = elem.chord[i].name.split("\n");
|
639
641
|
for (var ii = 0; ii < eachLine.length; ii++) {
|
640
|
-
abselem.
|
642
|
+
abselem.addRight(new ABCJS.write.RelativeElement(eachLine[ii], x, chordWidth+chordMargin, undefined, {type:"text", position: "below", height: chordHeight}));
|
641
643
|
}
|
642
644
|
break;
|
643
645
|
case "above":
|
644
|
-
// setting the y-coordinate to undefined for now: it will be overwritten later
|
645
|
-
abselem.
|
646
|
+
// setting the y-coordinate to undefined for now: it will be overwritten later on, after we figure out what the highest element on the line is.
|
647
|
+
abselem.addRight(new ABCJS.write.RelativeElement(elem.chord[i].name, 0, chordWidth+chordMargin, undefined, {type: "text", height: chordHeight}));
|
646
648
|
break;
|
647
649
|
default:
|
648
650
|
if (elem.chord[i].rel_position) {
|
649
651
|
var relPositionY = elem.chord[i].rel_position.y + 3*ABCJS.write.spacing.STEP; // TODO-PER: this is a fudge factor to make it line up with abcm2ps
|
650
|
-
abselem.addChild(new ABCJS.write.RelativeElement(elem.chord[i].name, x + elem.chord[i].rel_position.x, 0, elem.minpitch + relPositionY / ABCJS.write.spacing.STEP, {type: "text"}));
|
652
|
+
abselem.addChild(new ABCJS.write.RelativeElement(elem.chord[i].name, x + elem.chord[i].rel_position.x, 0, elem.minpitch + relPositionY / ABCJS.write.spacing.STEP, {type: "text", height: chordHeight}));
|
651
653
|
} else {
|
652
|
-
// setting the y-coordinate to undefined for now: it will be overwritten later
|
654
|
+
// setting the y-coordinate to undefined for now: it will be overwritten later on, after we figure out what the highest element on the line is.
|
653
655
|
var pos2 = 'above';
|
654
656
|
if (elem.positioning && elem.positioning.chordPosition)
|
655
657
|
pos2 = elem.positioning.chordPosition;
|
656
658
|
|
657
|
-
|
659
|
+
dim = this.renderer.getTextSize(elem.chord[i].name, 'gchordfont', "chord");
|
660
|
+
chordHeight = dim.height / ABCJS.write.spacing.STEP;
|
661
|
+
chordWidth = dim.width; // Since the chord is centered, we only use half the width.
|
662
|
+
abselem.addCentered(new ABCJS.write.RelativeElement(elem.chord[i].name, x, chordWidth, undefined, {type: "chord", position: pos2, height: chordHeight }));
|
658
663
|
}
|
659
664
|
}
|
660
665
|
}
|
@@ -116,6 +116,11 @@ if (!window.ABCJS.write)
|
|
116
116
|
return getBarYAt(beam.startX, beam.startY, beam.endX, beam.endY, midPoint);
|
117
117
|
};
|
118
118
|
|
119
|
+
ABCJS.write.BeamElem.prototype.yAtNote = function(element) {
|
120
|
+
var beam = this.beams[0];
|
121
|
+
return getBarYAt(beam.startX, beam.startY, beam.endX, beam.endY, element.x);
|
122
|
+
};
|
123
|
+
|
119
124
|
ABCJS.write.BeamElem.prototype.xAtMidpoint = function(startX, endX) {
|
120
125
|
return startX + (endX - startX)/2;
|
121
126
|
};
|
@@ -177,7 +182,6 @@ if (!window.ABCJS.write)
|
|
177
182
|
'class': renderer.addClasses('beam-elem')
|
178
183
|
});
|
179
184
|
}
|
180
|
-
<<<<<<< HEAD
|
181
185
|
|
182
186
|
function calcXPos(asc, firstElement, lastElement) {
|
183
187
|
var starthead = firstElement.heads[asc ? 0 : firstElement.heads.length - 1];
|
@@ -207,83 +211,6 @@ if (!window.ABCJS.write)
|
|
207
211
|
} else if (!asc && pos > 6) {
|
208
212
|
startY = 6;
|
209
213
|
endY = 6;
|
210
|
-
=======
|
211
|
-
};
|
212
|
-
|
213
|
-
ABCJS.write.BeamElem.prototype.draw = function(renderer) {
|
214
|
-
if (this.elems.length === 0 || this.allrests) return;
|
215
|
-
this.drawBeam(renderer);
|
216
|
-
this.drawStems(renderer);
|
217
|
-
};
|
218
|
-
|
219
|
-
ABCJS.write.BeamElem.prototype.calcDir = function() {
|
220
|
-
var average = this.average();
|
221
|
-
// var barpos = (this.isgrace)? 5:7;
|
222
|
-
this.asc = (this.forceup || this.isgrace || average<6) && (!this.forcedown); // hardcoded 6 is B
|
223
|
-
return this.asc;
|
224
|
-
};
|
225
|
-
|
226
|
-
ABCJS.write.BeamElem.prototype.drawBeam = function(renderer) {
|
227
|
-
var average = this.average();
|
228
|
-
var barpos = (this.isgrace)? 5:7;
|
229
|
-
this.calcDir();
|
230
|
-
|
231
|
-
var barminpos = this.asc ? 5 : 8; //PER: I just bumped up the minimum height for notes with descending stems to clear a rest in the middle of them.
|
232
|
-
this.pos = Math.round(this.asc ? Math.max(average+barpos,this.max+barminpos) : Math.min(average-barpos,this.min-barminpos));
|
233
|
-
var slant = this.elems[0].abcelem.averagepitch-this.elems[this.elems.length-1].abcelem.averagepitch;
|
234
|
-
if (this.isflat) slant=0;
|
235
|
-
var maxslant = this.elems.length/2;
|
236
|
-
|
237
|
-
if (slant>maxslant) slant = maxslant;
|
238
|
-
if (slant<-maxslant) slant = -maxslant;
|
239
|
-
this.starty = renderer.calcY(this.pos+Math.floor(slant/2));
|
240
|
-
this.endy = renderer.calcY(this.pos+Math.floor(-slant/2));
|
241
|
-
|
242
|
-
var starthead = this.elems[0].heads[(this.asc)? 0: this.elems[0].heads.length-1];
|
243
|
-
var endhead = this.elems[this.elems.length-1].heads[(this.asc)? 0: this.elems[this.elems.length-1].heads.length-1];
|
244
|
-
this.startx = starthead.x;
|
245
|
-
if(this.asc) this.startx+=starthead.w-0.6;
|
246
|
-
this.endx = endhead.x;
|
247
|
-
if(this.asc) this.endx+=endhead.w;
|
248
|
-
|
249
|
-
// PER: if the notes are too high or too low, make the beam go down to the middle
|
250
|
-
if (this.asc && this.pos < 6) {
|
251
|
-
this.starty = renderer.calcY(6);
|
252
|
-
this.endy = renderer.calcY(6);
|
253
|
-
} else if (!this.asc && this.pos > 6) {
|
254
|
-
this.starty = renderer.calcY(6);
|
255
|
-
this.endy = renderer.calcY(6);
|
256
|
-
}
|
257
|
-
|
258
|
-
var pathString = "M"+this.startx+" "+this.starty+" L"+this.endx+" "+this.endy+
|
259
|
-
"L"+this.endx+" "+(this.endy+this.dy) +" L"+this.startx+" "+(this.starty+this.dy)+"z";
|
260
|
-
renderer.printPath({path:pathString, stroke:"none", fill:"#000000", 'class': renderer.addClasses('beam-elem')});
|
261
|
-
};
|
262
|
-
|
263
|
-
ABCJS.write.BeamElem.prototype.drawStems = function(renderer) {
|
264
|
-
var auxbeams = []; // auxbeam will be {x, y, durlog, single} auxbeam[0] should match with durlog=-4 (16th) (j=-4-durlog)
|
265
|
-
renderer.beginGroup();
|
266
|
-
for (var i=0,ii=this.elems.length; i<ii; i++) {
|
267
|
-
if (this.elems[i].abcelem.rest)
|
268
|
-
continue;
|
269
|
-
var furthesthead = this.elems[i].heads[(this.asc)? 0: this.elems[i].heads.length-1];
|
270
|
-
var ovaldelta = (this.isgrace)?1/3:1/5;
|
271
|
-
var pitch = furthesthead.pitch + ((this.asc) ? ovaldelta : -ovaldelta);
|
272
|
-
var y = renderer.calcY(pitch);
|
273
|
-
var x = furthesthead.x + ((this.asc) ? furthesthead.w: 0);
|
274
|
-
var bary=this.getBarYAt(x);
|
275
|
-
var dx = (this.asc) ? -0.6 : 0.6;
|
276
|
-
renderer.printStem(x,dx,y,bary);
|
277
|
-
|
278
|
-
var sy = (this.asc) ? 1.5*ABCJS.write.spacing.STEP: -1.5*ABCJS.write.spacing.STEP;
|
279
|
-
if (this.isgrace) sy = sy*2/3;
|
280
|
-
for (var durlog=ABCJS.write.getDurlog(this.elems[i].abcelem.duration); durlog<-3; durlog++) { // get the duration via abcelem because of triplets
|
281
|
-
if (auxbeams[-4-durlog]) {
|
282
|
-
auxbeams[-4-durlog].single = false;
|
283
|
-
} else {
|
284
|
-
auxbeams[-4-durlog] = {x:x+((this.asc)?-0.6:0), y:bary+sy*(-4-durlog+1),
|
285
|
-
durlog:durlog, single:true};
|
286
|
-
>>>>>>> origin/master
|
287
214
|
}
|
288
215
|
}
|
289
216
|
|
@@ -351,7 +278,6 @@ ABCJS.write.BeamElem.prototype.drawStems = function(renderer) {
|
|
351
278
|
}
|
352
279
|
}
|
353
280
|
|
354
|
-
<<<<<<< HEAD
|
355
281
|
for (var j = auxBeams.length - 1; j >= 0; j--) {
|
356
282
|
if (i === elems.length - 1 || ABCJS.write.getDurlog(elems[i + 1].abcelem.duration) > (-j - 4)) {
|
357
283
|
|
@@ -366,23 +292,8 @@ ABCJS.write.BeamElem.prototype.drawStems = function(renderer) {
|
|
366
292
|
beams.push({ startX: auxBeams[j].x, endX: auxBeamEndX, startY: auxBeams[j].y, endY: auxBeamEndY, dy: dy });
|
367
293
|
auxBeams = auxBeams.slice(0, j);
|
368
294
|
}
|
369
|
-
=======
|
370
|
-
var pathString ="M"+auxbeams[j].x+" "+auxbeams[j].y+" L"+auxbeamendx+" "+auxbeamendy+
|
371
|
-
"L"+auxbeamendx+" "+(auxbeamendy+this.dy) +" L"+auxbeams[j].x+" "+(auxbeams[j].y+this.dy)+"z";
|
372
|
-
renderer.printPath({path:pathString, stroke:"none", fill:"#000000", 'class': renderer.addClasses('beam-elem')});
|
373
|
-
auxbeams = auxbeams.slice(0,j);
|
374
|
-
>>>>>>> origin/master
|
375
295
|
}
|
376
296
|
}
|
377
297
|
return beams;
|
378
298
|
}
|
379
|
-
<<<<<<< HEAD
|
380
299
|
})();
|
381
|
-
=======
|
382
|
-
renderer.endGroup('beam-elem');
|
383
|
-
};
|
384
|
-
|
385
|
-
ABCJS.write.BeamElem.prototype.getBarYAt = function(x) {
|
386
|
-
return this.starty + (this.endy-this.starty)/(this.endx-this.startx)*(x-this.startx);
|
387
|
-
};
|
388
|
-
>>>>>>> origin/master
|
@@ -33,7 +33,6 @@ ABCJS.write.CrescendoElem = function(anchor1, anchor2, dir, positioning) {
|
|
33
33
|
this.pitch = undefined; // This will be set later
|
34
34
|
};
|
35
35
|
|
36
|
-
<<<<<<< HEAD:write/abc_crescendo_element.js
|
37
36
|
ABCJS.write.CrescendoElem.prototype.setUpperAndLowerElements = function(positionY) {
|
38
37
|
if (this.dynamicHeightAbove)
|
39
38
|
this.pitch = positionY.dynamicHeightAbove;
|
@@ -52,26 +51,11 @@ ABCJS.write.CrescendoElem.prototype.draw = function (renderer) {
|
|
52
51
|
} else {
|
53
52
|
this.drawLine(renderer, y, y+height/2);
|
54
53
|
this.drawLine(renderer, y+height, y+height/2);
|
55
|
-
=======
|
56
|
-
ABCJS.write.CrescendoElem.prototype.draw = function (renderer) {
|
57
|
-
if (this.dir === "<") {
|
58
|
-
this.drawLine(renderer, 0, -4);
|
59
|
-
this.drawLine(renderer, 0, 4);
|
60
|
-
} else {
|
61
|
-
this.drawLine(renderer, -4, 0);
|
62
|
-
this.drawLine(renderer, 4, 0);
|
63
|
-
>>>>>>> origin/master:write/abc_cresendo_element.js
|
64
54
|
}
|
65
55
|
};
|
66
56
|
|
67
57
|
ABCJS.write.CrescendoElem.prototype.drawLine = function (renderer, y1, y2) {
|
68
|
-
<<<<<<< HEAD:write/abc_crescendo_element.js
|
69
58
|
var pathString = ABCJS.write.sprintf("M %f %f L %f %f",
|
70
59
|
this.anchor1.x, y1, this.anchor2.x, y2);
|
71
|
-
=======
|
72
|
-
var ypos = renderer.layouter.minY - 7;
|
73
|
-
var pathString = ABCJS.write.sprintf("M %f %f L %f %f",
|
74
|
-
this.anchor1.x, renderer.calcY(ypos)+y1-4, this.anchor2.x, renderer.calcY(ypos)+y2-4);
|
75
|
-
>>>>>>> origin/master:write/abc_cresendo_element.js
|
76
60
|
renderer.printPath({path:pathString, stroke:"#000000", 'class': renderer.addClasses('decoration')});
|
77
61
|
};
|
@@ -164,7 +164,7 @@ if (!window.ABCJS.write)
|
|
164
164
|
var textFudge = 2;
|
165
165
|
var textHeight = 5;
|
166
166
|
// TODO-PER: Get the height of the current font and use that for the thickness.
|
167
|
-
abselem.addChild(new ABCJS.write.RelativeElement(text,
|
167
|
+
abselem.addChild(new ABCJS.write.RelativeElement(text, width/2, 0, y+textFudge, {type:"decoration", klass: 'ornament', thickness: 3}));
|
168
168
|
|
169
169
|
incrementPlacement(placement, textHeight);
|
170
170
|
}
|
@@ -311,9 +311,10 @@ if (!window.ABCJS.write)
|
|
311
311
|
var yPos = closeDecoration(voice, decoration, pitch, width, abselem, roomtaken, dir, minPitch);
|
312
312
|
// yPos is an object containing 'above' and 'below'. That is the placement of the next symbol on either side.
|
313
313
|
|
314
|
+
yPos.above = Math.max(yPos.above, this.minTop);
|
314
315
|
var hasOne = stackedDecoration(decoration, width, abselem, yPos, positioning.ornamentPosition, this.minTop, this.minBottom);
|
315
316
|
if (hasOne) {
|
316
|
-
abselem.top = Math.max(yPos.above + 3, abselem.top); // TODO-PER: Not sure why we need this fudge factor.
|
317
|
+
// abselem.top = Math.max(yPos.above + 3, abselem.top); // TODO-PER: Not sure why we need this fudge factor.
|
317
318
|
}
|
318
319
|
};
|
319
320
|
|
@@ -32,7 +32,6 @@ ABCJS.write.DynamicDecoration = function(anchor, dec, position) {
|
|
32
32
|
this.pitch = undefined; // This will be set later
|
33
33
|
};
|
34
34
|
|
35
|
-
<<<<<<< HEAD
|
36
35
|
ABCJS.write.DynamicDecoration.prototype.setUpperAndLowerElements = function(positionY) {
|
37
36
|
if (this.volumeHeightAbove)
|
38
37
|
this.pitch = positionY.volumeHeightAbove;
|
@@ -46,12 +45,5 @@ ABCJS.write.DynamicDecoration.prototype.draw = function(renderer, linestartx, li
|
|
46
45
|
var scalex = 1;
|
47
46
|
var scaley = 1;
|
48
47
|
renderer.printSymbol(this.anchor.x, this.pitch, this.dec, scalex, scaley, renderer.addClasses('decoration'));
|
49
|
-
=======
|
50
|
-
ABCJS.write.DynamicDecoration.prototype.draw = function(renderer, linestartx, lineendx) {
|
51
|
-
var ypos = renderer.layouter.minY - 7;
|
52
|
-
var scalex = 1; // TODO-PER: do the scaling
|
53
|
-
var scaley = 1;
|
54
|
-
renderer.printSymbol(this.anchor.x, ypos, this.dec, scalex, scaley, renderer.addClasses('decoration'));
|
55
|
-
>>>>>>> origin/master
|
56
48
|
};
|
57
49
|
|
@@ -30,7 +30,6 @@ ABCJS.write.EndingElem = function(text, anchor1, anchor2) {
|
|
30
30
|
this.pitch = undefined; // This will be set later
|
31
31
|
};
|
32
32
|
|
33
|
-
<<<<<<< HEAD
|
34
33
|
ABCJS.write.EndingElem.prototype.setUpperAndLowerElements = function(positionY) {
|
35
34
|
this.pitch = positionY.endingHeightAbove;
|
36
35
|
};
|
@@ -40,44 +39,25 @@ ABCJS.write.EndingElem.prototype.draw = function (renderer, linestartx, lineendx
|
|
40
39
|
window.console.error("Ending Element y-coordinate not set.");
|
41
40
|
var y = renderer.calcY(this.pitch);
|
42
41
|
var height = 20;
|
43
|
-
=======
|
44
|
-
ABCJS.write.EndingElem.prototype.draw = function (renderer, linestartx, lineendx) {
|
45
|
-
>>>>>>> origin/master
|
46
42
|
var pathString;
|
47
43
|
if (this.anchor1) {
|
48
44
|
linestartx = this.anchor1.x+this.anchor1.w;
|
49
45
|
pathString = ABCJS.write.sprintf("M %f %f L %f %f",
|
50
|
-
<<<<<<< HEAD
|
51
46
|
linestartx, y, linestartx, y+height);
|
52
47
|
renderer.printPath({path:pathString, stroke:"#000000", fill:"#000000", 'class': renderer.addClasses('ending')});
|
53
48
|
renderer.renderText(linestartx+5, renderer.calcY(this.pitch-0.5), this.text, 'repeatfont', 'ending',"start");
|
54
|
-
=======
|
55
|
-
linestartx, renderer.y, linestartx, renderer.y+10);
|
56
|
-
renderer.printPath({path:pathString, stroke:"#000000", fill:"#000000", 'class': renderer.addClasses('ending')}); //TODO scale
|
57
|
-
renderer.renderText(linestartx+5, renderer.calcY(18.5), this.text, 'repeatfont', 'ending',"start");
|
58
|
-
>>>>>>> origin/master
|
59
49
|
}
|
60
50
|
|
61
51
|
if (this.anchor2) {
|
62
52
|
lineendx = this.anchor2.x;
|
63
53
|
pathString = ABCJS.write.sprintf("M %f %f L %f %f",
|
64
|
-
<<<<<<< HEAD
|
65
54
|
lineendx, y, lineendx, y+height);
|
66
55
|
renderer.printPath({path:pathString, stroke:"#000000", fill:"#000000", 'class': renderer.addClasses('ending')});
|
67
|
-
=======
|
68
|
-
lineendx, renderer.y, lineendx, renderer.y+10);
|
69
|
-
renderer.printPath({path:pathString, stroke:"#000000", fill:"#000000", 'class': renderer.addClasses('ending')}); // TODO scale
|
70
|
-
>>>>>>> origin/master
|
71
56
|
}
|
72
57
|
|
73
58
|
|
74
59
|
pathString = ABCJS.write.sprintf("M %f %f L %f %f",
|
75
|
-
<<<<<<< HEAD
|
76
60
|
linestartx, y, lineendx, y);
|
77
61
|
renderer.printPath({path:pathString, stroke:"#000000", fill:"#000000", 'class': renderer.addClasses('ending')});
|
78
|
-
=======
|
79
|
-
linestartx, renderer.y, lineendx, renderer.y);
|
80
|
-
renderer.printPath({path:pathString, stroke:"#000000", fill:"#000000", 'class': renderer.addClasses('ending')}); // TODO scale
|
81
|
-
>>>>>>> origin/master
|
82
62
|
};
|
83
63
|
|
@@ -234,7 +234,7 @@ function calcHorizontalSpacing(isLastLine, stretchLast, targetWidth, lineWidth,
|
|
234
234
|
*/
|
235
235
|
ABCJS.write.EngraverController.prototype.setXSpacing = function (staffGroup, formatting, isLastLine) {
|
236
236
|
var newspace = this.space;
|
237
|
-
for (var it = 0; it < 3; it++) { // TODO shouldn't need this triple pass any more
|
237
|
+
for (var it = 0; it < 3; it++) { // TODO-PER: shouldn't need this triple pass any more, but it does slightly affect the coordinates.
|
238
238
|
staffGroup.layout(newspace, this.renderer, false);
|
239
239
|
var stretchLast = formatting.stretchlast ? formatting.stretchlast : false;
|
240
240
|
newspace = calcHorizontalSpacing(isLastLine, stretchLast, this.width+this.renderer.padding.left, staffGroup.w, newspace, staffGroup.spacingunits, staffGroup.minspace);
|
@@ -54,46 +54,38 @@ ABCJS.write.RelativeElement = function(c, dx, w, pitch, opt) {
|
|
54
54
|
// this.top += offset;
|
55
55
|
// this.bottom += offset;
|
56
56
|
//}
|
57
|
+
var height = opt.height ? opt.height : 4; // The +1 is to give a little bit of padding.
|
57
58
|
this.centerVertically = false;
|
58
|
-
// TODO-PER: this should use the current font to determine the height. That requires the font to be passed in here, so refactor to store the font now instead of resolving it at draw time. This will allow the font to be changed mid-line, too.
|
59
|
-
var multiplier;
|
60
59
|
switch (this.type) {
|
61
60
|
case "debug":
|
62
|
-
this.chordHeightAbove =
|
61
|
+
this.chordHeightAbove = height;
|
63
62
|
break;
|
64
63
|
case "lyric":
|
65
|
-
multiplier = this.c.split("\n").length;
|
66
64
|
if (opt.position && opt.position === 'below')
|
67
|
-
this.lyricHeightBelow =
|
65
|
+
this.lyricHeightBelow = height;
|
68
66
|
else
|
69
|
-
this.lyricHeightAbove =
|
67
|
+
this.lyricHeightAbove = height;
|
70
68
|
break;
|
71
69
|
case "chord":
|
72
|
-
multiplier = this.c.split("\n").length;
|
73
70
|
if (opt.position && opt.position === 'below')
|
74
|
-
this.chordHeightBelow =
|
71
|
+
this.chordHeightBelow = height;
|
75
72
|
else
|
76
|
-
this.chordHeightAbove =
|
73
|
+
this.chordHeightAbove = height;
|
77
74
|
break;
|
78
75
|
case "text":
|
79
|
-
multiplier = this.c.split("\n").length;
|
80
76
|
if (this.pitch === undefined) {
|
81
77
|
if (opt.position && opt.position === 'below')
|
82
|
-
this.chordHeightBelow =
|
78
|
+
this.chordHeightBelow = height;
|
83
79
|
else
|
84
|
-
this.chordHeightAbove =
|
80
|
+
this.chordHeightAbove = height;
|
85
81
|
} else
|
86
82
|
this.centerVertically = true;
|
87
83
|
break;
|
88
|
-
case "part": this.partHeightAbove =
|
84
|
+
case "part": this.partHeightAbove = height; break;
|
89
85
|
}
|
90
86
|
};
|
91
87
|
|
92
|
-
<<<<<<< HEAD
|
93
88
|
ABCJS.write.RelativeElement.prototype.setX = function (x) {
|
94
|
-
=======
|
95
|
-
ABCJS.write.RelativeElement.prototype.draw = function (renderer, x, bartop) {
|
96
|
-
>>>>>>> origin/master
|
97
89
|
this.x = x+this.dx;
|
98
90
|
};
|
99
91
|
|
@@ -104,7 +96,6 @@ ABCJS.write.RelativeElement.prototype.draw = function (renderer, bartop) {
|
|
104
96
|
switch(this.type) {
|
105
97
|
case "symbol":
|
106
98
|
if (this.c===null) return null;
|
107
|
-
<<<<<<< HEAD
|
108
99
|
var klass = "symbol";
|
109
100
|
if (this.klass) klass += " " + this.klass;
|
110
101
|
this.graphelem = renderer.printSymbol(this.x, this.pitch, this.c, this.scalex, this.scaley, renderer.addClasses(klass)); break;
|
@@ -132,39 +123,11 @@ ABCJS.write.RelativeElement.prototype.draw = function (renderer, bartop) {
|
|
132
123
|
this.graphelem = renderer.printStem(this.x, this.linewidth, y, (bartop)?bartop:renderer.calcY(this.pitch2)); break; // bartop can't be 0
|
133
124
|
case "stem":
|
134
125
|
this.graphelem = renderer.printStem(this.x, this.linewidth, y, renderer.calcY(this.pitch2)); break;
|
135
|
-
=======
|
136
|
-
this.graphelem = renderer.printSymbol(this.x, this.pitch, this.c, this.scalex, this.scaley, renderer.addClasses('symbol')); break;
|
137
|
-
case "debug":
|
138
|
-
this.graphelem = renderer.renderText(this.x, this.y, this.c, "debugfont", 'debug-msg', 'start'); break;
|
139
|
-
case "barNumber":
|
140
|
-
this.graphelem = renderer.renderText(this.x, renderer.calcY(this.pitch), this.c, "measurefont", 'bar-number', "start");
|
141
|
-
break;
|
142
|
-
case "lyric":
|
143
|
-
this.graphelem = renderer.renderText(this.x, renderer.calcY(renderer.layouter.minY-7), this.c, "vocalfont", 'abc-lyric');
|
144
|
-
break;
|
145
|
-
case "chord":
|
146
|
-
this.graphelem = renderer.renderText(this.x, renderer.calcY(this.pitch), this.c, 'gchordfont', "start", "chord");
|
147
|
-
break;
|
148
|
-
case "text":
|
149
|
-
this.graphelem = renderer.renderText(this.x, renderer.calcY(this.pitch), this.c, 'annotationfont', "start", "annotation");
|
150
|
-
break;
|
151
|
-
case "bar":
|
152
|
-
this.graphelem = renderer.printStem(this.x, this.linewidth, renderer.calcY(this.pitch), (bartop)?bartop:renderer.calcY(this.pitch2)); break; // bartop can't be 0
|
153
|
-
case "stem":
|
154
|
-
this.graphelem = renderer.printStem(this.x, this.linewidth, renderer.calcY(this.pitch), renderer.calcY(this.pitch2)); break;
|
155
|
-
>>>>>>> origin/master
|
156
126
|
case "ledger":
|
157
127
|
this.graphelem = renderer.printStaveLine(this.x, this.x+this.w, this.pitch); break;
|
158
128
|
}
|
159
129
|
if (this.scalex!==1 && this.graphelem) {
|
160
|
-
<<<<<<< HEAD
|
161
130
|
this.graphelem.scale(this.scalex, this.scaley, this.x, y);
|
162
|
-
=======
|
163
|
-
this.graphelem.scale(this.scalex, this.scaley, this.x, renderer.calcY(this.pitch));
|
164
|
-
}
|
165
|
-
if (this.attributes) {
|
166
|
-
this.graphelem.attr(this.attributes);
|
167
|
-
>>>>>>> origin/master
|
168
131
|
}
|
169
132
|
return this.graphelem;
|
170
133
|
};
|