2

最近我正在绘制算法 gameOfLife。

我发现 JSXGraph 非常方便和有用。我只需要包含库并添加几行来绘制,如下面的最小示例所示。

<!DOCTYPE html>
<html>
<head>
    <title>Ultimate Slot Machine</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
    <script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>

</head>
<body>
    <div id="box" class="jxgbox" style="width:800px; height:800px; margin: 0 auto;"></div>
    <script type="text/javascript">
     var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-10, 10, 10, -10], axis:false, grid:true});

     var p = board.create('point',[-3,1]);

     var q = board.create('point',[-3,1], {face:'x', size:16});
    </script>

</body>
</html>

问题是我不知道如何删除创建的点,我在官方文档中找不到任何参考。

https://jsxgraph.org/docs/symbols/Point.html

https://jsxgraph.org/wiki/index.php/Point

请帮忙。

4

1 回答 1

7

JSXGraph 元素通过调用board.removeObject(object);or被移除board.removeObject([array of objects]);。您的示例如下所示:

 var p = board.create('point',[-3,1]);
 var q = board.create('point',[-3,1], {face:'x', size:16});
 board.removeObject(p);
 board.removeObject(q);
 // or
 board.removeObject([p, q]);
于 2019-06-16T13:59:27.920 回答