From 41633a91ad736b864d55828677f9b9286d7a75a8 Mon Sep 17 00:00:00 2001 From: zepumph Date: Fri, 26 Mar 2021 11:46:47 -0800 Subject: [PATCH] prefer Utils.toFixed when possible, https://github.com/phetsims/chipper/issues/737 --- js/Matrix3.js | 6 +++--- js/Matrix4.js | 4 +++- js/Utils.js | 2 +- js/toSVGNumber.js | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/js/Matrix3.js b/js/Matrix3.js index c32492c..97f9911 100644 --- a/js/Matrix3.js +++ b/js/Matrix3.js @@ -9,11 +9,11 @@ import Enumeration from '../../phet-core/js/Enumeration.js'; import Poolable from '../../phet-core/js/Poolable.js'; import IOType from '../../tandem/js/types/IOType.js'; +import dot from './dot.js'; import Matrix4 from './Matrix4.js'; +import toSVGNumber from './toSVGNumber.js'; import Vector2 from './Vector2.js'; import Vector3 from './Vector3.js'; -import dot from './dot.js'; -import toSVGNumber from './toSVGNumber.js'; class Matrix3 { /** @@ -324,7 +324,7 @@ class Matrix3 { // the inner part of a CSS3 transform, but remember to add the browser-specific parts! // NOTE: the toFixed calls are inlined for performance reasons - return `matrix(${this.entries[ 0 ].toFixed( 20 )},${this.entries[ 1 ].toFixed( 20 )},${this.entries[ 3 ].toFixed( 20 )},${this.entries[ 4 ].toFixed( 20 )},${this.entries[ 6 ].toFixed( 20 )},${this.entries[ 7 ].toFixed( 20 )})`; + return `matrix(${this.entries[ 0 ].toFixed( 20 )},${this.entries[ 1 ].toFixed( 20 )},${this.entries[ 3 ].toFixed( 20 )},${this.entries[ 4 ].toFixed( 20 )},${this.entries[ 6 ].toFixed( 20 )},${this.entries[ 7 ].toFixed( 20 )})`; // eslint-disable-line bad-sim-text } get cssTransform() { return this.getCSSTransform(); } diff --git a/js/Matrix4.js b/js/Matrix4.js index 4f290df..3ba7f6f 100644 --- a/js/Matrix4.js +++ b/js/Matrix4.js @@ -9,10 +9,12 @@ * @author Jonathan Olson */ +/* eslint-disable bad-sim-text */ + import Enumeration from '../../phet-core/js/Enumeration.js'; +import dot from './dot.js'; import Vector3 from './Vector3.js'; import Vector4 from './Vector4.js'; -import dot from './dot.js'; const Float32Array = window.Float32Array || Array; diff --git a/js/Utils.js b/js/Utils.js index e2f6a60..9c68beb 100644 --- a/js/Utils.js +++ b/js/Utils.js @@ -542,7 +542,7 @@ const Utils = { toFixed( value, decimalPlaces ) { const multiplier = Math.pow( 10, decimalPlaces ); const newValue = Utils.roundSymmetric( value * multiplier ) / multiplier; - return newValue.toFixed( decimalPlaces ); + return newValue.toFixed( decimalPlaces ); // eslint-disable-line bad-sim-text }, /** diff --git a/js/toSVGNumber.js b/js/toSVGNumber.js index caee6a8..e627130 100644 --- a/js/toSVGNumber.js +++ b/js/toSVGNumber.js @@ -20,7 +20,7 @@ import dot from './dot.js'; function toSVGNumber( number ) { // Largest guaranteed number of digits according to https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed // See https://github.com/phetsims/dot/issues/36 - return number.toFixed( 20 ); + return number.toFixed( 20 ); // eslint-disable-line bad-sim-text } dot.register( 'toSVGNumber', toSVGNumber );