mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:07:36 +00:00
PaintBrush: Fix some silly logic typos in flood fill.
This commit is contained in:
parent
a8b2b96f38
commit
150b3cf378
1 changed files with 7 additions and 9 deletions
|
@ -21,23 +21,21 @@ static void flood_fill(GraphicsBitmap& bitmap, const Point& start_position, Colo
|
|||
while (!queue.is_empty()) {
|
||||
auto position = queue.dequeue();
|
||||
|
||||
if (!bitmap.rect().contains(position))
|
||||
continue;
|
||||
if (bitmap.get_pixel(position) != target_color)
|
||||
continue;
|
||||
bitmap.set_pixel(position, fill_color);
|
||||
|
||||
if (position.x() != 0)
|
||||
queue.enqueue(position.translated(0, -1));
|
||||
|
||||
if (position.x() != bitmap.width() - 1)
|
||||
queue.enqueue(position.translated(0, 1));
|
||||
|
||||
if (position.y() != 0)
|
||||
queue.enqueue(position.translated(-1, 0));
|
||||
|
||||
if (position.y() != bitmap.height() - 1)
|
||||
if (position.x() != bitmap.width() - 1)
|
||||
queue.enqueue(position.translated(1, 0));
|
||||
|
||||
if (position.y() != 0)
|
||||
queue.enqueue(position.translated(0, -1));
|
||||
|
||||
if (position.y() != bitmap.height() - 1)
|
||||
queue.enqueue(position.translated(0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue