blob: b709ee5dc1474605d14960a97e15237ce2e1d4c5 (
plain)
1
2
3
4
5
6
|
const clamp = (vector, maxX, maxY) => {
const newVector = {...vector};
newVector.x = Math.max(0, Math.min(maxX, vector.x));
newVector.y = Math.max(0, Math.min(maxY, vector.y));
return newVector;
}
|