Infinity: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 1: Line 1:
== Just enjoy this construction... ==
== Just enjoy this construction... ==
<source lang="javascript">
</source>
<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 44: Line 42:
</script>  
</script>  
</html>
</html>
<source lang="javascript">
var board = JXG.JSXGraph.initBoard('jxgbox', {originX: 300, originY: 300, unitX: 50, unitY: 50})
var S = board.createElement('slider', [-5,-6,10,0,1,0.5], {name:'S'});
var points = new Array();
points[0] = board.createElement('point',[5, 5], {name:' '});
points[1] = board.createElement('point',[-5, 5], {name:' '});
points[2] = board.createElement('point',[-5, -5], {name:' '});
points[3] = board.createElement('point',[5, -5], {name:' '});
function viereck(pt, n) {
  var arr = new Array();
  for(var i = 0; i < 4; i++) {
  arr[i] = board.createElement('point',
        [function(t) {
            return function () {var x = pt[t].X();
                                var x1 = pt[(t+1)%4].X();
                                var s = S.X();
                                return x+(x1-x)*s;
                        }}(i),
          function(t) {
            return function () {var y = pt[t].Y();
                                var y1 = pt[(t+1)%4].Y();
                                var s = S.X();
                                return y+(y1-y)*s;
                        }}(i)
          ],
          {style:3, name:" "});
}
board.createElement('polygon',pt, {fillColor: '#5555'+n+''+n});
if(n>0)
viereck(arr, --n);
  }
  board.suspendUpdate();
  viereck(points,30);
  board.unsuspendUpdate();
</source>

Revision as of 16:53, 28 November 2008

Just enjoy this construction...

 var board = JXG.JSXGraph.initBoard('jxgbox', {originX: 300, originY: 300, unitX: 50, unitY: 50})
 var S = board.createElement('slider', [-5,-6,10,0,1,0.5], {name:'S'});
 var points = new Array();
 points[0] = board.createElement('point',[5, 5], {name:' '});	
 points[1] = board.createElement('point',[-5, 5], {name:' '});	
 points[2] = board.createElement('point',[-5, -5], {name:' '});	
 points[3] = board.createElement('point',[5, -5], {name:' '});	
	 		 	
 function viereck(pt, n) {
  var arr = new Array();
  for(var i = 0; i < 4; i++) {
   arr[i] = board.createElement('point', 
         [function(t) {
            return function () {var x = pt[t].X(); 
                                var x1 = pt[(t+1)%4].X(); 
                                var s = S.X();
                                return x+(x1-x)*s;
                         }}(i), 
          function(t) {
            return function () {var y = pt[t].Y(); 
                                var y1 = pt[(t+1)%4].Y(); 
                                var s = S.X();
                                return y+(y1-y)*s;
                         }}(i)
          ], 
          {style:3, name:" "});
	 			}
	 			board.createElement('polygon',pt, {fillColor: '#5555'+n+''+n});
	 			if(n>0)
	 				viereck(arr, --n);
  }
  board.suspendUpdate();
  viereck(points,30);
  board.unsuspendUpdate();