@@ -24,6 +24,7 @@ import {
2424 stringToPDFString ,
2525 Util ,
2626} from "../../src/shared/util.js" ;
27+ import { DOMMatrix , DOMPoint } from "@napi-rs/canvas" ;
2728
2829describe ( "util" , function ( ) {
2930 describe ( "BaseException" , function ( ) {
@@ -269,17 +270,16 @@ describe("util", function () {
269270 ] ;
270271
271272 for ( const { transform, points : original } of cases ) {
273+ const M = new DOMMatrix ( transform ) ;
272274 const pts = original . slice ( ) ;
273275
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 ] ;
280279
281280 Util . applyTransform ( pts , transform , 0 ) ;
282281 Util . applyTransform ( pts , transform , 2 ) ;
282+
283283 expect ( pts ) . toEqual ( expected ) ;
284284 }
285285 } ) ;
0 commit comments