2150 |
mathias |
1 |
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
|
|
|
2 |
<head>
|
|
|
3 |
<title>Testing decompose</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" djConfig="isDebug: true"></script>
|
|
|
10 |
<script type="text/javascript" src="../matrix.js"></script>
|
|
|
11 |
<script type="text/javascript" src="../decompose.js"></script>
|
|
|
12 |
<script type="text/javascript">
|
|
|
13 |
dojo.require("dojox.gfx.decompose");
|
|
|
14 |
|
|
|
15 |
var m = dojox.gfx.matrix;
|
|
|
16 |
|
|
|
17 |
var eq = function(a, b){
|
|
|
18 |
return Math.abs((a - b) / (a + b)) < 1e-6;
|
|
|
19 |
};
|
|
|
20 |
|
|
|
21 |
var calc = function(){
|
|
|
22 |
var matrix1 = eval("(m.normalize([" + dojo.byId("input").value + "]))");
|
|
|
23 |
dojo.byId("matrix1").value = dojo.toJson(matrix1, true);
|
|
|
24 |
var result = dojox.gfx.decompose(matrix1);
|
|
|
25 |
dojo.byId("result").innerHTML = "Result: " + dojo.toJson(result);
|
|
|
26 |
var matrix2 = m.normalize([
|
|
|
27 |
m.translate(result.dx, result.dy),
|
|
|
28 |
m.rotate(result.angle2),
|
|
|
29 |
m.scale(result.sx, result.sy),
|
|
|
30 |
m.rotate(result.angle1)
|
|
|
31 |
]);
|
|
|
32 |
dojo.byId("matrix2").value = dojo.toJson(matrix2, true);
|
|
|
33 |
};
|
|
|
34 |
|
|
|
35 |
</script>
|
|
|
36 |
</head>
|
|
|
37 |
<body>
|
|
|
38 |
<h1>Testing decompose</h1>
|
|
|
39 |
<p>
|
|
|
40 |
<span style="font-size: 8pt;">Example: m.rotategAt(30, 100, 100), m.scaleAt(2, 3, 5, 5), m.rotate(45)</span><br />
|
|
|
41 |
<input id="input" type="text" size="50" maxlength="200" /><button onclick="calc();">Calc</button>
|
|
|
42 |
</p>
|
|
|
43 |
<p id="result">Result:</p>
|
|
|
44 |
<p>
|
|
|
45 |
<span style="font-size: 8pt;">Original matrix</span><br />
|
|
|
46 |
<textarea id="matrix1" cols="50" rows="8" readonly="readonly"></textarea>
|
|
|
47 |
</p>
|
|
|
48 |
<p>
|
|
|
49 |
<span style="font-size: 8pt;">Decomposed matrix</span><br />
|
|
|
50 |
<textarea id="matrix2" cols="50" rows="8" readonly="readonly"></textarea>
|
|
|
51 |
</p>
|
|
|
52 |
<p>That's all Folks!</p>
|
|
|
53 |
</body>
|
|
|
54 |
</html>
|