OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Geometry Interfaces: DOMMatrix</title> | 4 <title>Geometry Interfaces: DOMMatrix</title> |
5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
7 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <script> | 9 <script> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 assert_equals(matrix.m34, 0); | 54 assert_equals(matrix.m34, 0); |
55 assert_equals(matrix.m41, 0); | 55 assert_equals(matrix.m41, 0); |
56 assert_equals(matrix.m42, 3); | 56 assert_equals(matrix.m42, 3); |
57 assert_equals(matrix.m43, 0); | 57 assert_equals(matrix.m43, 0); |
58 assert_equals(matrix.m44, 9); | 58 assert_equals(matrix.m44, 9); |
59 assert_false(matrix.is2D); | 59 assert_false(matrix.is2D); |
60 assert_false(matrix.isIdentity); | 60 assert_false(matrix.isIdentity); |
61 }, "DOMMatrix(other) constructor"); | 61 }, "DOMMatrix(other) constructor"); |
62 | 62 |
63 test(function() { | 63 test(function() { |
64 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]); | |
65 var matrix2d = DOMMatrix.fromFloat32Array(float32Array); | |
66 assert_true(matrix2d.is2D); | |
67 assert_equals(matrix2d.a, 1); | |
68 assert_equals(matrix2d.b, 2); | |
69 assert_equals(matrix2d.c, 3); | |
70 assert_equals(matrix2d.d, 4); | |
71 assert_equals(matrix2d.e, 5); | |
72 assert_equals(matrix2d.f, 6); | |
73 }, "DOMMatrix fromFloat32Array - 2D matrix"); | |
74 | |
75 test(function() { | |
76 // 3.1 is not representable as a 32-bit float | |
77 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]); | |
78 var matrix2d = DOMMatrix.fromFloat64Array(float64Array); | |
79 assert_true(matrix2d.is2D); | |
80 assert_equals(matrix2d.a, 1); | |
81 assert_equals(matrix2d.b, 2); | |
82 assert_equals(matrix2d.c, 3); | |
83 assert_equals(matrix2d.d, 3.1); | |
84 assert_equals(matrix2d.e, 4); | |
85 assert_equals(matrix2d.f, 5); | |
86 }, "DOMMatrix fromFloat64Array - 2D matrix"); | |
87 | |
88 test(function() { | |
89 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); | |
90 var matrix3d = DOMMatrix.fromFloat32Array(float32Array); | |
91 assert_false(matrix3d.is2D); | |
92 assert_equals(matrix3d.m11, 1); | |
93 assert_equals(matrix3d.m12, 2); | |
94 assert_equals(matrix3d.m13, 3); | |
95 assert_equals(matrix3d.m14, 4); | |
96 assert_equals(matrix3d.m21, 5); | |
97 assert_equals(matrix3d.m22, 6); | |
98 assert_equals(matrix3d.m23, 7); | |
99 assert_equals(matrix3d.m24, 8); | |
100 assert_equals(matrix3d.m31, 9); | |
101 assert_equals(matrix3d.m32, 10); | |
102 assert_equals(matrix3d.m33, 11); | |
103 assert_equals(matrix3d.m34, 12); | |
104 assert_equals(matrix3d.m41, 13); | |
105 assert_equals(matrix3d.m42, 14); | |
106 assert_equals(matrix3d.m43, 15); | |
107 assert_equals(matrix3d.m44, 16); | |
108 }, "DOMMatrix fromFloat32Array - 3D matrix"); | |
109 | |
110 test(function() { | |
111 // 10.1 and 16.6 are not representable as a 32-bit float | |
112 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12 , 13, 14, 15, 16.6]); | |
113 var matrix3d = DOMMatrix.fromFloat64Array(float64Array); | |
114 assert_false(matrix3d.is2D); | |
115 assert_equals(matrix3d.m11, 1); | |
116 assert_equals(matrix3d.m12, 2); | |
117 assert_equals(matrix3d.m13, 3); | |
118 assert_equals(matrix3d.m14, 4); | |
119 assert_equals(matrix3d.m21, 5); | |
120 assert_equals(matrix3d.m22, 6); | |
121 assert_equals(matrix3d.m23, 7); | |
122 assert_equals(matrix3d.m24, 8); | |
123 assert_equals(matrix3d.m31, 9); | |
124 assert_equals(matrix3d.m32, 10.1); | |
125 assert_equals(matrix3d.m33, 11); | |
126 assert_equals(matrix3d.m34, 12); | |
127 assert_equals(matrix3d.m41, 13); | |
128 assert_equals(matrix3d.m42, 14); | |
129 assert_equals(matrix3d.m43, 15); | |
130 assert_equals(matrix3d.m44, 16.6); | |
131 }, "DOMMatrix fromFloat64Array - 3D matrix"); | |
132 | |
133 test(function() { | |
64 var matrix = new DOMMatrix(); | 134 var matrix = new DOMMatrix(); |
65 matrix.a = 10; | 135 matrix.a = 10; |
66 matrix.b = 20; | 136 matrix.b = 20; |
67 matrix.m24 = 2; | 137 matrix.m24 = 2; |
68 matrix.m33 = 3; | 138 matrix.m33 = 3; |
69 matrix.m42 = 3; | 139 matrix.m42 = 3; |
70 matrix.m44 = 9; | 140 matrix.m44 = 9; |
71 assert_equals(matrix.a, matrix.m11); | 141 assert_equals(matrix.a, matrix.m11); |
72 assert_equals(matrix.b, matrix.m12); | 142 assert_equals(matrix.b, matrix.m12); |
73 assert_equals(matrix.c, matrix.m21); | 143 assert_equals(matrix.c, matrix.m21); |
(...skipping 27 matching lines...) Expand all Loading... | |
101 matrix.m31 = 1; | 171 matrix.m31 = 1; |
102 matrix.m33 = 0; | 172 matrix.m33 = 0; |
103 assert_false(matrix.is2D); | 173 assert_false(matrix.is2D); |
104 assert_false(matrix.isIdentity); | 174 assert_false(matrix.isIdentity); |
105 matrix.m31 = 0; | 175 matrix.m31 = 0; |
106 matrix.m33 = 1; | 176 matrix.m33 = 1; |
107 assert_false(matrix.is2D); | 177 assert_false(matrix.is2D); |
108 assert_true(matrix.isIdentity); | 178 assert_true(matrix.isIdentity); |
109 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before calling setMatrixValue()."); | 179 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before calling setMatrixValue()."); |
110 | 180 |
181 test(function() { | |
182 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array(0)); }, | |
dominicc (has gone to gerrit)
2016/09/07 17:44:31
Ah, this isn't exactly what I meant. The numbers i
Hwanseung Lee
2016/09/08 14:25:09
Done.
| |
183 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
184 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array(0)); }, | |
185 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
186 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array(1)); }, | |
187 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
188 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array(1)); }, | |
189 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
190 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array(5)); }, | |
191 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
192 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array(5)); }, | |
193 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
194 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array(7)); }, | |
195 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
196 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array(7)); }, | |
197 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
198 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array(15)); }, | |
199 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
200 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array(15)); }, | |
201 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
202 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array(17)); }, | |
203 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
204 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array(17)); }, | |
205 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
206 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array(65536)); }, | |
207 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
208 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array(65536)); }, | |
209 "DOMMatrix constructor only accepts 1 number sequence with 6 or 16 e lements."); | |
210 }, "DOMMatrix constructor - invalid arguments"); | |
211 | |
111 </script> | 212 </script> |
112 </body> | 213 </body> |
113 </html> | 214 </html> |
OLD | NEW |