App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/res/abc/abc2svg/equalbars-1.js view on Meta::CPAN
w = 0
x = 0
for (i = 0; i < n; i++) {
s = bars[i][0]
if (s.x - x > w)
w = s.x - x
x = s.x
}
if (w * n < width)
width = w * n
this.set_realwidth(width)
}
// set the measure parameters
x = s2.type == C.GRACE ? s2.extra.x : (s2.x - s2.wl)
if (this.equalbars_d < x)
this.equalbars_d = x // new offset of the first note/rest
d = this.equalbars_d
w = (width - d) / (t - t0) // width per time unit
// loop on the bars
for (i = 0; i < n; i++) {
do { // don't shift the 1st note from the bar
if (s2.type == C.GRACE) {
for (g = s2.extra; g; g = g.next)
g.x = d + g.x - x
} else {
s2.x = d + s2.x - x
}
s2 = s2.ts_next
} while (!s2.seqst)
s = bars[i][0]; // next bar
f = w * bars[i][1] / (s.x - x)
// and update the x offsets
for ( ; s2 != s; s2 = s2.ts_next) {
if (s2.type == C.GRACE) {
for (g = s2.extra; g; g = g.next)
g.x = d + (g.x - x) * f
// } else if (s2.x) {
} else {
s2.x = d + (s2.x - x) * f
}
}
d += w * bars[i][1];
x = s2.x
while (1) {
s2.x = d;
s2 = s2.ts_next
if (!s2 || s2.seqst)
break
}
if (!s2)
break
}
}, // set_sym_glue()
set_hooks: function(abc) {
abc.output_music = abc2svg.equalbars.output_music.bind(abc, abc.output_music);
abc.set_format = abc2svg.equalbars.set_fmt.bind(abc, abc.set_format);
abc.set_sym_glue = abc2svg.equalbars.set_sym_glue.bind(abc, abc.set_sym_glue)
}
} // equalbars
if (!abc2svg.mhooks)
abc2svg.mhooks = {}
abc2svg.mhooks.equalbars = abc2svg.equalbars.set_hooks
( run in 0.726 second using v1.01-cache-2.11-cpan-2398b32b56e )