1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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)]);
}
]);
})();
}
|