@@ -60,9 +60,9 @@ describe('DOMMatrix Class Test', () => {
6060
6161 it ( 'Test init with incompatible CSSMatrix, DOMMatrix, JSON object' , ( ) => {
6262 // const css1 = {a: 0.94, b: 0.25, c: -0.25, d: 0.95, e: 0, f: 0, m11: 0.93, m12: 0.25, m13: -0.25, m14: 0, m21: -0.25, m22: 0.95, m23: 0, m24: 0, m31: 0.2, m32: 0.05, m33: 0.95, m34: 0, m41: 0, m42: 0, m43: 0, m44: 1};
63- const css1 = { a : 0.94 , b : 0.25 , c : - 0.25 , d : 0.95 , e : 0 , f : 0 , m11 : 0.93 , m12 : 0.25 , m13 : - 0.25 , m14 : 0 , m21 : - 0.25 , m22 : 0.95 , m23 : 0 , m24 : 0 , m31 : 0.2 , m32 : 0.05 , m33 : 0.95 , m34 : 0 , m41 : 0 , m42 : 0 , m43 : 0 , m44 : 1 } ;
64- const css2 = { m11 : 0.93 , m12 : 0.25 , m13 : - 0.25 , m14 : 0 , m21 : - 0.25 , m22 : 0.95 , m23 : 0 , m24 : 0 , m31 : 0.2 , m32 : 0.05 , m33 : 0.95 , m34 : 0 , m41 : 0 , m42 : 0 , m43 : 0 , m44 : 1 } ;
65- const css3 = { a : 0.94 , b : 0.25 , c : - 0.25 , d : 0.95 , e : 0 , f : 0 } ;
63+ const css1 = { a : 0.94 , b : 0.25 , c : - 0.25 , d : 0.95 , e : 0 , f : 0 , m11 : 0.93 , m12 : 0.25 , m13 : - 0.25 , m14 : 0 , m21 : - 0.25 , m22 : 0.95 , m23 : 0 , m24 : 0 , m31 : 0.2 , m32 : 0.05 , m33 : 0.95 , m34 : 0 , m41 : 0 , m42 : 0 , m43 : 0 , m44 : 1 } ;
64+ const css2 = { m11 : 0.93 , m12 : 0.25 , m13 : - 0.25 , m14 : 0 , m21 : - 0.25 , m22 : 0.95 , m23 : 0 , m24 : 0 , m31 : 0.2 , m32 : 0.05 , m33 : 0.95 , m34 : 0 , m41 : 0 , m42 : 0 , m43 : 0 , m44 : 1 } ;
65+ const css3 = { a : 0.94 , b : 0.25 , c : - 0.25 , d : 0.95 , e : 0 , f : 0 } ;
6666
6767 [ css1 , css2 , css3 ] . forEach ( ( c ) => {
6868 try {
@@ -89,7 +89,7 @@ describe('DOMMatrix Class Test', () => {
8989 it ( 'Test specific private methods' , ( ) => {
9090 try {
9191 // @ts -ignore
92- new CSSMatrix ( ) . rotateAxisAngle ( 'a' , 'true' , 'wombat' , '05' ) ;
92+ new CSSMatrix ( ) . rotateAxisAngle ( 'a' , 'true' , 'wombat' , '05' ) ;
9393 } catch ( err ) {
9494 expect ( err ) . to . be . instanceOf ( TypeError ) ;
9595 expect ( err ) . to . have . property ( 'message' , 'CSSMatrix: expecting 4 values' ) ;
@@ -117,95 +117,95 @@ describe('DOMMatrix Class Test', () => {
117117 . to . deep . equal ( Array . from ( d1 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
118118
119119 console . log ( 'CSSMatrix.rotate(x:25, y:15)' ) ;
120- const d2 = new DOMMatrix ( ) . rotate ( 25 , 15 ) ;
121- const m2 = new CSSMatrix ( ) . rotate ( 25 , 15 ) ;
122- cssDiv . style . transform = m2 . toString ( ) ;
123- domDiv . style . transform = d2 . toString ( ) ;
120+ const d2 = new DOMMatrix ( ) . rotate ( 25 , 15 ) ;
121+ const m2 = new CSSMatrix ( ) . rotate ( 25 , 15 ) ;
122+ cssDiv . style . transform = m2 . toString ( ) ;
123+ domDiv . style . transform = d2 . toString ( ) ;
124124
125- expect ( m2 . isIdentity ) . to . equal ( d2 . isIdentity ) ;
126- expect ( m2 . is2D ) . to . equal ( d2 . is2D ) ;
125+ expect ( m2 . isIdentity ) . to . equal ( d2 . isIdentity ) ;
126+ expect ( m2 . is2D ) . to . equal ( d2 . is2D ) ;
127127
128- // same here
129- // expect(m2.toFloat32Array()).to.deep.equal(d2.toFloat32Array());
130- // expect(m2.toFloat64Array()).to.deep.equal(d2.toFloat64Array());
131- expect ( Array . from ( m2 . toFloat32Array ( ) ) . map ( roundTo4 ) )
132- . to . deep . equal ( Array . from ( d2 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
133- expect ( Array . from ( m2 . toFloat64Array ( ) ) . map ( roundTo4 ) )
134- . to . deep . equal ( Array . from ( d2 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
128+ // same here
129+ // expect(m2.toFloat32Array()).to.deep.equal(d2.toFloat32Array());
130+ // expect(m2.toFloat64Array()).to.deep.equal(d2.toFloat64Array());
131+ expect ( Array . from ( m2 . toFloat32Array ( ) ) . map ( roundTo4 ) )
132+ . to . deep . equal ( Array . from ( d2 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
133+ expect ( Array . from ( m2 . toFloat64Array ( ) ) . map ( roundTo4 ) )
134+ . to . deep . equal ( Array . from ( d2 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
135135
136136
137137 console . log ( 'CSSMatrix.translate(x:150)' ) ;
138- const d3 = new DOMMatrix ( ) . translate ( 150 ) ;
139- const m3 = new CSSMatrix ( ) . translate ( 150 ) ;
140-
141- cssDiv . style . transform = m3 . toString ( ) ;
142- domDiv . style . transform = d3 . toString ( ) ;
143- expect ( m3 . isIdentity ) . to . equal ( d3 . isIdentity ) ;
144- expect ( m3 . is2D ) . to . equal ( d3 . is2D ) ;
145- // expect(m3.toFloat32Array()).to.deep.equal(d3.toFloat32Array());
146- // expect(m3.toFloat64Array()).to.deep.equal(d3.toFloat64Array());
147- expect ( Array . from ( m3 . toFloat32Array ( ) ) . map ( roundTo4 ) )
148- . to . deep . equal ( Array . from ( d3 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
149- expect ( Array . from ( m3 . toFloat64Array ( ) ) . map ( roundTo4 ) )
150- . to . deep . equal ( Array . from ( d3 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
138+ const d3 = new DOMMatrix ( ) . translate ( 150 ) ;
139+ const m3 = new CSSMatrix ( ) . translate ( 150 ) ;
140+
141+ cssDiv . style . transform = m3 . toString ( ) ;
142+ domDiv . style . transform = d3 . toString ( ) ;
143+ expect ( m3 . isIdentity ) . to . equal ( d3 . isIdentity ) ;
144+ expect ( m3 . is2D ) . to . equal ( d3 . is2D ) ;
145+ // expect(m3.toFloat32Array()).to.deep.equal(d3.toFloat32Array());
146+ // expect(m3.toFloat64Array()).to.deep.equal(d3.toFloat64Array());
147+ expect ( Array . from ( m3 . toFloat32Array ( ) ) . map ( roundTo4 ) )
148+ . to . deep . equal ( Array . from ( d3 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
149+ expect ( Array . from ( m3 . toFloat64Array ( ) ) . map ( roundTo4 ) )
150+ . to . deep . equal ( Array . from ( d3 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
151151
152152 console . log ( 'CSSMatrix.skew(x:15, y:-20)' ) ;
153- const d4 = new DOMMatrix ( 'skew(15deg, -20deg)' ) ;
154- const m4 = new CSSMatrix ( ) . skew ( 15 , - 20 ) ;
155- console . log ( 'In this test we\'re addapting to the output of the native DOMMatrix method since it doesn\'t support the skew() method itself.' ) ;
156- cssDiv . style . transform = m4 . toString ( ) ;
157- domDiv . style . transform = d4 . toString ( ) ;
158- expect ( m4 . isIdentity ) . to . equal ( d4 . isIdentity ) ;
159- expect ( m4 . is2D ) . to . equal ( d4 . is2D ) ;
160- // expect(m4.toFloat32Array()).to.deep.equal(d4.toFloat32Array());
161- // expect(m4.toFloat64Array()).to.deep.equal(d4.toFloat64Array());
162- expect ( Array . from ( m4 . toFloat32Array ( ) ) . map ( roundTo4 ) )
163- . to . deep . equal ( Array . from ( d4 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
164- expect ( Array . from ( m4 . toFloat64Array ( ) ) . map ( roundTo4 ) )
165- . to . deep . equal ( Array . from ( d4 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
153+ const d4 = new DOMMatrix ( 'skew(15deg, -20deg)' ) ;
154+ const m4 = new CSSMatrix ( ) . skew ( 15 , - 20 ) ;
155+ console . log ( 'In this test we\'re addapting to the output of the native DOMMatrix method since it doesn\'t support the skew() method itself.' ) ;
156+ cssDiv . style . transform = m4 . toString ( ) ;
157+ domDiv . style . transform = d4 . toString ( ) ;
158+ expect ( m4 . isIdentity ) . to . equal ( d4 . isIdentity ) ;
159+ expect ( m4 . is2D ) . to . equal ( d4 . is2D ) ;
160+ // expect(m4.toFloat32Array()).to.deep.equal(d4.toFloat32Array());
161+ // expect(m4.toFloat64Array()).to.deep.equal(d4.toFloat64Array());
162+ expect ( Array . from ( m4 . toFloat32Array ( ) ) . map ( roundTo4 ) )
163+ . to . deep . equal ( Array . from ( d4 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
164+ expect ( Array . from ( m4 . toFloat64Array ( ) ) . map ( roundTo4 ) )
165+ . to . deep . equal ( Array . from ( d4 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
166166
167167 console . log ( 'CSSMatrix.scale(x:1.3)' ) ;
168- const d5 = new DOMMatrix ( ) . scale ( 1.3 ) ;
169- const m5 = new CSSMatrix ( ) . scale ( 1.3 ) ;
170-
171- cssDiv . style . transform = m5 . toString ( ) ;
172- domDiv . style . transform = d5 . toString ( ) ;
173- expect ( m5 . isIdentity ) . to . equal ( d5 . isIdentity ) ;
174- expect ( m5 . is2D ) . to . equal ( d5 . is2D ) ;
175- // expect(m5.toFloat32Array()).to.deep.equal(d5.toFloat32Array());
176- // expect(m5.toFloat64Array()).to.deep.equal(d5.toFloat64Array());
177- expect ( Array . from ( m5 . toFloat32Array ( ) ) . map ( roundTo4 ) )
178- . to . deep . equal ( Array . from ( d5 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
179- expect ( Array . from ( m5 . toFloat64Array ( ) ) . map ( roundTo4 ) )
180- . to . deep . equal ( Array . from ( d5 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
168+ const d5 = new DOMMatrix ( ) . scale ( 1.3 ) ;
169+ const m5 = new CSSMatrix ( ) . scale ( 1.3 ) ;
170+
171+ cssDiv . style . transform = m5 . toString ( ) ;
172+ domDiv . style . transform = d5 . toString ( ) ;
173+ expect ( m5 . isIdentity ) . to . equal ( d5 . isIdentity ) ;
174+ expect ( m5 . is2D ) . to . equal ( d5 . is2D ) ;
175+ // expect(m5.toFloat32Array()).to.deep.equal(d5.toFloat32Array());
176+ // expect(m5.toFloat64Array()).to.deep.equal(d5.toFloat64Array());
177+ expect ( Array . from ( m5 . toFloat32Array ( ) ) . map ( roundTo4 ) )
178+ . to . deep . equal ( Array . from ( d5 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
179+ expect ( Array . from ( m5 . toFloat64Array ( ) ) . map ( roundTo4 ) )
180+ . to . deep . equal ( Array . from ( d5 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
181181
182182 console . log ( 'CSSMatrix.scale(x:1.3,y:1.8)' ) ;
183- const d6 = new DOMMatrix ( ) . scale ( 1.3 , 1.8 ) ;
184- const m6 = new CSSMatrix ( ) . scale ( 1.3 , 1.8 ) ;
185- cssDiv . style . transform = m6 . toString ( ) ;
186- domDiv . style . transform = d6 . toString ( ) ;
187- expect ( m6 . isIdentity ) . to . equal ( d6 . isIdentity ) ;
188- expect ( m6 . is2D ) . to . equal ( d6 . is2D ) ;
189- // expect(m6.toFloat32Array()).to.deep.equal(d6.toFloat32Array());
190- // expect(m6.toFloat64Array()).to.deep.equal(d6.toFloat64Array());
191- expect ( Array . from ( m6 . toFloat32Array ( ) ) . map ( roundTo4 ) )
192- . to . deep . equal ( Array . from ( d6 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
193- expect ( Array . from ( m6 . toFloat64Array ( ) ) . map ( roundTo4 ) )
194- . to . deep . equal ( Array . from ( d6 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
183+ const d6 = new DOMMatrix ( ) . scale ( 1.3 , 1.8 ) ;
184+ const m6 = new CSSMatrix ( ) . scale ( 1.3 , 1.8 ) ;
185+ cssDiv . style . transform = m6 . toString ( ) ;
186+ domDiv . style . transform = d6 . toString ( ) ;
187+ expect ( m6 . isIdentity ) . to . equal ( d6 . isIdentity ) ;
188+ expect ( m6 . is2D ) . to . equal ( d6 . is2D ) ;
189+ // expect(m6.toFloat32Array()).to.deep.equal(d6.toFloat32Array());
190+ // expect(m6.toFloat64Array()).to.deep.equal(d6.toFloat64Array());
191+ expect ( Array . from ( m6 . toFloat32Array ( ) ) . map ( roundTo4 ) )
192+ . to . deep . equal ( Array . from ( d6 . toFloat32Array ( ) ) . map ( roundTo4 ) ) ;
193+ expect ( Array . from ( m6 . toFloat64Array ( ) ) . map ( roundTo4 ) )
194+ . to . deep . equal ( Array . from ( d6 . toFloat64Array ( ) ) . map ( roundTo4 ) ) ;
195195
196196 console . log ( 'CSSMatrix.transformPoint' ) ;
197- const p1 = new DOMPoint ( 15 , 20 , 35 , 1 ) ;
198- const p2 = { x : 15 , y : 20 , z : 35 , w : 1 } ;
199- const dp = new DOMMatrix ( ) . rotate ( 15 ) . translate ( 15 , 15 ) ;
200- const mp = new CSSMatrix ( ) . rotate ( 15 ) . translate ( 15 , 15 ) ;
201-
202- console . log ( 'For some reason the native DOMMatrix again falsely claims **is2D** to be true' ) ;
203- expect ( mp . isIdentity ) . to . equal ( dp . isIdentity ) ;
204- expect ( mp . is2D ) . to . equal ( dp . is2D ) ;
205- expect ( mp . toFloat32Array ( ) ) . to . deep . equal ( dp . toFloat32Array ( ) ) ;
206- expect ( mp . toFloat64Array ( ) ) . to . deep . equal ( dp . toFloat64Array ( ) ) ;
207- expect ( mp . transformPoint ( p1 ) ) . to . deep . equal ( dp . transformPoint ( p1 ) ) ;
208- expect ( mp . transformPoint ( p2 ) ) . to . deep . equal ( dp . transformPoint ( p2 ) . toJSON ( ) ) ;
197+ const p1 = new DOMPoint ( 15 , 20 , 35 , 1 ) ;
198+ const p2 = { x : 15 , y : 20 , z : 35 , w : 1 } ;
199+ const dp = new DOMMatrix ( ) . rotate ( 15 ) . translate ( 15 , 15 ) ;
200+ const mp = new CSSMatrix ( ) . rotate ( 15 ) . translate ( 15 , 15 ) ;
201+
202+ console . log ( 'For some reason the native DOMMatrix again falsely claims **is2D** to be true' ) ;
203+ expect ( mp . isIdentity ) . to . equal ( dp . isIdentity ) ;
204+ expect ( mp . is2D ) . to . equal ( dp . is2D ) ;
205+ expect ( mp . toFloat32Array ( ) ) . to . deep . equal ( dp . toFloat32Array ( ) ) ;
206+ expect ( mp . toFloat64Array ( ) ) . to . deep . equal ( dp . toFloat64Array ( ) ) ;
207+ expect ( mp . transformPoint ( p1 ) ) . to . deep . equal ( dp . transformPoint ( p1 ) ) ;
208+ expect ( mp . transformPoint ( p2 ) ) . to . deep . equal ( dp . transformPoint ( p2 ) . toJSON ( ) ) ;
209209 } ) ;
210210
211211 it ( 'Test init a 6 values array' , ( ) => {
@@ -219,7 +219,7 @@ describe('DOMMatrix Class Test', () => {
219219 expect ( m1 . toFloat64Array ( ) ) . to . deep . equal ( m4 . toFloat64Array ( ) )
220220 } ) ;
221221
222- it ( 'Test init a 16 values array' , ( ) => {
222+ it ( 'Test init a 16 values array' , ( ) => {
223223 const test = [ 0.852 , 0.153 , 0.186 , - 0.0004 , - 0.092 , 0.869 , - 0.266 , 0.0006 , - 0.25 , 0.258 , 0.933 , - 0.002 , 0 , 0 , 0 , 1 ] as Matrix3d ;
224224 const m1 = new CSSMatrix ( test ) ;
225225 // const m2 = new CSSMatrix(...test);
@@ -232,7 +232,7 @@ describe('DOMMatrix Class Test', () => {
232232
233233 it ( 'Test static methods' , ( ) => {
234234 const m = new CSSMatrix ( ) ;
235- const source = { a : 1 } ;
235+ const source = { a : 1 } ;
236236 const source1 = 'wombat(1)' ;
237237 const source2 = 'skew()' ;
238238 const source3 = 'translate(wombat)' ;
@@ -277,7 +277,7 @@ describe('DOMMatrix Class Test', () => {
277277 const dom = new DOMMatrix ( str ) ;
278278 const cssDiv = container . querySelector ( '.bg-primary' ) as HTMLElement ;
279279 const domDiv = container . querySelector ( '.bg-secondary' ) as HTMLElement ;
280-
280+
281281 cssDiv . style . transform = css . toString ( ) ;
282282 domDiv . style . transform = dom . toString ( ) ;
283283
0 commit comments