OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Geometry Interfaces: DOMMatrix translate</title> | 4 <title>Geometry Interfaces: DOMMatrix translate</title> |
5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <script> | 8 <script> |
9 | 9 |
10 function toArray(matrix) | |
11 { | |
12 return [ matrix.m11, matrix.m21, matrix.m31, matrix.m41, | |
13 matrix.m12, matrix.m22, matrix.m32, matrix.m42, | |
14 matrix.m13, matrix.m23, matrix.m33, matrix.m43, | |
15 matrix.m14, matrix.m24, matrix.m34, matrix.m44 ]; | |
16 } | |
17 | |
18 test(function() { | 10 test(function() { |
19 var matrix = new DOMMatrix(); | 11 var matrix = new DOMMatrix(); |
20 assert_true(matrix.is2D); | 12 assert_true(matrix.is2D); |
21 assert_true(matrix.isIdentity); | 13 assert_true(matrix.isIdentity); |
22 assert_array_equals(toArray(matrix), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 14 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 0, 0, 0, 1 ]); |
23 var result = matrix.translate(2, 3); | 15 var result = matrix.translate(2, 3); |
24 assert_true(result.is2D); | 16 assert_true(result.is2D); |
25 assert_false(result.isIdentity); | 17 assert_false(result.isIdentity); |
26 assert_array_equals(toArray(result), [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 18 assert_array_equals(result.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 2, 3, 0, 1 ]); |
27 assert_true(matrix.is2D); | 19 assert_true(matrix.is2D); |
28 assert_true(matrix.isIdentity); | 20 assert_true(matrix.isIdentity); |
29 assert_array_equals(toArray(matrix), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 21 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 0, 0, 0, 1 ]); |
30 }, "DOMMatrix.translate(tx, ty)"); | 22 }, "DOMMatrix.translate(tx, ty)"); |
31 | 23 |
32 test(function() { | 24 test(function() { |
33 var matrix = new DOMMatrix(); | 25 var matrix = new DOMMatrix(); |
34 matrix.translateSelf(2, 3); | 26 matrix.translateSelf(2, 3); |
35 assert_true(matrix.is2D); | 27 assert_true(matrix.is2D); |
36 assert_false(matrix.isIdentity); | 28 assert_false(matrix.isIdentity); |
37 assert_array_equals(toArray(matrix), [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 29 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 2, 3, 0, 1 ]); |
38 var result = matrix.translate(4, 2); | 30 var result = matrix.translate(4, 2); |
39 assert_true(result.is2D); | 31 assert_true(result.is2D); |
40 assert_false(result.isIdentity); | 32 assert_false(result.isIdentity); |
41 assert_array_equals(toArray(result), [ 1, 0, 0, 6, 0, 1, 0, 5, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 33 assert_array_equals(result.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 6, 5, 0, 1 ]); |
42 assert_true(matrix.is2D); | 34 assert_true(matrix.is2D); |
43 assert_false(matrix.isIdentity); | 35 assert_false(matrix.isIdentity); |
44 assert_array_equals(toArray(matrix), [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 36 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 2, 3, 0, 1 ]); |
45 }, "DOMMatrix.translate(tx, ty) with non-identity"); | 37 }, "DOMMatrix.translate(tx, ty) with non-identity"); |
46 | 38 |
47 test(function() { | 39 test(function() { |
48 var matrix = new DOMMatrix(); | 40 var matrix = new DOMMatrix(); |
49 assert_true(matrix.is2D); | 41 assert_true(matrix.is2D); |
50 assert_true(matrix.isIdentity); | 42 assert_true(matrix.isIdentity); |
51 assert_array_equals(toArray(matrix), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 43 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 0, 0, 0, 1 ]); |
52 var result = matrix.translateSelf(4, 2); | 44 var result = matrix.translateSelf(4, 2); |
53 assert_true(result.is2D); | 45 assert_true(result.is2D); |
54 assert_false(result.isIdentity); | 46 assert_false(result.isIdentity); |
55 assert_array_equals(toArray(result), [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 47 assert_array_equals(result.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 4, 2, 0, 1 ]); |
56 assert_true(matrix.is2D); | 48 assert_true(matrix.is2D); |
57 assert_false(matrix.isIdentity); | 49 assert_false(matrix.isIdentity); |
58 assert_array_equals(toArray(matrix), [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 50 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 4, 2, 0, 1 ]); |
59 }, "DOMMatrix.translateSelf(tx, ty)"); | 51 }, "DOMMatrix.translateSelf(tx, ty)"); |
60 | 52 |
61 test(function() { | 53 test(function() { |
62 var matrix = new DOMMatrix(); | 54 var matrix = new DOMMatrix(); |
63 assert_true(matrix.is2D); | 55 assert_true(matrix.is2D); |
64 assert_true(matrix.isIdentity); | 56 assert_true(matrix.isIdentity); |
65 assert_array_equals(toArray(matrix), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 57 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 0, 0, 0, 1 ]); |
66 var result = matrix.translate(2, 3, 4); | 58 var result = matrix.translate(2, 3, 4); |
67 assert_false(result.is2D); | 59 assert_false(result.is2D); |
68 assert_false(result.isIdentity); | 60 assert_false(result.isIdentity); |
69 assert_array_equals(toArray(result), [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0,
0, 0, 1 ]); | 61 assert_array_equals(result.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 2, 3, 4, 1 ]); |
70 assert_true(matrix.is2D); | 62 assert_true(matrix.is2D); |
71 assert_true(matrix.isIdentity); | 63 assert_true(matrix.isIdentity); |
72 assert_array_equals(toArray(matrix), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 64 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 0, 0, 0, 1 ]); |
73 }, "DOMMatrix.translate(tx, ty, tz)"); | 65 }, "DOMMatrix.translate(tx, ty, tz)"); |
74 | 66 |
75 test(function() { | 67 test(function() { |
76 var matrix = new DOMMatrix(); | 68 var matrix = new DOMMatrix(); |
77 matrix.translateSelf(2, 3); | 69 matrix.translateSelf(2, 3); |
78 assert_true(matrix.is2D); | 70 assert_true(matrix.is2D); |
79 assert_false(matrix.isIdentity); | 71 assert_false(matrix.isIdentity); |
80 assert_array_equals(toArray(matrix), [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 72 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 2, 3, 0, 1 ]); |
81 var result = matrix.translate(4, 2, 3); | 73 var result = matrix.translate(4, 2, 3); |
82 assert_false(result.is2D); | 74 assert_false(result.is2D); |
83 assert_false(result.isIdentity); | 75 assert_false(result.isIdentity); |
84 assert_array_equals(toArray(result), [ 1, 0, 0, 6, 0, 1, 0, 5, 0, 0, 1, 3, 0,
0, 0, 1 ]); | 76 assert_array_equals(result.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 6, 5, 3, 1 ]); |
85 assert_true(matrix.is2D); | 77 assert_true(matrix.is2D); |
86 assert_false(matrix.isIdentity); | 78 assert_false(matrix.isIdentity); |
87 assert_array_equals(toArray(matrix), [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 79 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 2, 3, 0, 1 ]); |
88 }, "DOMMatrix.translate(tx, ty, tz) with non-identity"); | 80 }, "DOMMatrix.translate(tx, ty, tz) with non-identity"); |
89 | 81 |
90 test(function() { | 82 test(function() { |
91 var matrix = new DOMMatrix(); | 83 var matrix = new DOMMatrix(); |
92 assert_true(matrix.is2D); | 84 assert_true(matrix.is2D); |
93 assert_true(matrix.isIdentity); | 85 assert_true(matrix.isIdentity); |
94 assert_array_equals(toArray(matrix), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1 ]); | 86 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 0, 0, 0, 1 ]); |
95 var result = matrix.translateSelf(4, 2, 3); | 87 var result = matrix.translateSelf(4, 2, 3); |
96 assert_false(result.is2D); | 88 assert_false(result.is2D); |
97 assert_false(result.isIdentity); | 89 assert_false(result.isIdentity); |
98 assert_array_equals(toArray(result), [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 3, 0,
0, 0, 1 ]); | 90 assert_array_equals(result.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 4, 2, 3, 1 ]); |
99 assert_false(matrix.is2D); | 91 assert_false(matrix.is2D); |
100 assert_false(matrix.isIdentity); | 92 assert_false(matrix.isIdentity); |
101 assert_array_equals(toArray(matrix), [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 3, 0,
0, 0, 1 ]); | 93 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
, 0, 4, 2, 3, 1 ]); |
102 }, "DOMMatrix.translateSelf(tx, ty, tz)"); | 94 }, "DOMMatrix.translateSelf(tx, ty, tz)"); |
103 | 95 |
104 test(function() { | 96 test(function() { |
105 var matrix = new DOMMatrix(); | 97 var matrix = new DOMMatrix(); |
106 assert_true(matrix.is2D); | 98 assert_true(matrix.is2D); |
107 assert_true(matrix.isIdentity); | 99 assert_true(matrix.isIdentity); |
108 matrix.m14 = 2; | 100 matrix.m14 = 2; |
109 matrix.m24 = 3; | 101 matrix.m24 = 3; |
110 matrix.m34 = 4; | 102 matrix.m34 = 4; |
111 matrix.m44 = 7; | 103 matrix.m44 = 7; |
112 assert_false(matrix.is2D); | 104 assert_false(matrix.is2D); |
113 assert_false(matrix.isIdentity); | 105 assert_false(matrix.isIdentity); |
114 assert_array_equals(toArray(matrix), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2,
3, 4, 7 ]); | 106 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1
, 4, 0, 0, 0, 7 ]); |
115 matrix.translateSelf(7, -8, 2); | 107 matrix.translateSelf(7, -8, 2); |
116 assert_false(matrix.is2D); | 108 assert_false(matrix.is2D); |
117 assert_false(matrix.isIdentity); | 109 assert_false(matrix.isIdentity); |
118 assert_array_equals(toArray(matrix), [ 1, 0, 0, 7, 0, 1, 0, -8, 0, 0, 1, 2, 2,
3, 4, 5 ]); | 110 assert_array_equals(matrix.toFloat64Array(), [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1
, 4, 7, -8, 2, 5 ]); |
119 }, "DOMMatrix.translateSelf(tx, ty, tz) Homogeneous Coordinates"); | 111 }, "DOMMatrix.translateSelf(tx, ty, tz) Homogeneous Coordinates"); |
120 | 112 |
121 </script> | 113 </script> |
122 </body> | 114 </body> |
123 </html> | 115 </html> |
OLD | NEW |