@@ -24,6 +24,7 @@ import {
24
24
stringToPDFString ,
25
25
Util ,
26
26
} from "../../src/shared/util.js" ;
27
+ import { DOMMatrix , DOMPoint } from "@napi-rs/canvas" ;
27
28
28
29
describe ( "util" , function ( ) {
29
30
describe ( "BaseException" , function ( ) {
@@ -269,17 +270,16 @@ describe("util", function () {
269
270
] ;
270
271
271
272
for ( const { transform, points : original } of cases ) {
273
+ const M = new DOMMatrix ( transform ) ;
272
274
const pts = original . slice ( ) ;
273
275
274
- const [ a , b , c , d , e , f ] = transform ;
275
- const ex0x = a * original [ 0 ] + c * original [ 1 ] + e ;
276
- const ex0y = b * original [ 0 ] + d * original [ 1 ] + f ;
277
- const ex1x = a * original [ 2 ] + c * original [ 3 ] + e ;
278
- const ex1y = b * original [ 2 ] + d * original [ 3 ] + f ;
279
- const expected = [ ex0x , ex0y , ex1x , ex1y ] ;
276
+ const p0 = M . transformPoint ( new DOMPoint ( original [ 0 ] , original [ 1 ] ) ) ;
277
+ const p1 = M . transformPoint ( new DOMPoint ( original [ 2 ] , original [ 3 ] ) ) ;
278
+ const expected = [ p0 . x , p0 . y , p1 . x , p1 . y ] ;
280
279
281
280
Util . applyTransform ( pts , transform , 0 ) ;
282
281
Util . applyTransform ( pts , transform , 2 ) ;
282
+
283
283
expect ( pts ) . toEqual ( expected ) ;
284
284
}
285
285
} ) ;
0 commit comments