Class jsgl.fill.DisabledFill
is a special class allowing you to easily disable filling of elements.
By default, many JSGL elements come with default fill object, which is an jsgl.fill.SolidFill
instance with color set to white
:
var myRect = myPanel.createRectangle(); myPanel.addElement(myRect); myRect.setLocationXY(50,30); myRect.setSizeWH(100,75); with(myRect.getStroke()) { setColor('green'); setWeight(8); }
When the above code is applied to a panel with non-transparent background holder, by default, the result may look like:
Indeed, there are situations when you don't like the shape to be filled with the default white color. This is when jsgl.fill.DisableFill
class becomes useful. You don't have to instantiate the class ā€“ you can use its singleton instance, which is accessible via jsgl.fill.DISABLED
, together with the .setFill()
method of a given element:
myRect.setFill(jsgl.fill.DISABLED);
Then the result will look like:
Using jsgl.fill.DISABLED
is the most straightforward way. Alternatively, however, you may use the .setEnabled()
method of the default fill object to achieve the same result:
myRect = myPanel.createRectangle(); myPanel.addElement(myRect); myRect.getFill().setEnabled(false);
In this case, the fill object remains the same (along with all its properties), and can later be turned on again.