test_group.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. <!--
  10. The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
  11. <script type="text/javascript" src="Silverlight.js"></script>
  12. -->
  13. <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
  14. <!--<script type="text/javascript" src="../matrix.js"></script>-->
  15. <!--<script type="text/javascript" src="../util.js"></script>-->
  16. <!--<script type="text/javascript" src="../shape.js"></script>-->
  17. <!--<script type="text/javascript" src="../path.js"></script>-->
  18. <!--<script type="text/javascript" src="../vml.js"></script>-->
  19. <!--<script type="text/javascript" src="../svg.js"></script>-->
  20. <!--<script type="text/javascript" src="../silverlight.js"></script>-->
  21. <script type="text/javascript">
  22. dojo.require("dojox.gfx");
  23. var surface = null;
  24. var g1 = null;
  25. var g2 = null;
  26. var r1 = null;
  27. makeShapes = function(){
  28. surface = dojox.gfx.createSurface(document.getElementById("test"), 500, 500);
  29. // make a checkerboard
  30. for(var i = 0; i < 500; i += 100){
  31. for(var j = 0; j < 500; j += 100){
  32. if(i % 200 == j % 200) {
  33. surface.createRect({ x: i, y: j }).setFill([255, 0, 0, 0.1]);
  34. }
  35. }
  36. }
  37. // create groups and shapes
  38. g1 = surface.createGroup();
  39. g2 = surface.createGroup();
  40. r1 = surface.createRect({x: 200, y: 200}).setFill("green").setStroke({});
  41. g1.setTransform({dy: -100});
  42. //g2.setTransform(dojox.gfx.matrix.rotateAt(-45, 250, 250));
  43. g2.setTransform({dx: 100, dy: -100});
  44. };
  45. switchRect = function(){
  46. var radio = document.getElementsByName("switch");
  47. if(radio[0].checked){
  48. surface.add(r1);
  49. }else if(radio[1].checked){
  50. g1.add(r1);
  51. }else if(radio[2].checked){
  52. g2.add(r1);
  53. }
  54. };
  55. dojo.addOnLoad(makeShapes);
  56. </script>
  57. </head>
  58. <body>
  59. <h1>dojox.gfx Group tests</h1>
  60. <p>
  61. <input type="radio" name="switch" id="r1_s" checked="checked" onclick="switchRect()" /><label for="r1_s">Rectangle belongs to the surface</label><br />
  62. <input type="radio" name="switch" id="r1_g1" onclick="switchRect()" /><label for="r1_g1">Rectangle belongs to the group #1</label><br />
  63. <input type="radio" name="switch" id="r1_g2" onclick="switchRect()" /><label for="r1_g2">Rectangle belongs to the group #2</label>
  64. </p>
  65. <div id="test"></div>
  66. <p>That's all Folks!</p>
  67. </body>
  68. </html>