+ [task#127424] set rows info for color of getRegionInfo function.
This commit is contained in:
@@ -109,6 +109,20 @@ function getRegionInfo(pixels, visited, x, y, width, height)
|
||||
{
|
||||
visited[currentY + ',' + currentX] = true;
|
||||
region.area++;
|
||||
|
||||
/* 将rows[currentY] 设为一个数组,以便存储多个区域段。*/
|
||||
/* Set rows [CurrentY] as an array to store multiple regional segments. */
|
||||
if(!region.rows[currentY]) region.rows[currentY] = [];
|
||||
region.rows[currentY].push({ left: Infinity, right: -Infinity });
|
||||
let currentRow = region.rows[currentY][region.rows[currentY].length - 1];
|
||||
currentRow.left = Math.min(currentRow.left, currentX);
|
||||
currentRow.right = Math.max(currentRow.right, currentX);
|
||||
if(currentRow.top === undefined) currentRow.top = currentY;
|
||||
|
||||
if (currentX > 0) stack.push([currentX - 1, currentY]);
|
||||
if (currentX < width - 1) stack.push([currentX + 1, currentY]);
|
||||
if (currentY > 0) stack.push([currentX, currentY - 1]);
|
||||
if (currentY < height - 1) stack.push([currentX, currentY + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user