Whether the given point lies inside the rounded rectangle. This method works by normalizing the sizes of the radii in case they overflow the sizes of the side.
Source
bool contains(Point point) { if (point.x < left || point.x >= right || point.y < top || point.y >= bottom) return false; // outside bounding box _scaleRadii(); double x; double y; double radiusX; double radiusY; // check whether point is in one of the rounded corner areas // x, y -> translate to ellipse center if (point.x < left + _scaled.tlRadiusX && point.y < top + _scaled.tlRadiusY) { x = point.x - left - _scaled.tlRadiusX; y = point.y - top - _scaled.tlRadiusY; radiusX = _scaled.tlRadiusX; radiusY = _scaled.tlRadiusY; } else if (point.x > right - _scaled.trRadiusX && point.y < top + _scaled.trRadiusY) { x = point.x - right + _scaled.trRadiusX; y = point.y - top - _scaled.trRadiusY; radiusX = _scaled.trRadiusX; radiusY = _scaled.trRadiusY; } else if (point.x > right - _scaled.brRadiusX && point.y > bottom - _scaled.brRadiusY) { x = point.x - right + _scaled.brRadiusX; y = point.y - bottom + _scaled.brRadiusY; radiusX = _scaled.brRadiusX; radiusY = _scaled.brRadiusY; } else if (point.x < left + _scaled.blRadiusX && point.y > bottom - _scaled.blRadiusY) { x = point.x - left - _scaled.blRadiusX; y = point.y - bottom + _scaled.blRadiusY; radiusX = _scaled.blRadiusX; radiusY = _scaled.blRadiusY; } else { return true; // inside and not within the rounded corner area } x = x / radiusX; y = y / radiusY; // check if the point is outside the unit circle if (x * x + y * y > 1.0) return false; return true; }