test_decompose.html 1.8 KB

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