dfb720f8644a98b58cb925acdb0b51f473ed177a.svn-base 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <style type="text/css">
  6. @import "../../../dojo/resources/dojo.css";
  7. @import "../../../dijit/tests/css/dijitTests.css";
  8. </style>
  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="../vml.js"></script>-->
  15. <!--<script type="text/javascript" src="../svg.js"></script>-->
  16. <!--<script type="text/javascript" src="../silverlight.js"></script>-->
  17. <script type="text/javascript">
  18. dojo.require("dojox.gfx");
  19. makeShapes = function(){
  20. var surface = dojox.gfx.createSurface(document.getElementById("test"), 500, 500);
  21. var g1 = surface.createGroup();
  22. // make a checkerboard
  23. for(var i = 0; i < 500; i += 100){
  24. for(var j = 0; j < 500; j += 100){
  25. if(i % 200 == j % 200) {
  26. surface.createRect({x: i, y: j}).setFill([255, 0, 0, 0.1]);
  27. }
  28. }
  29. }
  30. var r1 = g1.createShape({type: "rect", x: 200, y: 200})
  31. .setFill("green")
  32. .setStroke({})
  33. //.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
  34. ;
  35. var r2 = surface.createShape({type: "rect"}).setStroke({})
  36. .setFill({type: "linear", to: {x: 50, y: 100},
  37. colors: [{offset: 0, color: "green"}, {offset: 0.5, color: "red"}, {offset: 1, color: "blue"}] })
  38. .setTransform({dx: 100, dy: 100})
  39. ;
  40. var r3 = surface.createRect().setStroke({})
  41. .setFill({ type: "linear" })
  42. //.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
  43. ;
  44. var r4 = g1.createShape({type: "rect"})
  45. .setFill("blue")
  46. //.setStroke({})
  47. //.setTransform(dojox.gfx.matrix.rotategAt(-45, 350, 250))
  48. .setTransform([dojox.gfx.matrix.rotategAt(-30, 350, 250), { dx: 300, dy: 200 }])
  49. ;
  50. var p1 = g1.createShape({type: "path"})
  51. .setStroke({})
  52. .moveTo(300, 100)
  53. .lineTo(400, 200)
  54. .lineTo(400, 300)
  55. .lineTo(300, 400)
  56. .curveTo(400, 300, 400, 200, 300, 100)
  57. //.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
  58. .setTransform({})
  59. ;
  60. var p2 = g1.createShape(p1.getShape())
  61. .setStroke({color: "red", width: 2})
  62. //.moveTo( 300, 100 )
  63. //.lineTo( 400, 200 )
  64. //.lineTo( 400, 300 )
  65. //.lineTo( 300, 400 )
  66. //.curveTo( 400, 300, 400, 200, 300, 100 )
  67. //.setTransform(dojox.gfx.matrix.rotategAt(180, 250, 250))
  68. .setTransform({dx: 100})
  69. ;
  70. var p3 = g1.createShape({type: "path"})
  71. .setStroke({color: "blue", width: 2})
  72. .moveTo(300, 100)
  73. .setAbsoluteMode(false)
  74. .lineTo ( 100, 100)
  75. .lineTo ( 0, 100)
  76. .lineTo (-100, 100)
  77. .curveTo( 100, -100, 100, -200, 0, -300)
  78. //.setTransform(dojox.gfx.matrix.rotategAt(135, 250, 250))
  79. .setTransform(dojox.gfx.matrix.rotategAt(180, 250, 250))
  80. ;
  81. //g1.setTransform({dx: 100});
  82. g1.moveToFront();
  83. g1.setTransform(dojox.gfx.matrix.rotategAt(-15, 250, 250));
  84. //g1.setTransform([dojox.gfx.matrix.rotategAt(-45, 250, 250), dojox.gfx.matrix.scaleAt(0.5, 250, 250)]);
  85. //g1.setTransform([dojox.gfx.matrix.scaleAt(2, 1, 250, 250), dojox.gfx.matrix.rotategAt(-45, 250, 250)]);
  86. };
  87. dojo.addOnLoad(makeShapes);
  88. </script>
  89. </head>
  90. <body>
  91. <h1>dojox.gfx Transform test</h1>
  92. <div id="test"></div>
  93. <p>That's all Folks!</p>
  94. </body>
  95. </html>