Difference between revisions of "Random points"

From JSXGraph Wiki
Jump to: navigation, search
Line 1: Line 1:
 +
===Draw 100 random points===
 
<html>
 
<html>
 
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
 
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
Line 24: Line 25:
  
 
<source lang="javascript">
 
<source lang="javascript">
 +
        board = JXG.JSXGraph.initBoard('box', {originX: 10, originY:390 , unitX:380 , unitY: 380});
 +
               
 +
        function reload() {
 +
            JXG.JSXGraph.freeBoard(board);       
 +
            board = JXG.JSXGraph.initBoard('box', {originX: 10, originY: 390, unitX: 380, unitY: 380});           
 +
 +
            board.suspendUpdate();
 +
            for (var i=0;i<100;i++) {
 +
                var p = board.createElement('point',
 +
                      [Math.random(),Math.random()],{style:5,name:' '});
 +
            }
 +
            board.unsuspendUpdate();
 +
        }
 +
        reload();
 
</source>
 
</source>
  
 +
===Draw 100 random points===
 +
These 100 points are updated on the onmouseover event and get
 +
new random coordinates.
 +
<html>
 +
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
 +
<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>
 +
<form><input type='button' value="Reload" onClick="reload();"></form>
 +
<div id="box2" class="jxgbox" style="width:400px; height:400px;"></div>
 +
<script language="JavaScript">
 +
board2 = JXG.JSXGraph.initBoard('box2', {originX: 10, originY:390 , unitX:380 , unitY: 380});
 +
board2.suspendUpdate();
 +
for (var i=0;i<100;i++) {
 +
  var p = board2.createElement('point',
 +
          [function(){return Math.random();},function(){ return Math.random()}],
 +
          {style:5,name:' '});
 +
}
 +
board.unsuspendUpdate();
 +
</script>
 +
</html>
 +
 +
<source lang="javascript">
 +
</source>
  
 
[[Category:Examples]]
 
[[Category:Examples]]

Revision as of 15:25, 7 December 2008

Draw 100 random points

        board = JXG.JSXGraph.initBoard('box', {originX: 10, originY:390 , unitX:380 , unitY: 380});
                
        function reload() {
            JXG.JSXGraph.freeBoard(board);        
            board = JXG.JSXGraph.initBoard('box', {originX: 10, originY: 390, unitX: 380, unitY: 380});            

            board.suspendUpdate();
            for (var i=0;i<100;i++) {
                var p = board.createElement('point',
                       [Math.random(),Math.random()],{style:5,name:' '});
            }
            board.unsuspendUpdate();
        }
        reload();

Draw 100 random points

These 100 points are updated on the onmouseover event and get new random coordinates.