Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
fix edge case on floodfill
Browse files Browse the repository at this point in the history
  • Loading branch information
bit101 committed Mar 30, 2020
1 parent 4ee8ac7 commit ba8951d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion floodfill/floodfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func FloodFill(surface Surface, x, y, r, g, b float64, threshold float64) {
// helper func. if coord is in bounds and has target color, change to replacement color and add to queue
checkNeighbor := func(x, y int) {
neighbor := newCoord(x, y, w)
if neighbor.x < w-1 && neighbor.x > 0 && neighbor.y < h-1 && neighbor.y > 0 &&
if neighbor.x < w && neighbor.x >= 0 && neighbor.y < h && neighbor.y >= 0 &&
getRGB(data, neighbor).isEqual(targetRGB, th) {

setRGB(data, neighbor, replacementRGB)
Expand Down

0 comments on commit ba8951d

Please sign in to comment.