Controlling brightness within a widget? (drawLayer related)

Hello!

I’m hoping to make my cellular automaton look cool with low room light settings. The widget paints both a background grid plus some active cells. I’m hoping to take advantage of the new brightness settings in rack. I’ve been successful in overriding the drawLayer method for the widget. It looks like this with a darkened background:

Here you can see the same idea with room brightness turned all the way off:

My question is: Is there a way for me to read the room brightness so that I can fine-tune the background grid color? Similarly, is there a way to read the light bloom value?

Thanks in advance. :bowing_man:

1 Like

settings::haloBrightness can be used to determine the halo brightness.

Are you trying you dim the grid when the room brightness is turned down?

1 Like

Yes, that’s exactly what I’m hoping to do. I hope to dim the grid so that only the bright squares appear. And I’m also hoping to figure out a way to add a halo effect to the bright squares based on the settings::haloBrightness and general room brightness. :slight_smile:

Note to self: settings::rackBrightness is the room brightness (see VCV Rack API: rack::settings Namespace Reference)

If your widget is a ModuleLightWidget, try moving the drawing of the grid to drawBackground, that should hide the grid when the lights are out. Then, for the halo, make sure you have the ModuleLightWidgets color set. The drawHalo function checks the color and if it is black, it does nothing.

You could draw the background of the grid in the draw method, and the active cells in the drawLayer method. Irrespective of whether or not it’s a ModuleLightWidget.

The background will be drawn, then the room darkening layer is applied, then the drawLayer(… 1) method is called to draw the illuminated parts.

If you want to fine tune things, you could draw the background in the draw method, and then draw it again with a degree of transparency in the drawLayer method. Which is what I’ve done in this example:

FullBright FullDark

The draw method has a white rectangle.

The drawLayer method has the same rectangle with a white → transparent gradient, and then also the scale and needle.

3 Likes

Thanks really clever. I’ll probably take that approach. :smiley: