Small fixes

This commit is contained in:
barsdeveloper
2022-01-08 18:57:37 +01:00
parent a6ff4161e8
commit 41b741e8b8
12 changed files with 175 additions and 116 deletions

View File

@@ -1,3 +1,4 @@
import Configuration from "./Configuration"
import TypeInitialization from "./entity/TypeInitialization"
export default class Utility {
@@ -77,4 +78,19 @@ export default class Utility {
return constructor
}
}
/**
*
* @param {Number[]} location
* @param {Number} gridSize
*/
static snapToGrid(location, gridSize = Configuration.gridSize) {
if (gridSize === 1) {
return location
}
return [
gridSize * Math.round(location[0] / gridSize),
gridSize * Math.round(location[1] / gridSize)
]
}
}