Difference between revisions of "Grouping objects"

From JSXGraph Wiki
Jump to navigationJump to search
 
(8 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>
+
var pArr = [];
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
+
pArr[0] = b1.create('point',[0,0], {size:4});
<div id="jxgbox" class="jxgbox" style="width:500px; height:300px;"></div>
+
pArr[1] = b1.create('point',[2,1], {size:4});
<script type="text/javascript">
+
pArr[2] = b1.create('point',[2,2], {size:4});
var b1 = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 150, unitX: 50, unitY: 50});
+
pArr[3] = b1.create('point',[0,1], {size:4});
var p = [];
 
p[0] = b1.createElement('point',[0,0], {name:'A',style:6});
 
p[1] = b1.createElement('point',[2,1], {name:'B',style:6});
 
p[2] = b1.createElement('point',[2,2], {name:'C',style:6});
 
p[3] = b1.createElement('point',[0,1], {name:'D',style:6});
 
  
var poly = b1.createElement('polygon',p);
+
var poly = b1.create('polygon',pArr);
var g = new JXG.Group('','',p);
+
var gr = b1.create('group',pArr);
</script>
+
</jsxgraph>
</html>
 
  
 +
==The underlying JavaScript code==
 +
<source lang="javascript">
 +
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);
 +
</source>
 +
The points are grouped together with the following command:
 +
<source lang="javascript">
 +
var gr = b1.create('group',pArr);
 +
</source>
  
  
 
[[Category:Examples]]
 
[[Category:Examples]]

Latest revision as of 16: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);