OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <title>Geometry Interfaces: DOMMatrix scale</title> | |
5 <script src="../../resources/js-test.js"></script> | |
krit
2014/08/08 05:47:33
Could you instead use resources/testharness.js? Th
zino
2014/08/17 11:35:25
Done.
| |
6 </head> | |
7 <body> | |
8 <script> | |
9 | |
10 function compareMatrix(matrixObject, matrixValue) | |
11 { | |
12 return matrixObject.m11 == matrixValue[0] && | |
13 matrixObject.m21 == matrixValue[1] && | |
14 matrixObject.m31 == matrixValue[2] && | |
15 matrixObject.m41 == matrixValue[3] && | |
16 matrixObject.m12 == matrixValue[4] && | |
17 matrixObject.m22 == matrixValue[5] && | |
18 matrixObject.m32 == matrixValue[6] && | |
19 matrixObject.m42 == matrixValue[7] && | |
20 matrixObject.m13 == matrixValue[8] && | |
21 matrixObject.m23 == matrixValue[9] && | |
22 matrixObject.m33 == matrixValue[10] && | |
23 matrixObject.m43 == matrixValue[11] && | |
24 matrixObject.m14 == matrixValue[12] && | |
25 matrixObject.m24 == matrixValue[13] && | |
26 matrixObject.m34 == matrixValue[14] && | |
27 matrixObject.m44 == matrixValue[15]; | |
28 } | |
29 | |
30 debug("# DOMMatrix.scale(scale)"); | |
31 var matrix = new DOMMatrix(); | |
32 shouldBeTrue("matrix.is2D"); | |
33 shouldBeTrue("matrix.isIdentity"); | |
34 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
35 var result = matrix.scale(3); | |
36 shouldBeTrue("result.is2D"); | |
37 shouldBeFalse("result.isIdentity"); | |
38 shouldBeTrue("compareMatrix(result, [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
39 shouldBeTrue("matrix.is2D"); | |
40 shouldBeTrue("matrix.isIdentity"); | |
41 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
42 debug(""); | |
43 | |
44 debug("# DOMMatrix.scale(scale, ox, oy)"); | |
45 matrix = new DOMMatrix(); | |
46 shouldBeTrue("matrix.is2D"); | |
47 shouldBeTrue("matrix.isIdentity"); | |
48 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
49 result = matrix.scale(3, 4, 2); | |
50 shouldBeTrue("result.is2D"); | |
51 shouldBeFalse("result.isIdentity"); | |
52 shouldBeTrue("compareMatrix(result, [ 3, 0, 0, -8, 0, 3, 0, -4, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
53 shouldBeTrue("matrix.is2D"); | |
54 shouldBeTrue("matrix.isIdentity"); | |
55 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
56 debug(""); | |
57 | |
58 debug("# DOMMatrix.scale3d(scale)"); | |
59 matrix = new DOMMatrix(); | |
60 shouldBeTrue("matrix.is2D"); | |
61 shouldBeTrue("matrix.isIdentity"); | |
62 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
63 result = matrix.scale3d(3); | |
64 shouldBeFalse("result.is2D"); | |
65 shouldBeFalse("result.isIdentity"); | |
66 shouldBeTrue("compareMatrix(result, [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1 ])"); | |
67 shouldBeTrue("matrix.is2D"); | |
68 shouldBeTrue("matrix.isIdentity"); | |
69 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
70 debug(""); | |
71 | |
72 debug("# DOMMatrix.scale3d(scale, ox, oy, oz)"); | |
73 matrix = new DOMMatrix(); | |
74 shouldBeTrue("matrix.is2D"); | |
75 shouldBeTrue("matrix.isIdentity"); | |
76 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
77 result = matrix.scale3d(3, 2, 7, -1); | |
78 shouldBeFalse("result.is2D"); | |
79 shouldBeFalse("result.isIdentity"); | |
80 shouldBeTrue("compareMatrix(result, [ 3, 0, 0, -4, 0, 3, 0, -14, 0, 0, 3, 2, 0, 0, 0, 1 ])"); | |
81 shouldBeTrue("matrix.is2D"); | |
82 shouldBeTrue("matrix.isIdentity"); | |
83 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
84 debug(""); | |
85 | |
86 debug("# DOMMatrix.scaleNonUniform(sx, sy, sz, ox, oy, oz)"); | |
87 matrix = new DOMMatrix(); | |
88 shouldBeTrue("matrix.is2D"); | |
89 shouldBeTrue("matrix.isIdentity"); | |
90 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
91 result = matrix.scaleNonUniform(2, 3, 0.5, 2, -4, -1); | |
92 shouldBeFalse("result.is2D"); | |
93 shouldBeFalse("result.isIdentity"); | |
94 shouldBeTrue("compareMatrix(result, [ 2, 0, 0, -2, 0, 3, 0, 8, 0, 0, 0.5, -0 .5, 0, 0, 0, 1 ])"); | |
95 shouldBeTrue("matrix.is2D"); | |
96 shouldBeTrue("matrix.isIdentity"); | |
97 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
98 debug(""); | |
99 | |
100 debug("# DOMMatrix.scaleSelf(scale)"); | |
101 var matrix = new DOMMatrix(); | |
102 shouldBeTrue("matrix.is2D"); | |
103 shouldBeTrue("matrix.isIdentity"); | |
104 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
105 var result = matrix.scaleSelf(3); | |
106 shouldBeTrue("result.is2D"); | |
107 shouldBeFalse("result.isIdentity"); | |
108 shouldBeTrue("compareMatrix(result, [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
109 shouldBeTrue("matrix.is2D"); | |
110 shouldBeFalse("matrix.isIdentity"); | |
111 shouldBeTrue("compareMatrix(matrix, [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
112 debug(""); | |
113 | |
114 debug("# DOMMatrix.scaleSelf(scaleSelf, ox, oy)"); | |
115 matrix = new DOMMatrix(); | |
116 shouldBeTrue("matrix.is2D"); | |
117 shouldBeTrue("matrix.isIdentity"); | |
118 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
119 result = matrix.scaleSelf(3, 4, 2); | |
120 shouldBeTrue("result.is2D"); | |
121 shouldBeFalse("result.isIdentity"); | |
122 shouldBeTrue("compareMatrix(result, [ 3, 0, 0, -8, 0, 3, 0, -4, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
123 shouldBeTrue("matrix.is2D"); | |
124 shouldBeFalse("matrix.isIdentity"); | |
125 shouldBeTrue("compareMatrix(matrix, [ 3, 0, 0, -8, 0, 3, 0, -4, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
126 debug(""); | |
127 | |
128 debug("# DOMMatrix.scale3dSelf(scale)"); | |
129 matrix = new DOMMatrix(); | |
130 shouldBeTrue("matrix.is2D"); | |
131 shouldBeTrue("matrix.isIdentity"); | |
132 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
133 result = matrix.scale3dSelf(3); | |
134 shouldBeFalse("result.is2D"); | |
135 shouldBeFalse("result.isIdentity"); | |
136 shouldBeTrue("compareMatrix(result, [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1 ])"); | |
137 shouldBeFalse("matrix.is2D"); | |
138 shouldBeFalse("matrix.isIdentity"); | |
139 shouldBeTrue("compareMatrix(matrix, [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1 ])"); | |
140 debug(""); | |
141 | |
142 debug("# DOMMatrix.scale3dSelf(scale, ox, oy, oz)"); | |
143 matrix = new DOMMatrix(); | |
144 shouldBeTrue("matrix.is2D"); | |
145 shouldBeTrue("matrix.isIdentity"); | |
146 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
147 result = matrix.scale3dSelf(3, 2, 7, -1); | |
148 shouldBeFalse("result.is2D"); | |
149 shouldBeFalse("result.isIdentity"); | |
150 shouldBeTrue("compareMatrix(result, [ 3, 0, 0, -4, 0, 3, 0, -14, 0, 0, 3, 2, 0, 0, 0, 1 ])"); | |
151 shouldBeFalse("matrix.is2D"); | |
152 shouldBeFalse("matrix.isIdentity"); | |
153 shouldBeTrue("compareMatrix(matrix, [ 3, 0, 0, -4, 0, 3, 0, -14, 0, 0, 3, 2, 0, 0, 0, 1 ])"); | |
154 debug(""); | |
155 | |
156 debug("# DOMMatrix.scaleNonUniformSelf(sx, sy, sz, ox, oy, oz)"); | |
157 matrix = new DOMMatrix(); | |
158 shouldBeTrue("matrix.is2D"); | |
159 shouldBeTrue("matrix.isIdentity"); | |
160 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
161 result = matrix.scaleNonUniformSelf(2, 3, 0.5, 2, -4, -1); | |
162 shouldBeFalse("result.is2D"); | |
163 shouldBeFalse("result.isIdentity"); | |
164 shouldBeTrue("compareMatrix(result, [ 2, 0, 0, -2, 0, 3, 0, 8, 0, 0, 0.5, -0 .5, 0, 0, 0, 1 ])"); | |
165 shouldBeFalse("matrix.is2D"); | |
166 shouldBeFalse("matrix.isIdentity"); | |
167 shouldBeTrue("compareMatrix(matrix, [ 2, 0, 0, -2, 0, 3, 0, 8, 0, 0, 0.5, -0 .5, 0, 0, 0, 1 ])"); | |
168 debug(""); | |
169 | |
170 debug("# DOMMatrix.scaleNonUniformSelf(1, 1, 1, ox, oy, oz)"); | |
171 matrix = new DOMMatrix(); | |
172 shouldBeTrue("matrix.is2D"); | |
173 shouldBeTrue("matrix.isIdentity"); | |
174 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
175 result = matrix.scaleNonUniformSelf(1, 1, 1, 2, -4, -1); | |
176 shouldBeFalse("result.is2D"); | |
177 shouldBeTrue("result.isIdentity"); | |
178 shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
179 shouldBeFalse("matrix.is2D"); | |
180 shouldBeTrue("matrix.isIdentity"); | |
181 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
182 debug(""); | |
183 | |
184 </script> | |
185 </body> | |
186 </html> | |
OLD | NEW |