AABB.expand constructor

AABB.expand(
  1. AABB from,
  2. double amount
)

Implementation

factory AABB.expand(AABB from, double amount) {
  var aabb = AABB.clone(from);
  if (aabb.width < amount) {
    aabb.left -= amount / 2;
    aabb.right += amount / 2;
  }
  if (aabb.height < amount) {
    aabb.top -= amount / 2;
    aabb.bottom += amount / 2;
  }
  return aabb;
}