clamp method

void clamp(
  1. Vector2 min,
  2. Vector2 max
)

Clamps this vector so that it is within or equals to the bounds defined by min and max.

Implementation

void clamp(Vector2 min, Vector2 max) {
  x = x.clamp(min.x, max.x);
  y = y.clamp(min.y, max.y);
}