Paint Fill: Implement the “paint fill” function that one might see on many image editing programs. That is, given a screen (represented by a two-dimensional array of colors), a point, and a new color, fill in the surrounding area until the color changes from the original color.
Hints: #364, #382
解法1
举个例子:如果一个画布背景是白色,上面有一个黑色的方块,点中这个方块中的某个坐标,把这个方块变成绿色。
如果两个方块顶点相碰,那么只会有一个方块变颜色。这也就是体重所说的surrounding区域变色,而surrounding的概念则是上下左右4个方向,不含斜方向。要注意避免重复着色。
|
|
评论