4 <title>Geometry Interfaces: DOMMatrix scale
</title>
5 <script src=
"../../resources/testharness.js"></script>
6 <script src=
"../../resources/testharnessreport.js"></script>
12 var matrix
= new DOMMatrix();
13 assert_true(matrix
.is2D
);
14 assert_true(matrix
.isIdentity
);
15 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
16 var result
= matrix
.scale(3);
17 assert_true(result
.is2D
);
18 assert_false(result
.isIdentity
);
19 assert_array_equals(result
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
20 assert_true(matrix
.is2D
);
21 assert_true(matrix
.isIdentity
);
22 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
23 }, "DOMMatrix.scale(scale)");
26 var matrix
= new DOMMatrix();
27 assert_true(matrix
.is2D
);
28 assert_true(matrix
.isIdentity
);
29 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
30 var result
= matrix
.scale(3, 4, 2);
31 assert_true(result
.is2D
);
32 assert_false(result
.isIdentity
);
33 assert_array_equals(result
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, -8, -4, 0, 1 ]);
34 assert_true(matrix
.is2D
);
35 assert_true(matrix
.isIdentity
);
36 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
37 }, "DOMMatrix.scale(scale, ox, oy)");
40 var matrix
= new DOMMatrix();
41 assert_true(matrix
.is2D
);
42 assert_true(matrix
.isIdentity
);
43 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
44 var result
= matrix
.scale3d(3);
45 assert_false(result
.is2D
);
46 assert_false(result
.isIdentity
);
47 assert_array_equals(result
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1 ]);
48 assert_true(matrix
.is2D
);
49 assert_true(matrix
.isIdentity
);
50 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
51 }, "DOMMatrix.scale3d(scale)");
54 var matrix
= new DOMMatrix();
55 assert_true(matrix
.is2D
);
56 assert_true(matrix
.isIdentity
);
57 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
58 var result
= matrix
.scale3d(3, 2, 7, -1);
59 assert_false(result
.is2D
);
60 assert_false(result
.isIdentity
);
61 assert_array_equals(result
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, -4, -14, 2, 1 ]);
62 assert_true(matrix
.is2D
);
63 assert_true(matrix
.isIdentity
);
64 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
65 }, "DOMMatrix.scale3d(scale, ox, oy, oz)");
68 var matrix
= new DOMMatrix();
69 assert_true(matrix
.is2D
);
70 assert_true(matrix
.isIdentity
);
71 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
72 var result
= matrix
.scaleNonUniform(2, 3, 0.5, 2, -4, -1);
73 assert_false(result
.is2D
);
74 assert_false(result
.isIdentity
);
75 assert_array_equals(result
.toFloat64Array(), [ 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0.5, 0, -2, 8, -0.5, 1 ]);
76 assert_true(matrix
.is2D
);
77 assert_true(matrix
.isIdentity
);
78 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
79 }, "DOMMatrix.scaleNonUniform(sx, sy, sz, ox, oy, oz)");
82 var matrix
= new DOMMatrix();
83 assert_true(matrix
.is2D
);
84 assert_true(matrix
.isIdentity
);
85 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
86 var result
= matrix
.scaleSelf(3);
87 assert_true(result
.is2D
);
88 assert_false(result
.isIdentity
);
89 assert_array_equals(result
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
90 assert_true(matrix
.is2D
);
91 assert_false(matrix
.isIdentity
);
92 assert_array_equals(matrix
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
93 }, "DOMMatrix.scaleSelf(scale)");
96 var matrix
= new DOMMatrix();
97 assert_true(matrix
.is2D
);
98 assert_true(matrix
.isIdentity
);
99 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
100 var result
= matrix
.scaleSelf(3, 4, 2);
101 assert_true(result
.is2D
);
102 assert_false(result
.isIdentity
);
103 assert_array_equals(result
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, -8, -4, 0, 1 ]);
104 assert_true(matrix
.is2D
);
105 assert_false(matrix
.isIdentity
);
106 assert_array_equals(matrix
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, -8, -4, 0, 1 ]);
107 }, "DOMMatrix.scaleSelf(scale)");
110 var matrix
= new DOMMatrix();
111 assert_true(matrix
.is2D
);
112 assert_true(matrix
.isIdentity
);
113 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
114 var result
= matrix
.scale3dSelf(3);
115 assert_false(result
.is2D
);
116 assert_false(result
.isIdentity
);
117 assert_array_equals(result
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1 ]);
118 assert_false(matrix
.is2D
);
119 assert_false(matrix
.isIdentity
);
120 assert_array_equals(matrix
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1 ]);
121 }, "DOMMatrix.scale3dSelf(scale)");
124 var matrix
= new DOMMatrix();
125 assert_true(matrix
.is2D
);
126 assert_true(matrix
.isIdentity
);
127 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
128 var result
= matrix
.scale3dSelf(3, 2, 7, -1);
129 assert_false(result
.is2D
);
130 assert_false(result
.isIdentity
);
131 assert_array_equals(result
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, -4, -14, 2, 1 ]);
132 assert_false(matrix
.is2D
);
133 assert_false(matrix
.isIdentity
);
134 assert_array_equals(matrix
.toFloat64Array(), [ 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, -4, -14, 2, 1 ]);
135 }, "DOMMatrix.scale3dSelf(scale, ox, oy, oz)");
138 var matrix
= new DOMMatrix();
139 assert_true(matrix
.is2D
);
140 assert_true(matrix
.isIdentity
);
141 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
142 var result
= matrix
.scaleNonUniformSelf(2, 3, 0.5, 2, -4, -1);
143 assert_false(result
.is2D
);
144 assert_false(result
.isIdentity
);
145 assert_array_equals(result
.toFloat64Array(), [ 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0.5, 0, -2, 8, -0.5, 1 ]);
146 assert_false(matrix
.is2D
);
147 assert_false(matrix
.isIdentity
);
148 assert_array_equals(matrix
.toFloat64Array(), [ 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0.5, 0, -2, 8, -0.5, 1 ]);
149 }, "DOMMatrix.scaleNonUniformSelf(sx, sy, sz, ox, oy, oz)");
152 var matrix
= new DOMMatrix();
153 assert_true(matrix
.is2D
);
154 assert_true(matrix
.isIdentity
);
155 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
156 var result
= matrix
.scaleNonUniformSelf(1, 1, 1, 2, -4, -1);
157 assert_false(result
.is2D
);
158 assert_true(result
.isIdentity
);
159 assert_array_equals(result
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
160 assert_false(matrix
.is2D
);
161 assert_true(matrix
.isIdentity
);
162 assert_array_equals(matrix
.toFloat64Array(), [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]);
163 }, "DOMMatrix.scaleNonUniformSelf(1, 1, 1, ox, oy, oz)");