0xfe / vexflow

A JavaScript library for rendering music notation and guitar tablature.

Home Page:http://www.vexflow.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to set the background color for individual staves?

the-drunk-coder opened this issue · comments

Hi,

as the title says, I was wondering whether it's possible to set the background color for individual staves? I'm rendering to SVG.

I've tried something like:

//...
context.save();
context.setBackgroundFillStyle("yellow");

// draw stave and notes
//...
context.restore();

but it has no effect.

Best,
N

Have you tried it using css, using nth-child() specification? The context will affect all the lines.

hmm but how would I find out the index ?

Sorry, I misread this. I thought you wanted to color individual stave lines.

SVG doesn't really have 'background color'. You would need to draw a rectangle with the fill color you want, where your stave is going to be drawn. You would do this before you render the stave. That should get the effect of a background color. You should be able to use svg context rectangle to do this.

oh yes that works, thanks ... if anyone's interested, here's a fiddle for how to draw SVG rectangles:
https://jsfiddle.net/kzbwg/