App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/res/abc/abc2svg/fit2box-1.js view on Meta::CPAN
}
setparm("pagewidth", wb)
setparm("leftmargin", marg.toFixed(0)) // restore the margins
setparm("rightmargin", marg.toFixed(0))
setparm("pagescale", sc)
setparm("stretchstaff", 1)
setparm("stretchlast", 1)
cfmt.fullsvg = ""
cfmt.trimsvg = 0
// do the last generation
//console.log("---\n"+f.slice(0, 500)+"\n---")
//console.log("-> "+wb+" "+hb+" sc:"+sc.toFixed(3)+" marg:"+marg)
mus.tunes.shift() // remove the tune class
user.img_out = io // restore the normal output
if (abc2svg.fit2box.otosvg) { // restore the tosvg function
mus.tosvg = abc2svg.fit2box.otosvg
abc2svg.fit2box.otosvg = null
}
mus.tosvg(fn, f)
abc2svg.fit2box.on = 0
}, // do_fit()
tosvg: function(of, fn, file, bol, eof) {
var parse = this.get_parse()
parse.fname = fn
parse.file = bol ? file.slice(bol) : file
parse.eol = 0
abc2svg.fit2box.on = 1
abc2svg.fit2box.do_fit(this)
}, // tosvg()
// get a formatting parameter
set_fmt: function(of, cmd, parm) {
if (cmd != "fit2box")
return of(cmd, parm)
if (abc2svg.fit2box.on)
return
abc2svg.fit2box.on = 1
if (!parm) { // stop fit2box
if (abc2svg.fit2box.otosvg) { // restore the tosvg function
this.tosvg = abc2svg.fit2box.otosvg
abc2svg.fit2box.otosvg = null
}
return
}
var cfmt = this.cfmt(),
parse = this.get_parse(),
f = parse.file
cfmt.fit2box = parm.split(/\s+/)
// if no tune yet, change the generation function
if (f.indexOf("X:") < 0) {
if (!abc2svg.fit2box.otosvg) {
abc2svg.fit2box.otosvg = this.tosvg
this.tosvg = abc2svg.fit2box.tosvg.bind(this, this.tosvg)
}
return
}
// do the fit2box generation now
parse.file = parse.file.slice(parse.eol)
parse.eol = 0
abc2svg.fit2box.do_fit(this)
parse.file = f
parse.eol = parse.file.length - 2 // stop the current parsing in tosvg()
}, // set_fmt()
set_hooks: function(abc) {
abc.set_format = abc2svg.fit2box.set_fmt.bind(abc, abc.set_format)
} // set_hooks()
} // fit2box
if (!abc2svg.mhooks)
abc2svg.mhooks = {}
abc2svg.mhooks.fit2box = abc2svg.fit2box.set_hooks
( run in 0.674 second using v1.01-cache-2.11-cpan-2398b32b56e )