From f9c302b2f369cd9d1436be8dcef756ca260c9c6e Mon Sep 17 00:00:00 2001 From: zepumph Date: Fri, 26 Mar 2021 11:46:21 -0800 Subject: [PATCH] prefer Utils.toFixed when possible, https://github.com/phetsims/chipper/issues/737 --- js/display/SVGGradientStop.js | 2 +- js/display/drawables/ImageSVGDrawable.js | 2 +- js/util/Color.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/display/SVGGradientStop.js b/js/display/SVGGradientStop.js index b81cd56c9..69ac1794d 100644 --- a/js/display/SVGGradientStop.js +++ b/js/display/SVGGradientStop.js @@ -146,7 +146,7 @@ class SVGGradientStop { // Since this needs to be done quickly, and we don't particularly care about slight rounding differences (it's // being used for display purposes only, and is never shown to the user), we use the built-in JS toFixed instead of // Dot's version of toFixed. See https://github.com/phetsims/kite/issues/50 - const stopOpacityRule = `stop-opacity: ${scratchColor.a.toFixed( 20 )};`; + const stopOpacityRule = `stop-opacity: ${scratchColor.a.toFixed( 20 )};`; // eslint-disable-line bad-sim-text // For GC, mutate the color so it is just RGB and output that CSS also scratchColor.alpha = 1; diff --git a/js/display/drawables/ImageSVGDrawable.js b/js/display/drawables/ImageSVGDrawable.js index 03c04a902..622fc65de 100644 --- a/js/display/drawables/ImageSVGDrawable.js +++ b/js/display/drawables/ImageSVGDrawable.js @@ -126,7 +126,7 @@ class ImageSVGDrawable extends ImageStatefulDrawable( SVGSelfDrawable ) { // Since this needs to be done quickly, and we don't particularly care about slight rounding differences (it's // being used for display purposes only, and is never shown to the user), we use the built-in JS toFixed instead of // Dot's version of toFixed. See https://github.com/phetsims/kite/issues/50 - image.setAttribute( 'transform', `scale(${Math.pow( 2, level ).toFixed( 20 )})` ); + image.setAttribute( 'transform', `scale(${Math.pow( 2, level ).toFixed( 20 )})` ); // eslint-disable-line bad-sim-text image.setAttributeNS( xlinkns, 'xlink:href', url ); } else { diff --git a/js/util/Color.js b/js/util/Color.js index 808887ce9..26ebc47bd 100644 --- a/js/util/Color.js +++ b/js/util/Color.js @@ -276,7 +276,7 @@ class Color { // Since this needs to be done quickly, and we don't particularly care about slight rounding differences (it's // being used for display purposes only, and is never shown to the user), we use the built-in JS toFixed instead of // Dot's version of toFixed. See https://github.com/phetsims/kite/issues/50 - let alpha = this.a.toFixed( 20 ); + let alpha = this.a.toFixed( 20 ); // eslint-disable-line bad-sim-text while ( alpha.length >= 2 && alpha[ alpha.length - 1 ] === '0' && alpha[ alpha.length - 2 ] !== '.' ) { alpha = alpha.slice( 0, alpha.length - 1 ); }