边界填充算法讲解
Boundary fill is the algorithm used frequently in computer graphics to fill a desired color inside a closed polygon having the same boundary color for all of its sides.
边界填充是在计算机图形学中经常使用的算法,用于在其所有边都具有相同边界颜色的封闭多边形内填充所需颜色。
The most approached implementation of the algorithm is a stack-based recursive function.
该算法最接近的实现是基于堆栈的递归函数。
这个怎么运作: (How it works:)
The problem is pretty simple and usually follows these steps:
该问题非常简单,通常按照以下步骤操作:
- Take the position of the starting point and the boundary color. 取起点的位置和边界颜色。
- Decide wether you want to go in 4 directions (N, S, W, E) or 8 directions (N, S, W, E, NW, NE, SW, SE). 确定您要沿4个方向(N,S,W