Grouping objects: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<html>
<jsxgraph width="500" height="300" box="jxgbox">
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
var b1 = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-4, 3, 6, -3]});
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/prototype.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<div id="jxgbox" class="jxgbox" style="width:500px; height:300px;"></div>
<script type="text/javascript">
var b1 = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 150, unitX: 50, unitY: 50});
var pArr = [];
var pArr = [];
pArr[0] = b1.createElement('point',[0,0], {name:'A',style:6});
pArr[0] = b1.create('point',[0,0], {size:4});
pArr[1] = b1.createElement('point',[2,1], {name:'B',style:6});
pArr[1] = b1.create('point',[2,1], {size:4});
pArr[2] = b1.createElement('point',[2,2], {name:'C',style:6});
pArr[2] = b1.create('point',[2,2], {size:4});
pArr[3] = b1.createElement('point',[0,1], {name:'D',style:6});
pArr[3] = b1.create('point',[0,1], {size:4});


var poly = b1.createElement('polygon',pArr);
var poly = b1.create('polygon',pArr);
var gr = b1.createElement('group',pArr);
var gr = b1.create('group',pArr);
</script>
</jsxgraph>
</html>


===The underlying JavaScript code===
==The underlying JavaScript code==
<source lang="javascript">
<source lang="javascript">
var b1 = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 150, unitX: 50, unitY: 50});
var b1 = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-4, 3, 6, -3]});
var pArr = [];
var pArr = [];
pArr[0] = b1.createElement('point',[0,0], {name:'A',style:6});
pArr[0] = b1.create('point',[0,0], {size:4});
pArr[1] = b1.createElement('point',[2,1], {name:'B',style:6});
pArr[1] = b1.create('point',[2,1], {size:4});
pArr[2] = b1.createElement('point',[2,2], {name:'C',style:6});
pArr[2] = b1.create('point',[2,2], {size:4});
pArr[3] = b1.createElement('point',[0,1], {name:'D',style:6});
pArr[3] = b1.create('point',[0,1], {size:4});


var poly = b1.createElement('polygon',pArr);
var poly = b1.create('polygon',pArr);
var gr = b1.createElement('group',pArr);
</source>
</source>
The points are grouped together with the following command:
The points are grouped together with the following command:
<source lang="javascript">
<source lang="javascript">
var gr = b1.createElement('group',pArr);
var gr = b1.create('group',pArr);
</source>
</source>




[[Category:Examples]]
[[Category:Examples]]

Latest revision as of 14:34, 7 June 2011

The underlying JavaScript code

var b1 = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-4, 3, 6, -3]});
var pArr = [];
pArr[0] = b1.create('point',[0,0], {size:4});
pArr[1] = b1.create('point',[2,1], {size:4});
pArr[2] = b1.create('point',[2,2], {size:4});
pArr[3] = b1.create('point',[0,1], {size:4});

var poly = b1.create('polygon',pArr);

The points are grouped together with the following command:

var gr = b1.create('group',pArr);