Skip to content

Commit

Permalink
Use Math.floor instead of parseInt
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Jun 17, 2021
1 parent 0184e8c commit a787885
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/app/layerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ dwv.LayerController = function (containerDiv) {
baseScale = newScale;

// resize container
var width = parseInt(layerSize.x * baseScale.x, 10);
var height = parseInt(layerSize.y * baseScale.y, 10);
var width = Math.floor(layerSize.x * baseScale.x);
var height = Math.floor(layerSize.y * baseScale.y);
containerDiv.style.width = width + 'px';
containerDiv.style.height = height + 'px';

Expand Down
4 changes: 2 additions & 2 deletions src/gui/drawLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ dwv.gui.DrawLayer = function (containerDiv) {
*/
this.resize = function (newScale) {
// resize stage
konvaStage.setWidth(parseInt(layerSize.x * newScale.x, 10));
konvaStage.setHeight(parseInt(layerSize.y * newScale.y, 10));
konvaStage.setWidth(Math.floor(layerSize.x * newScale.x));
konvaStage.setHeight(Math.floor(layerSize.y * newScale.y));
// set scale
this.setScale(newScale);
};
Expand Down
4 changes: 2 additions & 2 deletions src/gui/viewLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ dwv.gui.ViewLayer = function (containerDiv) {
*/
this.resize = function (newScale) {
// resize canvas
canvas.width = parseInt(layerSize.x * newScale.x, 10);
canvas.height = parseInt(layerSize.y * newScale.y, 10);
canvas.width = Math.floor(layerSize.x * newScale.x);
canvas.height = Math.floor(layerSize.y * newScale.y);
// set scale
this.setScale(newScale);
};
Expand Down

0 comments on commit a787885

Please sign in to comment.