| 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 |
if (typeof abc2svg == "undefined") |
| 27 |
var abc2svg = {} |
| 28 |
|
| 29 |
abc2svg.grid2 = { |
| 30 |
|
| 31 |
|
| 32 |
do_grid: function() { |
| 33 |
var s, v, p_v, ix, cs, c_a_cs, bt, gch, |
| 34 |
voice_tb = this.get_voice_tb() |
| 35 |
|
| 36 |
if (this.cfmt().grid2) |
| 37 |
for (v = 0; v < voice_tb.length; v++) |
| 38 |
if (voice_tb[v].grid2 == undefined) |
| 39 |
voice_tb[v].grid2 = 1 |
| 40 |
|
| 41 |
for (v = 0; v < voice_tb.length; v++) { |
| 42 |
p_v = voice_tb[v] |
| 43 |
if (!p_v.grid2) |
| 44 |
continue |
| 45 |
this.set_curvoice(p_v) |
| 46 |
this.set_v_param("stafflines", "...") |
| 47 |
p_v.clef.invis = true; |
| 48 |
p_v.clef.clef_none = 1 |
| 49 |
p_v.key.k_sf = 0 |
| 50 |
delete p_v.key.k_a_acc |
| 51 |
p_v.staffnonote = 2 |
| 52 |
for (s = p_v.sym; s; s = s.next) { |
| 53 |
delete s.a_dd |
| 54 |
if (!s.dur) { |
| 55 |
if (s.bar_type) |
| 56 |
bt = s.time |
| 57 |
continue |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
s.invis = true; |
| 62 |
delete s.sl1; |
| 63 |
delete s.ti1 |
| 64 |
delete s.ti2 |
| 65 |
for (ix = 0; ix <= s.nhd; ix++) |
| 66 |
delete s.notes[ix].tie_ty |
| 67 |
if (s.tf) |
| 68 |
s.tf[0] = 1 |
| 69 |
if (!s.a_gch) { |
| 70 |
if (s.time == bt) |
| 71 |
s.a_gch = [ this.clone(c_a_cs) ] |
| 72 |
continue |
| 73 |
} |
| 74 |
for (ix = 0; ix < s.a_gch.length; ix++) { |
| 75 |
gch = s.a_gch[ix] |
| 76 |
if (gch.type == 'g') { |
| 77 |
c_a_cs = gch |
| 78 |
break |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
}, |
| 84 |
|
| 85 |
|
| 86 |
set_w: function(of, s) { |
| 87 |
of(s) |
| 88 |
if (!s.p_v || !s.p_v.grid2 |
| 89 |
|| !s.a_gch |
| 90 |
|| ((!s.prev || s.prev.invis) |
| 91 |
&& (!s.next || s.next.invis))) |
| 92 |
return |
| 93 |
var i, gch |
| 94 |
|
| 95 |
for (i = 0; i < s.a_gch.length; i++) { |
| 96 |
gch = s.a_gch[i] |
| 97 |
if (gch.type == 'g') { |
| 98 |
if (s.wl < -gch.x) |
| 99 |
s.wl = -gch.x |
| 100 |
if (s.wr < gch.text.wh[0]) |
| 101 |
s.wr = gch.text.wh[0] |
| 102 |
break |
| 103 |
} |
| 104 |
} |
| 105 |
}, |
| 106 |
|
| 107 |
|
| 108 |
draw_gchord: function(of, i, s, x, y) { |
| 109 |
var an |
| 110 |
if (s.p_v.grid2) { |
| 111 |
this.set_dscale(s.st) |
| 112 |
an = s.a_gch[i] |
| 113 |
if (an.type == 'g') { |
| 114 |
this.use_font(an.font) |
| 115 |
this.set_font(an.font) |
| 116 |
this.xy_str(s.x + an.x, 12 - an.font.size * .5, |
| 117 |
an.text) |
| 118 |
} |
| 119 |
} else { |
| 120 |
of(i, s, x, y) |
| 121 |
} |
| 122 |
}, |
| 123 |
|
| 124 |
output_music: function(of) { |
| 125 |
abc2svg.grid2.do_grid.call(this); |
| 126 |
of() |
| 127 |
}, |
| 128 |
|
| 129 |
set_fmt: function(of, cmd, param) { |
| 130 |
if (cmd == "grid2") { |
| 131 |
var curvoice = this.get_curvoice(), |
| 132 |
v = this.get_bool(param) |
| 133 |
|
| 134 |
if (curvoice) |
| 135 |
curvoice.grid2 = v |
| 136 |
else |
| 137 |
this.cfmt().grid2 = v |
| 138 |
return |
| 139 |
} |
| 140 |
of(cmd, param) |
| 141 |
}, |
| 142 |
|
| 143 |
set_hooks: function(abc) { |
| 144 |
abc.draw_gchord = abc2svg.grid2.draw_gchord.bind(abc, abc.draw_gchord); |
| 145 |
abc.output_music = abc2svg.grid2.output_music.bind(abc, abc.output_music); |
| 146 |
abc.set_format = abc2svg.grid2.set_fmt.bind(abc, abc.set_format) |
| 147 |
abc.set_width = abc2svg.grid2.set_w.bind(abc, abc.set_width) |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
if (!abc2svg.mhooks) |
| 152 |
abc2svg.mhooks = {} |
| 153 |
abc2svg.mhooks.grid2 = abc2svg.grid2.set_hooks |