答案 0 :(得分:0)
所有地区的边界区域
计算所有矩形的极值:
var currentLeftmostX=10000000;
var currentTopmostY=10000000;
var currentRightmostX=-10000000;
var currentBottommostY=-10000000;
// do this for each rect
if( rect.x < currentLeftmostX) {currentLeftmostX=rect.x;}
if( rect.y < currentTopmostY) {currentTopmostY=rect.y;}
if( rect.x+rect.width > currentRightmostX) {currentRightmostX=rect.x;}
if( rect.y+rect.height > currentBottommostY){currentBottommostY=rect.y;}
var boundingArea=
(currentRightmostX-currentLeftmostX)*(currentBottommostY - currentBottommostY);