e44a7e37b6
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
114 lines
3 KiB
JavaScript
114 lines
3 KiB
JavaScript
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)]);
|
|
}
|
|
]);
|
|
})();
|
|
|
|
}
|