From 6d4cf346d74aa791acb8a5a9d9245058857eb467 Mon Sep 17 00:00:00 2001 From: Chris Malley Date: Fri, 19 Jun 2015 12:19:52 -0600 Subject: [PATCH] phetsims/tasks#275 replace Math.round with dot.Util.roundSymmetric --- js/common/view/manipulator/PointManipulator.js | 4 ++-- js/common/view/manipulator/SlopeManipulator.js | 4 ++-- js/common/view/manipulator/X1Y1Manipulator.js | 4 ++-- js/common/view/manipulator/X2Y2Manipulator.js | 4 ++-- js/common/view/manipulator/YInterceptManipulator.js | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/js/common/view/manipulator/PointManipulator.js b/js/common/view/manipulator/PointManipulator.js index c2c84b72..9088ca0e 100644 --- a/js/common/view/manipulator/PointManipulator.js +++ b/js/common/view/manipulator/PointManipulator.js @@ -46,8 +46,8 @@ define( function( require ) { var location = modelViewTransform.viewToModelPosition( parentPoint ); // constrain to range, snap to grid - var x = Math.round( Util.clamp( location.x, xRange.min, xRange.max ) ); - var y = Math.round( Util.clamp( location.y, yRange.min, yRange.max ) ); + var x = Util.roundSymmetric( Util.clamp( location.x, xRange.min, xRange.max ) ); + var y = Util.roundSymmetric( Util.clamp( location.y, yRange.min, yRange.max ) ); var p = new Vector2( x, y ); // is this point the same as one of the others? diff --git a/js/common/view/manipulator/SlopeManipulator.js b/js/common/view/manipulator/SlopeManipulator.js index d8178dbf..031d4e24 100644 --- a/js/common/view/manipulator/SlopeManipulator.js +++ b/js/common/view/manipulator/SlopeManipulator.js @@ -45,8 +45,8 @@ define( function( require ) { var location = modelViewTransform.viewToModelPosition( parentPoint ); // constrain to dynamic range, snap to grid var line = lineProperty.get(); - var run = Math.round( Util.clamp( location.x - line.x1, runRangeProperty.get().min, runRangeProperty.get().max ) ); - var rise = Math.round( Util.clamp( location.y - line.y1, riseRangeProperty.get().min, riseRangeProperty.get().max ) ); + var run = Util.roundSymmetric( Util.clamp( location.x - line.x1, runRangeProperty.get().min, runRangeProperty.get().max ) ); + var rise = Util.roundSymmetric( Util.clamp( location.y - line.y1, riseRangeProperty.get().min, riseRangeProperty.get().max ) ); // don't allow slope=0/0, undefined line if ( rise !== 0 || run !== 0 ) { lineProperty.set( Line.createPointSlope( line.x1, line.y1, rise, run, line.color ) ); diff --git a/js/common/view/manipulator/X1Y1Manipulator.js b/js/common/view/manipulator/X1Y1Manipulator.js index 2269548b..1e8c19e9 100644 --- a/js/common/view/manipulator/X1Y1Manipulator.js +++ b/js/common/view/manipulator/X1Y1Manipulator.js @@ -47,8 +47,8 @@ define( function( require ) { var location = modelViewTransform.viewToModelPosition( parentPoint ); // constrain to range, snap to grid - var x1 = Math.round( Util.clamp( location.x, x1RangeProperty.get().min, x1RangeProperty.get().max ) ); - var y1 = Math.round( Util.clamp( location.y, y1RangeProperty.get().min, y1RangeProperty.get().max ) ); + var x1 = Util.roundSymmetric( Util.clamp( location.x, x1RangeProperty.get().min, x1RangeProperty.get().max ) ); + var y1 = Util.roundSymmetric( Util.clamp( location.y, y1RangeProperty.get().min, y1RangeProperty.get().max ) ); var line = lineProperty.get(); if ( constantSlope ) { diff --git a/js/common/view/manipulator/X2Y2Manipulator.js b/js/common/view/manipulator/X2Y2Manipulator.js index 5d678a78..48632d45 100644 --- a/js/common/view/manipulator/X2Y2Manipulator.js +++ b/js/common/view/manipulator/X2Y2Manipulator.js @@ -47,8 +47,8 @@ define( function( require ) { var location = modelViewTransform.viewToModelPosition( parentPoint ); // constrain to range, snap to grid - var x2 = Math.round( Util.clamp( location.x, x2RangeProperty.get().min, x2RangeProperty.get().max ) ); - var y2 = Math.round( Util.clamp( location.y, y2RangeProperty.get().min, y2RangeProperty.get().max ) ); + var x2 = Util.roundSymmetric( Util.clamp( location.x, x2RangeProperty.get().min, x2RangeProperty.get().max ) ); + var y2 = Util.roundSymmetric( Util.clamp( location.y, y2RangeProperty.get().min, y2RangeProperty.get().max ) ); if ( x2 !== line.x1 || y2 !== line.y1 ) { // Don't allow points to be the same, this would result in slope=0/0 (undefined line.) diff --git a/js/common/view/manipulator/YInterceptManipulator.js b/js/common/view/manipulator/YInterceptManipulator.js index 1b9ebfe7..204857fb 100644 --- a/js/common/view/manipulator/YInterceptManipulator.js +++ b/js/common/view/manipulator/YInterceptManipulator.js @@ -46,7 +46,7 @@ define( function( require ) { var location = modelViewTransform.viewToModelPosition( parentPoint ); // constrain to range, snap to grid - var y1 = Math.round( Util.clamp( location.y, y1RangeProperty.get().min, y1RangeProperty.get().max ) ); + var y1 = Util.roundSymmetric( Util.clamp( location.y, y1RangeProperty.get().min, y1RangeProperty.get().max ) ); var line = lineProperty.get(); // Keep slope constant, change y1.