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