jean Mj
unread,Apr 3, 2021, 3:29:06 AM4/3/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to JSXGraph
hello can i have some help showing the union of the circles. I can't seem to have the same colors when I move point A (outline and interior) and then I would also like to remove the interior arc. Thank you in advance.
<script>
$(document).ready(function(){
var jsxgraphUnion = {
board:null,
initGraph:function(id,w,h,box){
$("#"+id).width($("#"+id).parent().width()*0.95>w?w:$("#"+id).parent().width()*0.95);
$("#"+id).height(h);
JXG.joinCurves = function(boards, parents, attributes) {
var cu1 = parents[0], cu2 = parents[1],
attr = JXG.copyAttributes(attributes, boards.options, 'curve'),
c = boards.create('curve', [[0], [0]], attr);
c.updateDataArray = function() {
// The two paths have to be connected
this.dataX = cu1.dataX.slice(0,-1).concat(cu2.dataX);
this.dataY = cu1.dataY.slice(0,-1).concat(cu2.dataY);
if (this.dataX.length<4) {this.bezierDegree = 1;} else {this.bezierDegree = cu1.bezierDegree;}
};
c.prepareUpdate().update().updateRenderer();
return c;
};
this.board = JXG.JSXGraph.initBoard(id, {boundingbox:box,axis:false,showCopyright:false, grid:false,
pan:{enabled:false},zoom:{enabled: false},showNavigation:false});
},
draw:function(){
var p1 = this.board.create('point', [4,3]);
var a1 = this.board.create('circle', [p1,3]);
var p3 = this.board.create('point', [7,3]);
var a2 = this.board.create('circle', [p3,2]);
// Create two intersection points
var i1 = this.board.create('intersection', [a1,a2,0], {visible:false});
var i2 = this.board.create('intersection', [a1,a2,1], {visible:false});
// Create two arcs surrounding the intersection area
var c1 = this.board.create('arc', [p1, i2, i1], {visible:false});
var c2 = this.board.create('arc', [p3, i1, i2], {visible:false});
// Join the two arcs and fill the area.
a1.setAttribute({fillColor:function(){if(p1.Dist(p3)>5) return "green"; else return "white"}, fillOpacity:0.5});
a2.setAttribute({fillColor:function(){if(p1.Dist(p3)>5) return "green"; else return "white"}, fillOpacity:0.5});
var c3 = JXG.joinCurves(this.board, [c1,c2], {strokeColor:'red', strokeWidth:5,fillColor:'green', fillOpacity:0.5});
}
}
jsxgraphUnion.initGraph('boxunion1',850,350,[0,7,12,0]);
jsxgraphUnion.draw();
});
</script>