Vector2.clamp()
clamp each axis of this vector so it stays within the boundaries of the given rectangle
Parameters
Name | Type | Description | |
---|---|---|---|
1 | rectangle | Rectangle |
Return value
Vector2
The vector with its new values
Usage
import {Vector2, Rectangle} from '@lcluber/type6js';
let rectangle = new Rectangle(0,0,10,20);
let vector = new Vector2(0,30);
console.log(vector); //(0,30)
vector.clamp(rectangle);
console.log(vector); //(0,20)