From bb152d6145f8f468c2f9d805bc47f42426cb5a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cchrisshank=E2=80=9D?= Date: Wed, 18 Dec 2024 23:57:54 -0800 Subject: [PATCH] fix DOM precision --- lib/Matrix.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Matrix.ts b/lib/Matrix.ts index 64467be..440df2c 100644 --- a/lib/Matrix.ts +++ b/lib/Matrix.ts @@ -1,7 +1,6 @@ import type { Point } from './types'; -// TODO: find right value for precision -const roundToDomPrecision = (value: number) => Math.round(value * 100000) / 100000; +export const toDOMPrecision = (value: number) => Math.round(value * 1e4) / 1e4; const PI2 = Math.PI * 2; const TAU = Math.PI / 2; @@ -276,9 +275,9 @@ export class Matrix implements IMatrix { } static ToCssString(m: MatrixInit) { - return `matrix(${roundToDomPrecision(m.a)}, ${roundToDomPrecision(m.b)}, ${roundToDomPrecision( + return `matrix(${toDOMPrecision(m.a)}, ${toDOMPrecision(m.b)}, ${toDOMPrecision( m.c - )}, ${roundToDomPrecision(m.d)}, ${roundToDomPrecision(m.e)}, ${roundToDomPrecision(m.f)})`; + )}, ${toDOMPrecision(m.d)}, ${toDOMPrecision(m.e)}, ${toDOMPrecision(m.f)})`; } }