abcjs-rails 1.11 → 2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/abcjs/api/abc_animation.js +41 -1
- data/app/assets/javascripts/abcjs/api/abc_tunebook.js +5 -0
- data/app/assets/javascripts/abcjs/data/abc_tune.js +4 -3
- data/app/assets/javascripts/abcjs/edit/abc_editor.js +10 -0
- data/app/assets/javascripts/abcjs/parse/abc_parse.js +120 -19
- data/app/assets/javascripts/abcjs/parse/abc_parse_directive.js +456 -115
- data/app/assets/javascripts/abcjs/raphael.js +2 -2
- data/app/assets/javascripts/abcjs/write/abc_absolute_element.js +111 -4
- data/app/assets/javascripts/abcjs/write/abc_abstract_engraver.js +899 -0
- data/app/assets/javascripts/abcjs/write/abc_beam_element.js +263 -37
- data/app/assets/javascripts/abcjs/write/abc_create_clef.js +76 -0
- data/app/assets/javascripts/abcjs/write/abc_create_key_signature.js +41 -0
- data/app/assets/javascripts/abcjs/write/abc_create_time_signature.js +51 -0
- data/app/assets/javascripts/abcjs/write/{abc_cresendo_element.js → abc_crescendo_element.js} +32 -1
- data/app/assets/javascripts/abcjs/write/abc_decoration.js +321 -0
- data/app/assets/javascripts/abcjs/write/abc_dynamic_decoration.js +22 -1
- data/app/assets/javascripts/abcjs/write/abc_ending_element.js +31 -1
- data/app/assets/javascripts/abcjs/write/abc_engraver_controller.js +359 -0
- data/app/assets/javascripts/abcjs/write/abc_glyphs.js +119 -9
- data/app/assets/javascripts/abcjs/write/abc_layout.js +2 -2
- data/app/assets/javascripts/abcjs/write/abc_relative_element.js +106 -8
- data/app/assets/javascripts/abcjs/write/abc_renderer.js +754 -0
- data/app/assets/javascripts/abcjs/write/abc_staff_group_element.js +249 -9
- data/app/assets/javascripts/abcjs/write/abc_tempo_element.js +104 -0
- data/app/assets/javascripts/abcjs/write/abc_tie_element.js +69 -22
- data/app/assets/javascripts/abcjs/write/abc_triplet_element.js +77 -10
- data/app/assets/javascripts/abcjs/write/abc_voice_element.js +100 -8
- data/app/assets/javascripts/abcjs/write/abc_write.js +64 -68
- data/lib/abcjs-rails/version.rb +1 -1
- metadata +12 -4
@@ -0,0 +1,51 @@
|
|
1
|
+
// abc_create_time_signature.js
|
2
|
+
// Copyright (C) 2010,2015 Gregory Dyke (gregdyke at gmail dot com) and Paul Rosen
|
3
|
+
//
|
4
|
+
// This program is free software: you can redistribute it and/or modify
|
5
|
+
// it under the terms of the GNU General Public License as published by
|
6
|
+
// the Free Software Foundation, either version 3 of the License, or
|
7
|
+
// (at your option) any later version.
|
8
|
+
//
|
9
|
+
// This program is distributed in the hope that it will be useful,
|
10
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
// GNU General Public License for more details.
|
13
|
+
//
|
14
|
+
// You should have received a copy of the GNU General Public License
|
15
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
/*globals ABCJS */
|
18
|
+
|
19
|
+
if (!window.ABCJS)
|
20
|
+
window.ABCJS = {};
|
21
|
+
|
22
|
+
if (!window.ABCJS.write)
|
23
|
+
window.ABCJS.write = {};
|
24
|
+
|
25
|
+
(function() {
|
26
|
+
"use strict";
|
27
|
+
|
28
|
+
ABCJS.write.createTimeSignature = function(elem) {
|
29
|
+
var abselem = new ABCJS.write.AbsoluteElement(elem,0,10, 'staff-extra');
|
30
|
+
if (elem.type === "specified") {
|
31
|
+
//TODO make the alignment for time signatures centered
|
32
|
+
for (var i = 0; i < elem.value.length; i++) {
|
33
|
+
if (i !== 0)
|
34
|
+
abselem.addRight(new ABCJS.write.RelativeElement('+', i*20-9, ABCJS.write.glyphs.getSymbolWidth("+"), 6, { thickness: ABCJS.write.glyphs.symbolHeightInPitches("+") }));
|
35
|
+
if (elem.value[i].den) {
|
36
|
+
// TODO-PER: get real widths here, also center the num and den.
|
37
|
+
abselem.addRight(new ABCJS.write.RelativeElement(elem.value[i].num, i*20, ABCJS.write.glyphs.getSymbolWidth(elem.value[i].num.charAt(0))*elem.value[i].num.length, 8, { thickness: ABCJS.write.glyphs.symbolHeightInPitches(elem.value[i].num.charAt(0)) }));
|
38
|
+
abselem.addRight(new ABCJS.write.RelativeElement(elem.value[i].den, i*20, ABCJS.write.glyphs.getSymbolWidth(elem.value[i].den.charAt(0))*elem.value[i].den.length, 4, { thickness: ABCJS.write.glyphs.symbolHeightInPitches(elem.value[i].den.charAt(0)) }));
|
39
|
+
} else {
|
40
|
+
abselem.addRight(new ABCJS.write.RelativeElement(elem.value[i].num, i*20, ABCJS.write.glyphs.getSymbolWidth(elem.value[i].num.charAt(0))*elem.value[i].num.length, 6, { thickness: ABCJS.write.glyphs.symbolHeightInPitches(elem.value[i].num.charAt(0)) }));
|
41
|
+
}
|
42
|
+
}
|
43
|
+
} else if (elem.type === "common_time") {
|
44
|
+
abselem.addRight(new ABCJS.write.RelativeElement("timesig.common", 0, ABCJS.write.glyphs.getSymbolWidth("timesig.common"), 6, { thickness: ABCJS.write.glyphs.symbolHeightInPitches("timesig.common") }));
|
45
|
+
|
46
|
+
} else if (elem.type === "cut_time") {
|
47
|
+
abselem.addRight(new ABCJS.write.RelativeElement("timesig.cut", 0, ABCJS.write.glyphs.getSymbolWidth("timesig.cut"), 6, { thickness: ABCJS.write.glyphs.symbolHeightInPitches("timesig.cut") }));
|
48
|
+
}
|
49
|
+
return abselem;
|
50
|
+
};
|
51
|
+
})();
|
data/app/assets/javascripts/abcjs/write/{abc_cresendo_element.js → abc_crescendo_element.js}
RENAMED
@@ -22,12 +22,37 @@ if (!window.ABCJS)
|
|
22
22
|
if (!window.ABCJS.write)
|
23
23
|
window.ABCJS.write = {};
|
24
24
|
|
25
|
-
ABCJS.write.CrescendoElem = function(anchor1, anchor2, dir) {
|
25
|
+
ABCJS.write.CrescendoElem = function(anchor1, anchor2, dir, positioning) {
|
26
26
|
this.anchor1 = anchor1; // must have a .x and a .parent property or be null (means starts at the "beginning" of the line - after keysig)
|
27
27
|
this.anchor2 = anchor2; // must have a .x property or be null (means ends at the end of the line)
|
28
28
|
this.dir = dir; // either "<" or ">"
|
29
|
+
if (positioning === 'above')
|
30
|
+
this.dynamicHeightAbove = 4;
|
31
|
+
else
|
32
|
+
this.dynamicHeightBelow = 4;
|
33
|
+
this.pitch = undefined; // This will be set later
|
29
34
|
};
|
30
35
|
|
36
|
+
<<<<<<< HEAD:write/abc_crescendo_element.js
|
37
|
+
ABCJS.write.CrescendoElem.prototype.setUpperAndLowerElements = function(positionY) {
|
38
|
+
if (this.dynamicHeightAbove)
|
39
|
+
this.pitch = positionY.dynamicHeightAbove;
|
40
|
+
else
|
41
|
+
this.pitch = positionY.dynamicHeightBelow;
|
42
|
+
};
|
43
|
+
|
44
|
+
ABCJS.write.CrescendoElem.prototype.draw = function (renderer) {
|
45
|
+
if (this.pitch === undefined)
|
46
|
+
window.console.error("Crescendo Element y-coordinate not set.");
|
47
|
+
var y = renderer.calcY(this.pitch) + 4; // This is the top pixel to use (it is offset a little so that it looks good with the volume marks.)
|
48
|
+
var height = 8;
|
49
|
+
if (this.dir === "<") {
|
50
|
+
this.drawLine(renderer, y+height/2, y);
|
51
|
+
this.drawLine(renderer, y+height/2, y+height);
|
52
|
+
} else {
|
53
|
+
this.drawLine(renderer, y, y+height/2);
|
54
|
+
this.drawLine(renderer, y+height, y+height/2);
|
55
|
+
=======
|
31
56
|
ABCJS.write.CrescendoElem.prototype.draw = function (renderer) {
|
32
57
|
if (this.dir === "<") {
|
33
58
|
this.drawLine(renderer, 0, -4);
|
@@ -35,12 +60,18 @@ ABCJS.write.CrescendoElem.prototype.draw = function (renderer) {
|
|
35
60
|
} else {
|
36
61
|
this.drawLine(renderer, -4, 0);
|
37
62
|
this.drawLine(renderer, 4, 0);
|
63
|
+
>>>>>>> origin/master:write/abc_cresendo_element.js
|
38
64
|
}
|
39
65
|
};
|
40
66
|
|
41
67
|
ABCJS.write.CrescendoElem.prototype.drawLine = function (renderer, y1, y2) {
|
68
|
+
<<<<<<< HEAD:write/abc_crescendo_element.js
|
69
|
+
var pathString = ABCJS.write.sprintf("M %f %f L %f %f",
|
70
|
+
this.anchor1.x, y1, this.anchor2.x, y2);
|
71
|
+
=======
|
42
72
|
var ypos = renderer.layouter.minY - 7;
|
43
73
|
var pathString = ABCJS.write.sprintf("M %f %f L %f %f",
|
44
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
|
45
76
|
renderer.printPath({path:pathString, stroke:"#000000", 'class': renderer.addClasses('decoration')});
|
46
77
|
};
|
@@ -0,0 +1,321 @@
|
|
1
|
+
// abc_decoration.js: Creates a data structure suitable for printing a line of abc
|
2
|
+
// Copyright (C) 2010-2015 Gregory Dyke (gregdyke at gmail dot com) & Paul Rosen
|
3
|
+
//
|
4
|
+
// This program is free software: you can redistribute it and/or modify
|
5
|
+
// it under the terms of the GNU General Public License as published by
|
6
|
+
// the Free Software Foundation, either version 3 of the License, or
|
7
|
+
// (at your option) any later version.
|
8
|
+
//
|
9
|
+
// This program is distributed in the hope that it will be useful,
|
10
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
// GNU General Public License for more details.
|
13
|
+
//
|
14
|
+
// You should have received a copy of the GNU General Public License
|
15
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
/*global window, ABCJS */
|
18
|
+
|
19
|
+
if (!window.ABCJS)
|
20
|
+
window.ABCJS = {};
|
21
|
+
|
22
|
+
if (!window.ABCJS.write)
|
23
|
+
window.ABCJS.write = {};
|
24
|
+
|
25
|
+
(function() {
|
26
|
+
"use strict";
|
27
|
+
|
28
|
+
ABCJS.write.Decoration = function() {
|
29
|
+
this.startDiminuendoX = undefined;
|
30
|
+
this.startCrescendoX = undefined;
|
31
|
+
this.minTop = 12; // TODO-PER: this is assuming a 5-line staff. Pass that info in.
|
32
|
+
this.minBottom = 0;
|
33
|
+
};
|
34
|
+
|
35
|
+
var closeDecoration = function(voice, decoration, pitch, width, abselem, roomtaken, dir, minPitch) {
|
36
|
+
var yPos;
|
37
|
+
for (var i=0;i<decoration.length; i++) {
|
38
|
+
if (decoration[i]==="staccato" || decoration[i]==="tenuto" || decoration[i] === "accent") {
|
39
|
+
var symbol = "scripts." + decoration[i];
|
40
|
+
if (decoration[i] === "accent") symbol = "scripts.sforzato";
|
41
|
+
if (yPos === undefined)
|
42
|
+
yPos = (dir==="down") ? pitch+2:minPitch-2;
|
43
|
+
else
|
44
|
+
yPos = (dir==="down") ? yPos+2:yPos-2;
|
45
|
+
if (decoration[i] === "accent") {
|
46
|
+
// Always place the accent three pitches away, no matter whether that is a line or space.
|
47
|
+
if (dir === "up") yPos--;
|
48
|
+
else yPos++;
|
49
|
+
} else {
|
50
|
+
// don't place on a stave line. The stave lines are 2,4,6,8,10
|
51
|
+
switch (yPos) {
|
52
|
+
case 2:
|
53
|
+
case 4:
|
54
|
+
case 6:
|
55
|
+
case 8:
|
56
|
+
case 10:
|
57
|
+
if (dir === "up") yPos--;
|
58
|
+
else yPos++;
|
59
|
+
break;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
if (pitch>9) yPos++; // take up some room of those that are above
|
63
|
+
var deltaX = width/2;
|
64
|
+
if (ABCJS.write.glyphs.getSymbolAlign(symbol)!=="center") {
|
65
|
+
deltaX -= (ABCJS.write.glyphs.getSymbolWidth(symbol)/2);
|
66
|
+
}
|
67
|
+
abselem.addChild(new ABCJS.write.RelativeElement(symbol, deltaX, ABCJS.write.glyphs.getSymbolWidth(symbol), yPos));
|
68
|
+
}
|
69
|
+
if (decoration[i]==="slide" && abselem.heads[0]) {
|
70
|
+
var yPos2 = abselem.heads[0].pitch;
|
71
|
+
yPos2 -= 2; // TODO-PER: not sure what this fudge factor is.
|
72
|
+
var blank1 = new ABCJS.write.RelativeElement("", -roomtaken-15, 0, yPos2-1);
|
73
|
+
var blank2 = new ABCJS.write.RelativeElement("", -roomtaken-5, 0, yPos2+1);
|
74
|
+
abselem.addChild(blank1);
|
75
|
+
abselem.addChild(blank2);
|
76
|
+
voice.addOther(new ABCJS.write.TieElem(blank1, blank2, false, false, false));
|
77
|
+
}
|
78
|
+
}
|
79
|
+
if (yPos === undefined)
|
80
|
+
yPos = pitch;
|
81
|
+
|
82
|
+
return { above: yPos, below: abselem.bottom };
|
83
|
+
};
|
84
|
+
|
85
|
+
var volumeDecoration = function(voice, decoration, abselem, positioning) {
|
86
|
+
for (var i=0;i<decoration.length; i++) {
|
87
|
+
switch(decoration[i]) {
|
88
|
+
case "p":
|
89
|
+
case "mp":
|
90
|
+
case "pp":
|
91
|
+
case "ppp":
|
92
|
+
case "pppp":
|
93
|
+
case "f":
|
94
|
+
case "ff":
|
95
|
+
case "fff":
|
96
|
+
case "ffff":
|
97
|
+
case "sfz":
|
98
|
+
case "mf":
|
99
|
+
var elem = new ABCJS.write.DynamicDecoration(abselem, decoration[i], positioning);
|
100
|
+
voice.addOther(elem);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
};
|
104
|
+
|
105
|
+
var compoundDecoration = function(decoration, pitch, width, abselem, dir) {
|
106
|
+
function highestPitch() {
|
107
|
+
if (abselem.heads.length === 0)
|
108
|
+
return 10; // TODO-PER: I don't know if this can happen, but we'll return the top of the staff if so.
|
109
|
+
var pitch = abselem.heads[0].pitch;
|
110
|
+
for (var i = 1; i < abselem.heads.length; i++)
|
111
|
+
pitch = Math.max(pitch, abselem.heads[i].pitch);
|
112
|
+
return pitch;
|
113
|
+
}
|
114
|
+
function lowestPitch() {
|
115
|
+
if (abselem.heads.length === 0)
|
116
|
+
return 2; // TODO-PER: I don't know if this can happen, but we'll return the bottom of the staff if so.
|
117
|
+
var pitch = abselem.heads[0].pitch;
|
118
|
+
for (var i = 1; i < abselem.heads.length; i++)
|
119
|
+
pitch = Math.min(pitch, abselem.heads[i].pitch);
|
120
|
+
return pitch;
|
121
|
+
}
|
122
|
+
function compoundDecoration(symbol, count) {
|
123
|
+
var placement = (dir === 'down') ? lowestPitch()+1:highestPitch()+9;
|
124
|
+
var deltaX = width/2;
|
125
|
+
deltaX += (dir === 'down') ? -5 : 3;
|
126
|
+
for (var i = 0; i < count; i++) {
|
127
|
+
placement -= 1;
|
128
|
+
abselem.addChild(new ABCJS.write.RelativeElement(symbol, deltaX, ABCJS.write.glyphs.getSymbolWidth(symbol), placement));
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
for (var i=0;i<decoration.length; i++) {
|
133
|
+
switch(decoration[i]) {
|
134
|
+
case "/": compoundDecoration("flags.ugrace", 1); break;
|
135
|
+
case "//": compoundDecoration("flags.ugrace", 2); break;
|
136
|
+
case "///": compoundDecoration("flags.ugrace", 3); break;
|
137
|
+
case "////": compoundDecoration("flags.ugrace", 4); break;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
142
|
+
var stackedDecoration = function(decoration, width, abselem, yPos, positioning, minTop, minBottom) {
|
143
|
+
function incrementPlacement(placement, height) {
|
144
|
+
if (placement === 'above')
|
145
|
+
yPos.above += height;
|
146
|
+
else
|
147
|
+
yPos.below -= height;
|
148
|
+
}
|
149
|
+
function getPlacement(placement) {
|
150
|
+
var y;
|
151
|
+
if (placement === 'above') {
|
152
|
+
y = yPos.above;
|
153
|
+
if (y < minTop)
|
154
|
+
y = minTop;
|
155
|
+
} else {
|
156
|
+
y = yPos.below;
|
157
|
+
if (y > minBottom)
|
158
|
+
y = minBottom;
|
159
|
+
}
|
160
|
+
return y;
|
161
|
+
}
|
162
|
+
function textDecoration(text, placement) {
|
163
|
+
var y = getPlacement(placement);
|
164
|
+
var textFudge = 2;
|
165
|
+
var textHeight = 5;
|
166
|
+
// TODO-PER: Get the height of the current font and use that for the thickness.
|
167
|
+
abselem.addChild(new ABCJS.write.RelativeElement(text, 0, 0, y+textFudge, {type:"decoration", klass: 'ornament', thickness: 3}));
|
168
|
+
|
169
|
+
incrementPlacement(placement, textHeight);
|
170
|
+
}
|
171
|
+
function symbolDecoration(symbol, placement) {
|
172
|
+
var deltaX = width/2;
|
173
|
+
if (ABCJS.write.glyphs.getSymbolAlign(symbol) !== "center") {
|
174
|
+
deltaX -= (ABCJS.write.glyphs.getSymbolWidth(symbol) / 2);
|
175
|
+
}
|
176
|
+
var height = ABCJS.write.glyphs.symbolHeightInPitches(symbol) + 1; // adding a little padding so nothing touches.
|
177
|
+
var y = getPlacement(placement);
|
178
|
+
y = (placement === 'above') ? y + height/2 : y - height/2;// Center the element vertically.
|
179
|
+
abselem.addChild(new ABCJS.write.RelativeElement(symbol, deltaX, ABCJS.write.glyphs.getSymbolWidth(symbol), y, { klass: 'ornament', thickness: ABCJS.write.glyphs.symbolHeightInPitches(symbol) }));
|
180
|
+
|
181
|
+
incrementPlacement(placement, height);
|
182
|
+
}
|
183
|
+
|
184
|
+
var symbolList = {
|
185
|
+
"+": "scripts.stopped",
|
186
|
+
"open": "scripts.open",
|
187
|
+
"snap": "scripts.snap",
|
188
|
+
"wedge": "scripts.wedge",
|
189
|
+
"thumb": "scripts.thumb",
|
190
|
+
"shortphrase": "scripts.shortphrase",
|
191
|
+
"mediumphrase": "scripts.mediumphrase",
|
192
|
+
"longphrase": "scripts.longphrase",
|
193
|
+
"trill": "scripts.trill",
|
194
|
+
"roll": "scripts.roll",
|
195
|
+
"irishroll": "scripts.roll",
|
196
|
+
"marcato": "scripts.umarcato",
|
197
|
+
"dmarcato": "scripts.dmarcato",
|
198
|
+
"umarcato": "scripts.umarcato",
|
199
|
+
"turn": "scripts.turn",
|
200
|
+
"uppermordent": "scripts.prall",
|
201
|
+
"pralltriller": "scripts.prall",
|
202
|
+
"mordent": "scripts.mordent",
|
203
|
+
"lowermordent": "scripts.mordent",
|
204
|
+
"downbow": "scripts.downbow",
|
205
|
+
"upbow": "scripts.upbow",
|
206
|
+
"fermata": "scripts.ufermata",
|
207
|
+
"invertedfermata": "scripts.dfermata",
|
208
|
+
"breath": ",",
|
209
|
+
"coda": "scripts.coda",
|
210
|
+
"segno": "scripts.segno"
|
211
|
+
};
|
212
|
+
|
213
|
+
var hasOne = false;
|
214
|
+
for (var i=0;i<decoration.length; i++) {
|
215
|
+
switch(decoration[i]) {
|
216
|
+
case "0":
|
217
|
+
case "1":
|
218
|
+
case "2":
|
219
|
+
case "3":
|
220
|
+
case "4":
|
221
|
+
case "5":
|
222
|
+
case "D.C.":
|
223
|
+
case "D.S.":
|
224
|
+
textDecoration(decoration[i], positioning);
|
225
|
+
hasOne = true;
|
226
|
+
break;
|
227
|
+
case "fine":
|
228
|
+
textDecoration("FINE", positioning);
|
229
|
+
hasOne = true;
|
230
|
+
break;
|
231
|
+
case "+":
|
232
|
+
case "open":
|
233
|
+
case "snap":
|
234
|
+
case "wedge":
|
235
|
+
case "thumb":
|
236
|
+
case "shortphrase":
|
237
|
+
case "mediumphrase":
|
238
|
+
case "longphrase":
|
239
|
+
case "trill":
|
240
|
+
case "roll":
|
241
|
+
case "irishroll":
|
242
|
+
case "marcato":
|
243
|
+
case "dmarcato":
|
244
|
+
case "turn":
|
245
|
+
case "uppermordent":
|
246
|
+
case "pralltriller":
|
247
|
+
case "mordent":
|
248
|
+
case "lowermordent":
|
249
|
+
case "downbow":
|
250
|
+
case "upbow":
|
251
|
+
case "fermata":
|
252
|
+
case "breath":
|
253
|
+
case "umarcato":
|
254
|
+
case "coda":
|
255
|
+
case "segno":
|
256
|
+
symbolDecoration(symbolList[decoration[i]], positioning);
|
257
|
+
hasOne = true;
|
258
|
+
break;
|
259
|
+
case "invertedfermata":
|
260
|
+
symbolDecoration(symbolList[decoration[i]], 'below');
|
261
|
+
hasOne = true;
|
262
|
+
break;
|
263
|
+
case "mark":
|
264
|
+
abselem.klass = "mark";
|
265
|
+
break;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
return hasOne;
|
269
|
+
};
|
270
|
+
|
271
|
+
ABCJS.write.Decoration.prototype.dynamicDecoration = function(voice, decoration, abselem, positioning) {
|
272
|
+
var diminuendo;
|
273
|
+
var crescendo;
|
274
|
+
for (var i=0;i<decoration.length; i++) {
|
275
|
+
switch(decoration[i]) {
|
276
|
+
case "diminuendo(":
|
277
|
+
this.startDiminuendoX = abselem;
|
278
|
+
diminuendo = undefined;
|
279
|
+
break;
|
280
|
+
case "diminuendo)":
|
281
|
+
diminuendo = { start: this.startDiminuendoX, stop: abselem};
|
282
|
+
this.startDiminuendoX = undefined;
|
283
|
+
break;
|
284
|
+
case "crescendo(":
|
285
|
+
this.startCrescendoX = abselem;
|
286
|
+
crescendo = undefined;
|
287
|
+
break;
|
288
|
+
case "crescendo)":
|
289
|
+
crescendo = { start: this.startCrescendoX, stop: abselem};
|
290
|
+
this.startCrescendoX = undefined;
|
291
|
+
break;
|
292
|
+
}
|
293
|
+
}
|
294
|
+
if (diminuendo) {
|
295
|
+
voice.addOther(new ABCJS.write.CrescendoElem(diminuendo.start, diminuendo.stop, ">", positioning));
|
296
|
+
}
|
297
|
+
if (crescendo) {
|
298
|
+
voice.addOther(new ABCJS.write.CrescendoElem(crescendo.start, crescendo.stop, "<", positioning));
|
299
|
+
}
|
300
|
+
};
|
301
|
+
|
302
|
+
ABCJS.write.Decoration.prototype.createDecoration = function(voice, decoration, pitch, width, abselem, roomtaken, dir, minPitch, positioning, hasVocals) {
|
303
|
+
if (!positioning)
|
304
|
+
positioning = { ornamentPosition: 'above', volumePosition: hasVocals ? 'above' :'below', dynamicPosition: hasVocals ? 'above' : 'below' };
|
305
|
+
// These decorations don't affect the placement of other decorations
|
306
|
+
volumeDecoration(voice, decoration, abselem, positioning.volumePosition);
|
307
|
+
this.dynamicDecoration(voice, decoration, abselem, positioning.dynamicPosition);
|
308
|
+
compoundDecoration(decoration, pitch, width, abselem, dir);
|
309
|
+
|
310
|
+
// treat staccato, accent, and tenuto first (may need to shift other markers)
|
311
|
+
var yPos = closeDecoration(voice, decoration, pitch, width, abselem, roomtaken, dir, minPitch);
|
312
|
+
// yPos is an object containing 'above' and 'below'. That is the placement of the next symbol on either side.
|
313
|
+
|
314
|
+
var hasOne = stackedDecoration(decoration, width, abselem, yPos, positioning.ornamentPosition, this.minTop, this.minBottom);
|
315
|
+
if (hasOne) {
|
316
|
+
abselem.top = Math.max(yPos.above + 3, abselem.top); // TODO-PER: Not sure why we need this fudge factor.
|
317
|
+
}
|
318
|
+
};
|
319
|
+
|
320
|
+
})();
|
321
|
+
|
@@ -22,15 +22,36 @@ if (!window.ABCJS)
|
|
22
22
|
if (!window.ABCJS.write)
|
23
23
|
window.ABCJS.write = {};
|
24
24
|
|
25
|
-
ABCJS.write.DynamicDecoration = function(anchor, dec) {
|
25
|
+
ABCJS.write.DynamicDecoration = function(anchor, dec, position) {
|
26
26
|
this.anchor = anchor;
|
27
27
|
this.dec = dec;
|
28
|
+
if (position === 'below')
|
29
|
+
this.volumeHeightBelow = 5;
|
30
|
+
else
|
31
|
+
this.volumeHeightAbove = 5;
|
32
|
+
this.pitch = undefined; // This will be set later
|
28
33
|
};
|
29
34
|
|
35
|
+
<<<<<<< HEAD
|
36
|
+
ABCJS.write.DynamicDecoration.prototype.setUpperAndLowerElements = function(positionY) {
|
37
|
+
if (this.volumeHeightAbove)
|
38
|
+
this.pitch = positionY.volumeHeightAbove;
|
39
|
+
else
|
40
|
+
this.pitch = positionY.volumeHeightBelow;
|
41
|
+
};
|
42
|
+
|
43
|
+
ABCJS.write.DynamicDecoration.prototype.draw = function(renderer, linestartx, lineendx) {
|
44
|
+
if (this.pitch === undefined)
|
45
|
+
window.console.error("Dynamic Element y-coordinate not set.");
|
46
|
+
var scalex = 1;
|
47
|
+
var scaley = 1;
|
48
|
+
renderer.printSymbol(this.anchor.x, this.pitch, this.dec, scalex, scaley, renderer.addClasses('decoration'));
|
49
|
+
=======
|
30
50
|
ABCJS.write.DynamicDecoration.prototype.draw = function(renderer, linestartx, lineendx) {
|
31
51
|
var ypos = renderer.layouter.minY - 7;
|
32
52
|
var scalex = 1; // TODO-PER: do the scaling
|
33
53
|
var scaley = 1;
|
34
54
|
renderer.printSymbol(this.anchor.x, ypos, this.dec, scalex, scaley, renderer.addClasses('decoration'));
|
55
|
+
>>>>>>> origin/master
|
35
56
|
};
|
36
57
|
|