【发布时间】:2016-10-08 00:53:38
【问题描述】:
【问题讨论】:
标签: html canvas html5-canvas
【问题讨论】:
标签: html canvas html5-canvas
所有矩形的边界区域
计算所有矩形的极值:
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);
【讨论】: