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