Random points: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 45: | Line 45: | ||
new random coordinates. | new random coordinates. | ||
<html> | <html> | ||
<div id="box2" class="jxgbox" style="width:400px; height:400px;" onmouseover="board2.update()"></div> | <div id="box2" class="jxgbox" style="width:400px; height:400px;" onmouseover="board2.update()"></div> | ||
<script language="JavaScript"> | <script language="JavaScript"> | ||
Line 60: | Line 57: | ||
</script> | </script> | ||
</html> | </html> | ||
<source lang="html4strict"> | |||
<div id="box2" class="jxgbox" style="width:400px; height:400px;" onmouseover="board2.update()"></div> | |||
</source> | |||
<source lang="javascript"> | <source lang="javascript"> | ||
board2 = JXG.JSXGraph.initBoard('box2', {originX: 10, originY:390 , unitX:380 , unitY: 380}); | |||
board2.suspendUpdate(); | |||
for (var i=0;i<50;i++) { | |||
var p2 = board2.createElement('point', | |||
[function(){return Math.random();},function(){ return Math.random()}], | |||
{style:5,name:' '}); | |||
} | |||
board2.unsuspendUpdate(); | |||
</source> | </source> | ||
[[Category:Examples]] | [[Category:Examples]] |
Revision as of 14:35, 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.
<div id="box2" class="jxgbox" style="width:400px; height:400px;" onmouseover="board2.update()"></div>
board2 = JXG.JSXGraph.initBoard('box2', {originX: 10, originY:390 , unitX:380 , unitY: 380});
board2.suspendUpdate();
for (var i=0;i<50;i++) {
var p2 = board2.createElement('point',
[function(){return Math.random();},function(){ return Math.random()}],
{style:5,name:' '});
}
board2.unsuspendUpdate();