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