| 1 |
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" > |
| 2 |
<head> |
| 3 |
<title>Dojo Unified 2D Graphics</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 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
<script type="text/javascript"> |
| 18 |
dojo.require("dojox.gfx"); |
| 19 |
|
| 20 |
var surface = null; |
| 21 |
var g1 = null; |
| 22 |
var g2 = null; |
| 23 |
var r1 = null; |
| 24 |
|
| 25 |
createSurface = function(){ |
| 26 |
surface = dojox.gfx.createSurface("test", 500, 500); |
| 27 |
surface.whenLoaded(makeShapes); |
| 28 |
}; |
| 29 |
|
| 30 |
makeShapes = function(surface){ |
| 31 |
// make a checkerboard |
| 32 |
for(var i = 0; i < 500; i += 100){ |
| 33 |
for(var j = 0; j < 500; j += 100){ |
| 34 |
if(i % 200 == j % 200) { |
| 35 |
surface.createRect({ x: i, y: j }).setFill([255, 0, 0, 0.1]); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
// create groups and shapes |
| 40 |
g1 = surface.createGroup(); |
| 41 |
g2 = surface.createGroup(); |
| 42 |
r1 = surface.createRect({x: 200, y: 200}).setFill("green").setStroke({}); |
| 43 |
g1.setTransform({dy: -100}); |
| 44 |
//g2.setTransform(dojox.gfx.matrix.rotateAt(-45, 250, 250)); |
| 45 |
g2.setTransform({dx: 100, dy: -100}); |
| 46 |
}; |
| 47 |
|
| 48 |
switchRect = function(){ |
| 49 |
var radio = document.getElementsByName("switch"); |
| 50 |
if(radio[0].checked){ |
| 51 |
surface.add(r1); |
| 52 |
}else if(radio[1].checked){ |
| 53 |
g1.add(r1); |
| 54 |
}else if(radio[2].checked){ |
| 55 |
g2.add(r1); |
| 56 |
} |
| 57 |
}; |
| 58 |
|
| 59 |
dojo.addOnLoad(createSurface); |
| 60 |
|
| 61 |
</script> |
| 62 |
</head> |
| 63 |
<body> |
| 64 |
<h1>dojox.gfx Group tests</h1> |
| 65 |
<p> |
| 66 |
<input type="radio" name="switch" id="r1_s" checked="checked" onclick="switchRect()" /><label for="r1_s">Rectangle belongs to the surface</label><br /> |
| 67 |
<input type="radio" name="switch" id="r1_g1" onclick="switchRect()" /><label for="r1_g1">Rectangle belongs to the group #1</label><br /> |
| 68 |
<input type="radio" name="switch" id="r1_g2" onclick="switchRect()" /><label for="r1_g2">Rectangle belongs to the group #2</label> |
| 69 |
</p> |
| 70 |
<div id="test"></div> |
| 71 |
<p>That's all Folks!</p> |
| 72 |
</body> |
| 73 |
</html> |