2150 |
mathias |
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="../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 |
|
|
|
20 |
makeShapes = function(){
|
|
|
21 |
var surface = dojox.gfx.createSurface(document.getElementById("test"), 500, 500);
|
|
|
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.createShape({type: "rect", x: 200, y: 200})
|
|
|
32 |
.setFill("green")
|
|
|
33 |
.setStroke({})
|
|
|
34 |
//.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
|
|
|
35 |
;
|
|
|
36 |
var r2 = surface.createShape({type: "rect"}).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.createShape({type: "rect"})
|
|
|
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.createShape({type: "path"})
|
|
|
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.createShape(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.createShape({type: "path"})
|
|
|
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 |
};
|
|
|
88 |
|
|
|
89 |
dojo.addOnLoad(makeShapes);
|
|
|
90 |
|
|
|
91 |
</script>
|
|
|
92 |
</head>
|
|
|
93 |
<body>
|
|
|
94 |
<h1>dojox.gfx Transform test</h1>
|
|
|
95 |
<div id="test"></div>
|
|
|
96 |
<p>That's all Folks!</p>
|
|
|
97 |
</body>
|
|
|
98 |
</html>
|