fix DOM precision

This commit is contained in:
“chrisshank” 2024-12-18 23:57:54 -08:00
parent 207c81e9df
commit bb152d6145
1 changed files with 3 additions and 4 deletions

View File

@ -1,7 +1,6 @@
import type { Point } from './types'; import type { Point } from './types';
// TODO: find right value for precision export const toDOMPrecision = (value: number) => Math.round(value * 1e4) / 1e4;
const roundToDomPrecision = (value: number) => Math.round(value * 100000) / 100000;
const PI2 = Math.PI * 2; const PI2 = Math.PI * 2;
const TAU = Math.PI / 2; const TAU = Math.PI / 2;
@ -276,9 +275,9 @@ export class Matrix implements IMatrix {
} }
static ToCssString(m: MatrixInit) { static ToCssString(m: MatrixInit) {
return `matrix(${roundToDomPrecision(m.a)}, ${roundToDomPrecision(m.b)}, ${roundToDomPrecision( return `matrix(${toDOMPrecision(m.a)}, ${toDOMPrecision(m.b)}, ${toDOMPrecision(
m.c m.c
)}, ${roundToDomPrecision(m.d)}, ${roundToDomPrecision(m.e)}, ${roundToDomPrecision(m.f)})`; )}, ${toDOMPrecision(m.d)}, ${toDOMPrecision(m.e)}, ${toDOMPrecision(m.f)})`;
} }
} }