diff --git a/lib/zin/wg/think3c/js/v1.js b/lib/zin/wg/think3c/js/v1.js index bf858c3cf6..33dec1441c 100644 --- a/lib/zin/wg/think3c/js/v1.js +++ b/lib/zin/wg/think3c/js/v1.js @@ -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]); } }