Point: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 3: Line 3:
It is produced by the following commands:
It is produced by the following commands:
<source lang="xml">
<source lang="xml">
<div id="jxgbox" class="jxgbox" style="width:500px; height:200px; float:left; "></div>
<div id="jxgbox" class="jxgbox" style="width:500px; height:200px;"></div>
<script type="text/javascript">
<script type="text/javascript">
  var board = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 100, unitX: 50, unitY: 50});
  var board = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 100, unitX: 50, unitY: 50});
Line 20: Line 20:
  var p = board.createElement('point',[1,1]);
  var p = board.createElement('point',[1,1]);
</script>
</script>
<br clear=all>
</html>
</html>


Line 31: Line 30:


<html>
<html>
<div id="jxgbox2" class="jxgbox" style="width:500px; height:200px; float:left; "></div>
<div id="jxgbox2" class="jxgbox" style="width:500px; height:200px;"></div>
<script type="text/javascript">
<script type="text/javascript">
var b2 = JXG.JSXGraph.initBoard('jxgbox2', {originX: 200, originY: 100, unitX: 50, unitY: 50});
var b2 = JXG.JSXGraph.initBoard('jxgbox2', {originX: 200, originY: 100, unitX: 50, unitY: 50});
var p = b2.createElement('point',[1,1], {name:'X',style:5});
var p = b2.createElement('point',[1,1], {name:'X',style:5});
</script>
</script>
<br clear=all>
</html>
</html>


Line 53: Line 51:


<html>
<html>
<div id="jxgbox3" class="jxgbox" style="width:600px; height:200px; float:left; "></div>
<div id="jxgbox3" class="jxgbox" style="width:600px; height:200px; "></div>
<script type="text/javascript">
<script type="text/javascript">
var b3 = JXG.JSXGraph.initBoard('jxgbox3', {originX: 40, originY: 100, unitX: 40, unitY: 40});
var b3 = JXG.JSXGraph.initBoard('jxgbox3', {originX: 40, originY: 100, unitX: 40, unitY: 40});
Line 61: Line 59:
p.setProperty({fixed:true});
p.setProperty({fixed:true});
</script>
</script>
<br clear=all>
</html>
</html>



Revision as of 09:59, 17 September 2008

Construction of a free point

This example shows how to construct a simple, draggable point. It is produced by the following commands:

<div id="jxgbox" class="jxgbox" style="width:500px; height:200px;"></div>
<script type="text/javascript">
 var board = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 100, unitX: 50, unitY: 50});
 var p = board.createElement('point',[1,1]);
</script>

The JavaScript code has to be placed AFTER the div element which will contain the construction. From now on, we will only show the JavaScript code.

Attributes of a point

Several attributes can be given to change the properties of a point.

var b2 = JXG.JSXGraph.initBoard('jxgbox2', {originX: 200, originY: 100, unitX: 50, unitY: 50});
var p = b2.createElement('point',[1,1], {name:'X',style:5});

Point styles

The property type of a point can attain the values 0..12. In this examples we use a for loop to create 13 points.

var b3 = JXG.JSXGraph.initBoard('jxgbox3', {originX: 40, originY: 100, unitX: 40, unitY: 40});
for (var i=0;i<13;i++) {
  var p = b3.createElement('point',[i,0], {name:'P_{'+i+'}', style:i});
}

After creating the points we set the property fixed of the last point, P_12, to true. I.e. the point is no longer draggable.

p.setProperty({fixed:true});

Construction of a constrained point