aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/gfx/tests/decompose.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/gfx/tests/decompose.js
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/gfx/tests/decompose.js')
-rw-r--r--includes/js/dojox/gfx/tests/decompose.js114
1 files changed, 114 insertions, 0 deletions
diff --git a/includes/js/dojox/gfx/tests/decompose.js b/includes/js/dojox/gfx/tests/decompose.js
new file mode 100644
index 0000000..b488bdd
--- /dev/null
+++ b/includes/js/dojox/gfx/tests/decompose.js
@@ -0,0 +1,114 @@
+if(!dojo._hasResource["dojox.gfx.tests.decompose"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gfx.tests.decompose"] = true;
+dojo.provide("dojox.gfx.tests.decompose");
+dojo.require("dojox.gfx.decompose");
+
+(function(){
+ var m = dojox.gfx.matrix;
+ var eq = function(t, a, b){ t.t(2 * Math.abs(a - b) / ((a < 1 && b < 1) ? 1 : a + b) < 1e-6); };
+ var eqM = function(t, a, b){
+ eq(t, a.xx, b.xx);
+ eq(t, a.yy, b.yy);
+ eq(t, a.xy, b.xy);
+ eq(t, a.yx, b.yx);
+ eq(t, a.dx, b.dx);
+ eq(t, a.dy, b.dy);
+ };
+ var compose = function(r){
+ return m.normalize([
+ m.translate(r.dx, r.dy),
+ m.rotate(r.angle2),
+ m.scale(r.sx, r.sy),
+ m.rotate(r.angle1)
+ ]);
+ };
+ var reconstruct = function(a){
+ return compose(dojox.gfx.decompose(a));
+ };
+ var compare = function(t, a){
+ var A = m.normalize(a);
+ eqM(t, A, reconstruct(A));
+ };
+ tests.register("dojox.gfx.tests.decompose", [
+ function IdentityTest(t){
+ compare(t, m.identity);
+ },
+ function FlipXTest(t){
+ compare(t, m.flipX);
+ },
+ function FlipYTest(t){
+ compare(t, m.flipY);
+ },
+ function FlipXYTest(t){
+ compare(t, m.flipXY);
+ },
+ function TranslationTest(t){
+ compare(t, m.translate(45, -15));
+ },
+ function RotationTest(t){
+ compare(t, m.rotateg(35));
+ },
+ function SkewXTest(t){
+ compare(t, m.skewXg(35));
+ },
+ function SkewYTest(t){
+ compare(t, m.skewYg(35));
+ },
+ function ReflectTest(t){
+ compare(t, m.reflect(13, 27));
+ },
+ function ProjectTest(t){
+ compare(t, m.project(13, 27));
+ },
+ function ScaleTest1(t){
+ compare(t, m.scale(3));
+ },
+ function ScaleTest2(t){
+ compare(t, m.scale(3, -1));
+ },
+ function ScaleTest3(t){
+ compare(t, m.scale(-3, 1));
+ },
+ function ScaleTest4(t){
+ compare(t, m.scale(-3, -1));
+ },
+ function ScaleRotateTest1(t){
+ compare(t, [m.scale(3), m.rotateAt(35, 13, 27)]);
+ },
+ function ScaleRotateTest2(t){
+ compare(t, [m.scale(3, -1), m.rotateAt(35, 13, 27)]);
+ },
+ function ScaleRotateTest3(t){
+ compare(t, [m.scale(-3, 1), m.rotateAt(35, 13, 27)]);
+ },
+ function ScaleRotateTest4(t){
+ compare(t, [m.scale(-3, -1), m.rotateAt(35, 13, 27)]);
+ },
+ function RotateScaleTest1(t){
+ compare(t, [m.rotateAt(35, 13, 27), m.scale(3)]);
+ },
+ function RotateScaleTest2(t){
+ compare(t, [m.rotateAt(35, 13, 27), m.scale(3, -1)]);
+ },
+ function RotateScaleTest3(t){
+ compare(t, [m.rotateAt(35, 13, 27), m.scale(-3, 1)]);
+ },
+ function RotateScaleTest4(t){
+ compare(t, [m.rotateAt(35, 13, 27), m.scale(-3, -1)]);
+ },
+ function RotateScaleRotateTest1(t){
+ compare(t, [m.rotateAt(35, 13, 27), m.scale(3), m.rotateAt(-15, 163, -287)]);
+ },
+ function RotateScaleRotateTest2(t){
+ compare(t, [m.rotateAt(35, 13, 27), m.scale(3, -1), m.rotateAt(-15, 163, -287)]);
+ },
+ function RotateScaleRotateTest3(t){
+ compare(t, [m.rotateAt(35, 13, 27), m.scale(-3, 1), m.rotateAt(-15, 163, -287)]);
+ },
+ function RotateScaleRotateTest4(t){
+ compare(t, [m.rotateAt(35, 13, 27), m.scale(-3, -1), m.rotateAt(-15, 163, -287)]);
+ }
+ ]);
+})();
+
+}