Intersection of curves II: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 28: | Line 28: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
var board = JXG.JSXGraph.initBoard('jxgbox', { | |||
axis:true, | |||
boundingbox:[-5, 5, 5, -5] | |||
}); | |||
var curve1 = board.create('curve', [ | |||
[-3, 3, 0, -3], | |||
[3, 3, 0, 3] | |||
], | |||
{strokeColor: 'black', fillColor: 'none', fillOpacity: 0.8}); | |||
var curve2 = board.create('polygon', [[3, 4], [-4, 0], [-4, 4]], | |||
{strokeColor: 'blue', fillColor: 'red', fillOpacity: 0.3}); | |||
var clip_path = board.create('curve', [[], []], {strokeWidth: 3, fillColor: 'yellow', fillOpacity: 0.6}); | |||
clip_path.updateDataArray = function() { | |||
var a = JXG.Math.Clip.intersection(curve1, curve2, this.board); | |||
this.dataX = a[0]; | |||
this.dataY = a[1]; | |||
}; | |||
board.update(); | |||
</source> | </source> | ||
[[Category:Examples]] | [[Category:Examples]] | ||
[[Category:Curves]] | [[Category:Curves]] |
Revision as of 09:27, 28 March 2020
The underlying JavaScript code
var board = JXG.JSXGraph.initBoard('jxgbox', {
axis:true,
boundingbox:[-5, 5, 5, -5]
});
var curve1 = board.create('curve', [
[-3, 3, 0, -3],
[3, 3, 0, 3]
],
{strokeColor: 'black', fillColor: 'none', fillOpacity: 0.8});
var curve2 = board.create('polygon', [[3, 4], [-4, 0], [-4, 4]],
{strokeColor: 'blue', fillColor: 'red', fillOpacity: 0.3});
var clip_path = board.create('curve', [[], []], {strokeWidth: 3, fillColor: 'yellow', fillOpacity: 0.6});
clip_path.updateDataArray = function() {
var a = JXG.Math.Clip.intersection(curve1, curve2, this.board);
this.dataX = a[0];
this.dataY = a[1];
};
board.update();