8ba2794a5aa2512c05dfdd41ab7ec758fe188fd3.svn-base 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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="../_base.js"></script>
  15. <script type="text/javascript" src="../shape.js"></script>
  16. <script type="text/javascript" src="../path.js"></script>
  17. <script type="text/javascript" src="../arc.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="../canvas.js"></script>-->
  21. <!--<script type="text/javascript" src="../silverlight.js"></script>-->
  22. <script type="text/javascript">
  23. dojo.require("dojox.gfx");
  24. makeShapes = function(){
  25. var surface = dojox.gfx.createSurface(document.getElementById("test"), 500, 500);
  26. var g1 = surface.createGroup();
  27. // make a checkerboard
  28. for(var i = 0; i < 500; i += 100){
  29. for(var j = 0; j < 500; j += 100){
  30. if(i % 200 == j % 200) {
  31. surface.createRect({ x: i, y: j }).setFill([255, 0, 0, 0.1]);
  32. }
  33. }
  34. }
  35. var r1 = g1.createRect({ x: 200, y: 200 })
  36. .setFill("green")
  37. .setStroke({})
  38. //.setTransform(dojox.gfx.matrix.rotategAt(45, 250, 250))
  39. ;
  40. var r2 = surface.createRect().setStroke({})
  41. .setFill({ type: "linear", to: { x: 50, y: 100 },
  42. colors: [{ offset: 0, color: "green" }, { offset: 0.5, color: "red" }, { offset: 1, color: "blue" }] })
  43. .setTransform({dx: 100, dy: 100})
  44. ;
  45. var r3 = surface.createRect().setStroke({})
  46. .setFill({ type: "linear" })
  47. //.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
  48. ;
  49. var r4 = g1.createRect({})
  50. .setFill("blue")
  51. //.setStroke({})
  52. //.setTransform(dojox.gfx.matrix.rotategAt(-45, 350, 250))
  53. .setTransform([dojox.gfx.matrix.rotategAt(-30, 350, 250), { dx: 300, dy: 200 }])
  54. ;
  55. var p1 = g1.createPath()
  56. .setStroke({})
  57. .moveTo( 300, 100 )
  58. .lineTo( 400, 200 )
  59. .lineTo( 400, 300 )
  60. .lineTo( 300, 400 )
  61. .curveTo( 400, 300, 400, 200, 300, 100 )
  62. //.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
  63. .setTransform({})
  64. ;
  65. var p2 = g1.createPath(p1.getShape())
  66. .setStroke({ color: "red", width: 2 })
  67. //.moveTo( 300, 100 )
  68. //.lineTo( 400, 200 )
  69. //.lineTo( 400, 300 )
  70. //.lineTo( 300, 400 )
  71. //.curveTo( 400, 300, 400, 200, 300, 100 )
  72. //.setTransform(dojox.gfx.matrix.rotategAt(180, 250, 250))
  73. .setTransform({ dx: 100 })
  74. ;
  75. var p3 = g1.createPath()
  76. .setStroke({ color: "blue", width: 2 })
  77. .moveTo( 300, 100 )
  78. .setAbsoluteMode(false)
  79. .lineTo ( 100, 100 )
  80. .lineTo ( 0, 100 )
  81. .lineTo ( -100, 100 )
  82. .curveTo( 100, -100, 100, -200, 0, -300 )
  83. //.setTransform(dojox.gfx.matrix.rotategAt(135, 250, 250))
  84. .setTransform(dojox.gfx.matrix.rotategAt(180, 250, 250))
  85. ;
  86. //g1.setTransform({ dx: 100 });
  87. g1.moveToFront();
  88. g1.setTransform(dojox.gfx.matrix.rotategAt(-15, 250, 250));
  89. //g1.setTransform([dojox.gfx.matrix.rotategAt(-45, 250, 250), dojox.gfx.matrix.scaleAt(0.5, 250, 250)]);
  90. //g1.setTransform([dojox.gfx.matrix.scaleAt(2, 1, 250, 250), dojox.gfx.matrix.rotategAt(-45, 250, 250)]);
  91. var a = p1.getTransformedBoundingBox();
  92. a.push(a[0]);
  93. surface.createPolyline(a).setStroke("green");
  94. a = p2.getTransformedBoundingBox();
  95. a.push(a[0]);
  96. surface.createPolyline(a).setStroke("green");
  97. a = p3.getTransformedBoundingBox();
  98. a.push(a[0]);
  99. surface.createPolyline(a).setStroke("green");
  100. };
  101. dojo.addOnLoad(makeShapes);
  102. </script>
  103. <!--
  104. <style>
  105. v:group { text-align: left; }
  106. </style>
  107. -->
  108. </head>
  109. <body>
  110. <h1>dojox.gfx Transformation test</h1>
  111. <div id="test"></div>
  112. <p>That's all Folks!</p>
  113. </body>
  114. </html>