getBoundingBox static method
计算2个矩形的外接矩形,用于计算圆点摸tip的位置
Implementation
static Rect getBoundingBox(Rect rect1, Rect rect2) {
// 计算外接矩形的边界
double minX = rect1.left < rect2.left ? rect1.left : rect2.left;
double minY = rect1.top < rect2.top ? rect1.top : rect2.top;
double maxX = rect1.right > rect2.right ? rect1.right : rect2.right;
double maxY = rect1.bottom > rect2.bottom ? rect1.bottom : rect2.bottom;
// 返回外接矩形
return Rect.fromLTRB(minX, minY, maxX, maxY);
}