deflateRRect method

RRect deflateRRect(
  1. RRect rect
)

Returns a new RRect shrunk by this EdgeInsets, decreasing each corner's radius by the corresponding per-axis inset amounts (clamped at zero).

The resulting rectangle's left, top, right, and bottom edges are moved inward by the corresponding inset values. Each corner radius is also reduced by the corresponding inset values on both axes, maintaining the corner shape while scaling appropriately to the new size.

Corner radii are adjusted per-axis and clamped to be non-negative. For example, the top-left corner radius is reduced by left horizontally and top vertically. If either resulting dimension would be negative, the radius is clamped to zero in that direction.

See also:

Implementation

RRect deflateRRect(RRect rect) {
  return RRect.fromLTRBAndCorners(
    rect.left + left,
    rect.top + top,
    rect.right - right,
    rect.bottom - bottom,
    topLeft: (rect.tlRadius - Radius.elliptical(left, top)).clamp(minimum: Radius.zero),
    topRight: (rect.trRadius - Radius.elliptical(right, top)).clamp(minimum: Radius.zero),
    bottomRight: (rect.brRadius - Radius.elliptical(right, bottom)).clamp(minimum: Radius.zero),
    bottomLeft: (rect.blRadius - Radius.elliptical(left, bottom)).clamp(minimum: Radius.zero),
  );
}