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 | <!-- SVGWEB { --> |
---|
10 | <meta name="svg.render.forceflash" content="true"/> |
---|
11 | <script src="svgweb/src/svg.js" data-path="svgweb/src"></script> |
---|
12 | <script src="../../../../dojo/dojo.js" data-dojo-config="isDebug:true,forceGfxRenderer:'svg'" type="text/javascript"></script> |
---|
13 | <!-- } --> |
---|
14 | <script type="text/javascript"> |
---|
15 | dojo.require("dojox.gfx"); |
---|
16 | |
---|
17 | makeShapes = function(){ |
---|
18 | var surface = dojox.gfx.createSurface(document.getElementById("test"), 500, 500); |
---|
19 | /* SVGWEB { */ |
---|
20 | surface.whenLoaded(function() { |
---|
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.createRect({ x: 200, y: 200 }) |
---|
31 | .setFill("green") |
---|
32 | .setStroke({}) |
---|
33 | //.setTransform(dojox.gfx.matrix.rotategAt(45, 250, 250)) |
---|
34 | ; |
---|
35 | var r2 = surface.createRect().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.createRect({}) |
---|
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.createPath() |
---|
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.createPath(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.createPath() |
---|
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 | var a = p1.getTransformedBoundingBox(); |
---|
87 | a.push(a[0]); |
---|
88 | surface.createPolyline(a).setStroke("green"); |
---|
89 | a = p2.getTransformedBoundingBox(); |
---|
90 | a.push(a[0]); |
---|
91 | surface.createPolyline(a).setStroke("green"); |
---|
92 | a = p3.getTransformedBoundingBox(); |
---|
93 | a.push(a[0]); |
---|
94 | surface.createPolyline(a).setStroke("green"); |
---|
95 | }); |
---|
96 | /* } */ |
---|
97 | }; |
---|
98 | |
---|
99 | dojo.addOnLoad(makeShapes); |
---|
100 | |
---|
101 | </script> |
---|
102 | <!-- |
---|
103 | <style> |
---|
104 | v:group { text-align: left; } |
---|
105 | </style> |
---|
106 | --> |
---|
107 | </head> |
---|
108 | <body> |
---|
109 | <h1>dojox.gfx Transformation test</h1> |
---|
110 | <div id="test"></div> |
---|
111 | <p>That's all Folks!</p> |
---|
112 | </body> |
---|
113 | </html> |
---|