How can I shade sections of a JSXGraph board?

半城伤御伤魂 提交于 2019-12-24 20:52:26

问题


I have a jsxgraph board set up with a few simple lines, like this:

I want to shade portions of it, for example, the white area between the blue line and the dotted line. What's the best way to go about this? I've looked in the API but none of the provided elements jumped out at me, and I haven't seen any examples so far that do what I'm trying to do. Is the Inequality element easily extendable to multiple lines?


回答1:


You can use a polygon and hide the edges and vertices of the polygon. Here is an example:

    var board = JXG.JSXGraph.initBoard("jxgbox", {
        boundingbox: [-1, 5, 5, -1],
        axis: true
    });

    var p1 = board.create('point', [2, 1]);
    var shade = board.create('polygon', [p1, [0,p1.Y()], [0,4]],
            {
                borders: {visible: false},
                vertices: {visible: false}
            }
        );

If you need to intersect the coordinate axes, you can access them with board.defaultAxes.x and board.defaultAxes.y.



来源:https://stackoverflow.com/questions/47821727/how-can-i-shade-sections-of-a-jsxgraph-board

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!