blob: b0da861e23e223a389c0fe9701858fdcc92a187c (
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;
};
|