| 1 | <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" > |
| 2 | <head> |
| 3 | <title>Testing image</title> |
| 4 | <style type="text/css"> |
| 5 | @import "../../../dojo/resources/dojo.css"; |
| 6 | @import "../../../dijit/tests/css/dijitTests.css"; |
| 7 | </style> |
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 9 | <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script> |
| 10 | <script type="text/javascript"> |
| 11 | dojo.require("dojox.gfx"); |
| 12 | |
| 13 | var image = null, grid_size = 500, grid_step = 50, |
| 14 | m = dojox.gfx.matrix; |
| 15 | |
| 16 | createSurface = function(){ |
| 17 | var surface = dojox.gfx.createSurface("test", 800, 600); |
| 18 | surface.whenLoaded(makeShapes); |
| 19 | }; |
| 20 | |
| 21 | makeShapes = function(surface){ |
| 22 | for(var i = 0; i <= grid_size; i += grid_step){ |
| 23 | surface.createLine({x1: 0, x2: grid_size, y1: i, y2: i}).setStroke("black"); |
| 24 | surface.createLine({y1: 0, y2: grid_size, x1: i, x2: i}).setStroke("black"); |
| 25 | } |
| 26 | image = surface.createImage({width: 150, height: 100, src: "images/eugene-sm.jpg"}); |
| 27 | image.connect("onclick", function(){ alert("You didn't expect a download, did you?"); }); |
| 28 | }; |
| 29 | |
| 30 | transformImage = function(){ |
| 31 | var radio = document.getElementsByName("switch"); |
| 32 | if(radio[0].checked){ |
| 33 | image.setTransform({}); |
| 34 | }else if(radio[1].checked){ |
| 35 | image.setTransform({dx: 100, dy: 50}); |
| 36 | }else if(radio[2].checked){ |
| 37 | image.setTransform(m.rotateg(15)); |
| 38 | }else if(radio[3].checked){ |
| 39 | image.setTransform([{dx: 70, dy: 90}, {xx: 1.5, yy: 0.5}]); |
| 40 | }else if(radio[4].checked){ |
| 41 | image.setTransform([m.rotateg(15), m.skewXg(30)]); |
| 42 | } |
| 43 | var shift = document.getElementsByName("shift"); |
| 44 | if(shift[0].checked){ |
| 45 | image.setShape({x: 0, y: 0}); |
| 46 | }else if(shift[1].checked){ |
| 47 | image.setShape({x: 100, y: 50}); |
| 48 | }else if(shift[2].checked){ |
| 49 | image.setShape({x: 0, y: 0}); |
| 50 | image.applyRightTransform({dx: 100, dy: 50}); |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | dojo.addOnLoad(createSurface); |
| 55 | |
| 56 | </script> |
| 57 | </head> |
| 58 | <body> |
| 59 | <h1>dojox.gfx Image tests</h1> |
| 60 | <p>Note: Silverlight doesn't allow downloading images when run from a file system. This demo should be run from a server.</p> |
| 61 | <p> |
| 62 | <input type="radio" name="switch" id="r1_reset" checked onclick="transformImage()" /><label for="r1_reset">Reset Image</label><br /> |
| 63 | <input type="radio" name="switch" id="r1_move" onclick="transformImage()" /><label for="r1_move">Move Image</label><br /> |
| 64 | <input type="radio" name="switch" id="r1_rotate" onclick="transformImage()" /><label for="r1_rotate">Rotate Image</label><br /> |
| 65 | <input type="radio" name="switch" id="r1_scale" onclick="transformImage()" /><label for="r1_scale">Scale Image</label><br /> |
| 66 | <input type="radio" name="switch" id="r1_skew" onclick="transformImage()" /><label for="r1_skew">Skew Image</label><br /> |
| 67 | </p> |
| 68 | <p> |
| 69 | <input type="radio" name="shift" id="r2_none" checked onclick="transformImage()" /><label for="r2_none">Place image at (0, 0)</label><br /> |
| 70 | <input type="radio" name="shift" id="r2_origin" onclick="transformImage()" /><label for="r2_origin">Place image at (100, 50)</label><br /> |
| 71 | <input type="radio" name="shift" id="r2_shift" onclick="transformImage()" /><label for="r2_shift">Shift image by (100, 50)</label> |
| 72 | </p> |
| 73 | <div id="test"></div> |
| 74 | <p>That's all Folks!</p> |
| 75 | </body> |
| 76 | </html> |