JavaScript Graphics Library (JSGL.org) Draw and move interactive vector graphics easily in Javascript!

Disabled Stroke (class jsgl.stroke.DisabledStroke)

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.

See Also

 
disabled-stroke.txt Ā· Last modified: 2012/09/13 03:15 by Tomas Rehorek
 
Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.3
Driven by DokuWiki Powered by PHP Valid XHTML 1.0 Valid CSS