App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/res/abc/abc2svg/grid-1.js view on Meta::CPAN
tsfirst = this.get_tsfirst(),
fmt = tsfirst.fmt,
voice_tb = this.get_voice_tb(),
p_v = voice_tb[this.get_top_v()],
s = {
type: C.BLOCK,
subtype: 'grid',
dur: 0,
time: 0,
p_v: p_v,
v: p_v.v,
st: p_v.st
}
if (!cfmt.gridfont)
abc.param_set_font("gridfont", "serif 16")
abc.set_font('grid')
build_chords(s) // build the array of the chords
// and insert it in the tune
if (!s.chords) { // if no chord
;
} else if (grid.nomusic) { // if just the grid
this.set_tsfirst(s)
} else if (grid.n < 0) { // below
for (var s2 = tsfirst; s2.ts_next; s2 = s2.ts_next)
;
s.time = s2.time
s.prev = p_v.last_sym.prev // before the last symbol
s.prev.next = s
s.next = p_v.last_sym
p_v.last_sym.prev = s
s.ts_prev = s2.ts_prev
s.ts_prev.ts_next = s
s.ts_next = s2
s2.ts_prev = s
if (s2.seqst) {
s.seqst = true
s2.seqst = false
}
} else { // above
s.next = p_v.sym
s.ts_next = tsfirst
tsfirst.ts_prev = s
this.set_tsfirst(s)
p_v.sym.prev = s
p_v.sym = s
}
s.fmt = s.prev ? s.prev.fmt : fmt
}
of()
}, // set_stems()
set_fmt: function(of, cmd, parm) {
if (cmd == "grid") {
if (!parm)
parm = "1";
parm = parm.split(/\s+/)
var grid = {n: Number(parm.shift())}
if (isNaN(grid.n)) {
if (parm.length) {
this.syntax(1, this.errs.bad_val, "%%grid")
return
}
grid.n = 1
}
while (parm.length) {
var item = parm.shift()
if (item == "norepeat")
grid.norep = true
else if (item == "nomusic")
grid.nomusic = true
else if (item == "parts")
grid.parts = true
else if (item == "repbrk")
grid.repbrk = true
else if (item.slice(0, 8) == "include=")
grid.ls = item.slice(8).split(',')
}
this.cfmt().grid = grid
return
}
of(cmd, parm)
},
set_hooks: function(abc) {
abc.block_gen = abc2svg.grid.block_gen.bind(abc, abc.block_gen)
abc.set_stems = abc2svg.grid.set_stems.bind(abc, abc.set_stems)
abc.set_format = abc2svg.grid.set_fmt.bind(abc, abc.set_format)
}
} // grid
if (!abc2svg.mhooks)
abc2svg.mhooks = {}
abc2svg.mhooks.grid = abc2svg.grid.set_hooks
( run in 1.596 second using v1.01-cache-2.11-cpan-140bd7fdf52 )