diff --git a/lib/zin/wg/think3c/js/v1.js b/lib/zin/wg/think3c/js/v1.js index 854dd51410..bf858c3cf6 100644 --- a/lib/zin/wg/think3c/js/v1.js +++ b/lib/zin/wg/think3c/js/v1.js @@ -97,5 +97,20 @@ function getRegionInfo(pixels, visited, x, y, width, height) { const region = {area: 0, rows: []}; + /* 创建栈数据结构。*/ + /* Create a stack data structure.*/ + const stack = [[x, y]]; + while(stack.length > 0) + { + const [currentX, currentY] = stack.pop(); + + const index = (currentY * width * 4) + (currentX * 4); + if(pixels[index] === 255 && !visited[currentY + ',' + currentX]) + { + visited[currentY + ',' + currentX] = true; + region.area++; + } + } + return region; }