Debian Codegraph @

examples/image.html

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 <html>
2 <head>
3 <title>JSXGraph example</title>
4 <link rel="stylesheet" type="text/css" href="../distrib/jsxgraph.css" />
5 <!--<script type="text/javascript" src="prototype.js"></script>-->
6 <script type="text/javascript" src="../distrib/jsxgraphcore.js"></script>
7
8 </head>
9 <body>
10 <h2>Images</h2>
11 <div id="jxgbox" class="jxgbox" style="width:700px; height:500px;"></div>
12 <div id="debug" style="display:block;"></div>
13 <script type="text/javascript">
14 /* <![CDATA[ */
15 //(function(){
16 var p0, p1, picStr, board;
17
18 picStr = "http://easyimup.de/uploads/garfield-1069_e254457.gif";
19 //picStr = "./uccellino.jpg";
20 picStr = "./fagiolo.jpg";
21
22 board = JXG.JSXGraph.initBoard('jxgbox', {originX: 250, originY: 250, unitX: 40, unitY: 40, axis:true, grid:true});
23
24 var p0 = board.create('point', [-1,0], {style:5, name:'opacity'});
25
26 /*
27 var p1 = board.create('point', [3,0], {style:5, name:'rot+scale'});
28 var li = board.create('line', [p0,p1]);
29 */
30 var p1 = board.create('point', [1,1]);
31 var p2 = board.create('point', [4,3]);
32 var im = board.create('image',[picStr,
33 [function(){return p1.X()}, function(){return p1.Y(); }],
34 [function(){return p2.X() - p1.X()}, function(){return p2.Y() - p1.Y(); }]],
35 {id:'imx',
36 opacity: function(){ return Math.exp(-Math.abs(p0.X())*0.4);},
37 rotate:0,
38 frozen:false });
39
40 /*
41 //
42 // Translate image and point "rot+scale" by freagging point "offset"
43 var tOff = board.create('transform', [function(){return p0.X()},function(){return p0.Y()}], {type:'translate'});
44 tOff.bindTo(im);
45 tOff.bindTo(p1);
46
47 // Rotate image around point "offset" by dragging point "rot+scale"
48 var tRot = board.create('transform', [function(){return Math.atan2(p1.Y()-p0.Y(),p1.X()-p0.X())}, p0], {type:'rotate'});
49 tRot.bindTo(im);
50
51 // Scale image by dragging point "rot+scale"
52 // We do this by moving the image back to the origin (inverse of transformation tOff),
53 // then scale the image (because scaling "starts from (0,0))
54 // Finally, we move the image back to point "Offset"
55 var tOffInv = board.create('transform', [function(){return -p0.X()},function(){return -p0.Y()}], {type:'translate'});
56 var tScale = board.create('transform', [function(){return p1.Dist(p0)/3;},
57 function(){return p1.Dist(p0)/3;}], {type:'scale'});
58 tOffInv.bindTo(im); tScale.bindTo(im); tOff.bindTo(im);
59 //board.update();
60 */
61 //})();
62 /* ]]> */
63 </script>
64 </body>
65 </html>