Difference between revisions of "Random points"

From JSXGraph Wiki
Jump to: navigation, search
Line 53: Line 53:
 
  board2.suspendUpdate();
 
  board2.suspendUpdate();
 
  for (var i=0;i<50;i++) {
 
  for (var i=0;i<50;i++) {
/*
+
   var p2 = board2.createElement('point',
   var p = board2.createElement('point',
 
 
           [function(){return Math.random();},function(){ return Math.random()}],
 
           [function(){return Math.random();},function(){ return Math.random()}],
 
           {style:5,name:' '});
 
           {style:5,name:' '});
*/
 
 
  }
 
  }
 
  board2.unsuspendUpdate();
 
  board2.unsuspendUpdate();

Revision as of 16:33, 7 December 2008

Draw 50 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<50;i++) {
                var p = board.createElement('point',
                       [Math.random(),Math.random()],{style:5,name:' '});
            }
            board.unsuspendUpdate();
        }
        reload();

Draw 50 random points

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