test_gradient.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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="../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. dojo.require("dojo.colors"); // pull in CSS3 color names
  20. makeShapes = function(){
  21. var SIDE = 10;
  22. var fillObj = {
  23. colors: [
  24. { offset: 0, color: [255, 255, 0, 0] },
  25. { offset: 0.5, color: "orange" },
  26. { offset: 1, color: [255, 255, 0, 0] }
  27. ]
  28. };
  29. var surface = dojox.gfx.createSurface(dojo.byId("grad"), 300, 300);
  30. // create a background
  31. for(var i = 0; i < 300; i += SIDE){
  32. for(var j = 0; j < 300; j += SIDE){
  33. surface.
  34. createRect({x: j, y: i, width: 10, height: 10}).
  35. setFill((Math.floor(i / SIDE) + Math.floor(j / SIDE)) % 2 ? "lightgrey" : "white");
  36. }
  37. }
  38. // create a rect
  39. surface.createRect({
  40. width: 300,
  41. height: 100
  42. }).setFill(dojo.mixin({
  43. type: "linear",
  44. x1: 0, y1: 0,
  45. x2: 300, y2: 0
  46. }, fillObj));
  47. // create a circle
  48. surface.createEllipse({
  49. cx: 150,
  50. cy: 200,
  51. rx: 100,
  52. ry: 100
  53. }).setFill(dojo.mixin({
  54. type: "radial",
  55. cx: 150,
  56. cy: 200
  57. }, fillObj));
  58. };
  59. dojo.addOnLoad(makeShapes);
  60. </script>
  61. <style type="text/css">
  62. #grad { width: 300px; height: 300px; }
  63. </style>
  64. </head>
  65. <body>
  66. <h1>dojox.gfx Alpha gradient test</h1>
  67. <div id="grad"></div>
  68. </body>
  69. </html>