【发布时间】:2021-10-09 19:55:04
【问题描述】:
我有一个圆圈和简单的函数 Math.cos(x)
我希望圆圈与该函数相交时被填充(仅填充上侧)。但它不起作用。
脚本:
// circle
var point1 = app.board.create('point', [0,0], {size: 2, strokeWidth:2 })
var point2 = app.board.create('point', [6,0], {size: 2, strokeWidth:2 })
var circle = app.board.create('circle', [point1,point2], {strokeColor: "#f00", strokeWidth: 2 })
// function
var func = app.board.create('functiongraph',[function(x){ return Math.cos(x)}]);
// intersection
var curve = app.board.create('curve', [[], []], {strokeWidth: 0, fillColor: "#09f", fillOpacity: 0.8})
curve.updateDataArray = function() {
var a = JXG.Math.Clip.intersection(circle, func, this.board);
this.dataX = a[0];
this.dataY = a[1]
};
app.board.update()
输出
预期的输出(我是在 Paint 上完成的)
提前谢谢你:)
【问题讨论】:
标签: javascript svg jsxgraph