constrain method

Vector2 constrain(
  1. double x,
  2. double y
)

The size closest to (x, y) that satisfies these constraints.

Implementation

Vector2 constrain(double x, double y) => .new(
  x.clamp(min.x, max.x).toDouble(),
  y.clamp(min.y, max.y).toDouble(),
);