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