Drawing a line grid into a panel with LAF
-
How would I go about drawing a grid of 11 horizontal lines filing an entire panel's height?
As a scale to put behind sliders like e.g a Juno has.I did some experiments with paint routine according to Dave's videos but it got me nowhere ;(
const var Grid1 = Content.getComponent("Grid1"); Grid1.setPaintRoutine(function(g) { var a = this.getLocalBounds(0); var spacer = a[3]/10; //g.fillAll(this.get("bgColour")); g.setColour(Colours.white); for (i=0;i<=10;i++) { var y = i * spacer; g.fillRect([0,y,a[2],y+2]); } });
I just get a weird block with one line on top... probably a thinking mistake on my end but I can't figure it out
Also how would I wrap the routine into someting I can assign to other panels aswell?
-
M Morphoice deleted this topic on
-
M Morphoice restored this topic on
-
@Morphoice You'll find these useful
-
@d-healey yep that's exactly what my script is based of ;)) However, I now realize it should be 2 not y+2 as the forth parameter is a height not a position I guess ;)
-
@Morphoice Yeah,
[x y, width, height]
. Soa[3]
for the full height of the panel. -
@d-healey brilliant! again without you and your videos I'd be nothing!
this is what I came up with in the end:
const var Grid1 = Content.getComponent("Grid1"); Grid1.setPaintRoutine(function(g) { drawPandelGrid(); }); inline function drawPandelGrid() { local a = this.getLocalBounds(0); local spacer = a[3]/10; //g.fillAll(this.get("bgColour")); g.setColour(Colours.withAlpha(Colours.white, 0.1)); for (i=0;i<=10;i++) { local y = i * spacer; g.fillRect([0,y,a[2],2]); } }
and it gives a nice panel of lines to go behind my faders