Search code examples
jsxgraph

The opacity does not cover the objects which are below in Jsxgraph


It seems that opacity:1 doesn't mask what is drawn before the new object. For instance, if I draw a line from a point which is also the center of a circle, I expect that with opacity:1, I will not see the line until the border of the circle.


Solution

  • JSXGraph uses a layer model, see https://jsxgraph.org/wiki/index.php/Working_with_layers. Higher layer means, an element is "above" another element. Otherwise, geometry construction would not be possible. You can either set the layer of an element class globally, as in the example, like

    JXG.Options.layer.point = 7;
    JXG.Options.layer.line = 9;
    

    or set it on case by case basis:

    var line = board.create('line', [...], {layer: 9});