Difference between revisions of "Reflect images"
From JSXGraph Wiki
Jump to navigationJump to searchA WASSERMANN (talk | contribs) |
A WASSERMANN (talk | contribs) |
||
Line 10: | Line 10: | ||
// Define two line through four points | // Define two line through four points | ||
− | p0 = | + | p0 = brd.createElement('point', [0,3]); |
− | p1 = | + | p1 = brd.createElement('point', [1,1]); |
− | p2 = | + | p2 = brd.createElement('point', [-3,4]); |
− | p3 = | + | p3 = brd.createElement('point', [10,4]); |
− | l1 = | + | l1 = brd.createElement('line', [p0, p1]); |
− | l2 = | + | l2 = brd.createElement('line', [p2, p3]); |
− | p4 = | + | p4 = brd.createElement('point', [-2,-2]); |
− | p5 = | + | 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 = | + | im1 = brd.create('image',[imurl, [X, Y], [W, H]], {opacity:0.7}); |
− | im2 = | + | im2 = brd.create('image',[imurl, [X, Y], [W, H]], {opacity:0.7}); |
− | im3 = | + | im3 = brd.create('image',[imurl, [X, Y], [W, H]], {opacity:0.7}); |
− | t1 = | + | t1 = brd.createElement('transform', [l1], {type:'reflect'}); |
− | t2 = | + | 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); | ||
− | + | brd.update(); | |
})(); | })(); |
Revision as of 13:51, 29 July 2011
The JavaScript code
Here is the complete code to accomplish this behaviour.