Class jsgl.stroke.DisabledStroke
is a special class that allows you to disabled painting outline of elements.
By default, many JSGL elements come with a default stroke object, which is an jsgl.stroke.SolidStroke
instance of default properties, such as black color, 1px thickness etc.:
var myRect = myPanel.createRectangle(); myPanel.addElement(myRect); myRect.setLocationXY(50,30); myRect.setSizeWH(100,75); myRect.getFill().setColor('#9f9');
The above code produces the following result. Notice the black outline of the rectangle:
In many cases, it is desirable to not paint any outline at all. This is when jsgl.stroke.DisabledStroke
class is useful. You don't have the instantiate the class ā€“ you can the singleton instance, which is accessible via jsgl.stroke.DISABLED
, together with the .setFill()
method of a given element:
myRect.setStroke(jsgl.stroke.DISABLED);
The result is then following (note that the black outline is missing):
Using the jsgl.stroke.DISABLED
object is the most straightforward way to disable painting the outline.
Alternatively, you can turn off the stroke by keeping the default jsgl.stroke.SolidStroke
by calling its .setEnabled()
method:
myRect.getStroke().setEnabled(false);
The result of the above code is equivalent with the difference that the stroke object remains the same (along with all its properties), and can be turned on again later.