Reflect images: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 10: Line 10:


   // Define two line through four points
   // Define two line through four points
   p0 = board.createElement('point', [0,3]);  
   p0 = brd.createElement('point', [0,3]);  
   p1 = board.createElement('point', [1,1]);  
   p1 = brd.createElement('point', [1,1]);  
   p2 = board.createElement('point', [-3,4]);  
   p2 = brd.createElement('point', [-3,4]);  
   p3 = board.createElement('point', [10,4]);  
   p3 = brd.createElement('point', [10,4]);  


   l1 = board.createElement('line', [p0, p1]);  
   l1 = brd.createElement('line', [p0, p1]);  
   l2 = board.createElement('line', [p2, p3]);  
   l2 = brd.createElement('line', [p2, p3]);  


   p4 = board.createElement('point', [-2,-2]);  
   p4 = brd.createElement('point', [-2,-2]);  
   p5 = board.createElement('point', [1,0]);  
   p5 = brd.createElement('point', [1,0]);  


   X = function(){ return Math.min(p4.X(), p5.X()); };
   X = function(){ return Math.min(p4.X(), p5.X()); };
Line 26: Line 26:
   H = function(){ return Math.abs(p5.Y() -p4.Y()); };
   H = function(){ return Math.abs(p5.Y() -p4.Y()); };


   im1 = board.create('image',[imurl, [X, Y], [W, H]], {opacity:0.7});  
   im1 = brd.create('image',[imurl, [X, Y], [W, H]], {opacity:0.7});  
   im2 = board.create('image',[imurl, [X, Y], [W, H]], {opacity:0.7});  
   im2 = brd.create('image',[imurl, [X, Y], [W, H]], {opacity:0.7});  
   im3 = board.create('image',[imurl, [X, Y], [W, H]], {opacity:0.7});  
   im3 = brd.create('image',[imurl, [X, Y], [W, H]], {opacity:0.7});  


   t1 = board.createElement('transform', [l1], {type:'reflect'});
   t1 = brd.createElement('transform', [l1], {type:'reflect'});
   t2 = board.createElement('transform', [l2], {type:'reflect'});
   t2 = brd.createElement('transform', [l2], {type:'reflect'});


   // Reflect im2 on l1
   // Reflect im2 on l1
Line 40: Line 40:
   t2.bindTo(im3);
   t2.bindTo(im3);


   board.update();
   brd.update();


})();
})();

Revision as of 11:51, 29 July 2011

The JavaScript code

Here is the complete code to accomplish this behaviour.