Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8b019c9
draw flood fill
robertpfeiffer Apr 26, 2024
b473f0b
clang-format, docs, report error
robertpfeiffer May 5, 2024
c2ccab3
tests
robertpfeiffer May 5, 2024
0dea589
format
robertpfeiffer May 5, 2024
af87bc4
types
robertpfeiffer May 5, 2024
9df783e
comments, readability
robertpfeiffer May 5, 2024
c9c117f
code review feedback
robertpfeiffer May 21, 2024
029ccc5
My local install of clang-format disagreed with CI.\nIf you keep this…
robertpfeiffer May 21, 2024
90e8031
Merge branch 'main' into flood_fill
MyreMylar May 26, 2024
eee983e
Merge branch 'main' into flood_fill
MyreMylar Aug 25, 2025
438ed6d
Updating docs to match implementation
MyreMylar Aug 25, 2025
19bbcae
making docs more accurate
MyreMylar Aug 25, 2025
2518ee2
Update src_c/doc/draw_doc.h
MyreMylar Aug 25, 2025
1c5b761
make it 'start_point' everywhere
MyreMylar Aug 25, 2025
e91c585
Add small tweaks from AI code review
MyreMylar Aug 25, 2025
7244af0
Fix SDL3 build
MyreMylar Aug 25, 2025
03bbbd4
Fix SURF_GET_AT macro for SDL3
MyreMylar Aug 25, 2025
4908911
Merge remote-tracking branch 'origin/flood_fill' into flood_fill
MyreMylar Aug 25, 2025
f2304dd
Fix raising error in inner_function.
MyreMylar Aug 25, 2025
d1c9e55
TRy ifdefing SURF_GET_AT macro to avoid redef error
MyreMylar Aug 25, 2025
cb9d5e9
docs indentation
MyreMylar Aug 25, 2025
decc5da
docs indentation
MyreMylar Aug 25, 2025
84ade6e
formatting
MyreMylar Aug 25, 2025
148cbb5
switch start_point to start_pos
MyreMylar Aug 26, 2025
6bdc0a0
Adapt documentation to match other functions
MyreMylar Aug 26, 2025
7047eca
Fix conversion and error propagation
MyreMylar Aug 26, 2025
7012bdf
more interesting cases for flood fill tests
robertpfeiffer Aug 26, 2025
d440ba8
Better explain test case on comments
robertpfeiffer Aug 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion buildconfig/stubs/pygame/draw.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
See the :mod:`pygame.gfxdraw` module for alternative draw methods.
"""

from typing import overload
from typing import Union, overload

from pygame.rect import Rect
from pygame.surface import Surface
Expand Down Expand Up @@ -568,3 +568,26 @@ def aalines(
.. versionchanged:: 2.5.0 ``blend`` argument re-added for backcompat, but will
always raise a deprecation exception when used
"""

def flood_fill(
surface: Surface, color: Union[ColorLike, Surface], start_point: Point
) -> Rect:
"""Replace the color of a cluster of connected same-color pixels, beginning
from the starting point, with a repeating pattern or solid single color

:param Surface surface: surface to draw on
:param color: color, or surface pattern, to draw with. The alpha value is optional if using a
tuple ``(RGB[A])``
:type color: :data:`pygame.typing.ColorLike` or a pattern to fill with, as a Surface
:param start_point: starting point as a sequence of 2 ints/floats,
e.g. ``(x, y)``
:type start_point: tuple(int or float, int or float) or
list(int or float, int or float) or Vector2(int or float, int or float)

:returns: a rect bounding the changed pixels, if nothing is drawn the
bounding rect's position will be the position of the starting point
and its width and height will be 0
:rtype: Rect

.. versionadded:: 2.5.6
"""
1 change: 1 addition & 0 deletions src_c/doc/draw_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
#define DOC_DRAW_LINES "lines(surface, color, closed, points, width=1) -> Rect\nDraw multiple contiguous straight line segments."
#define DOC_DRAW_AALINE "aaline(surface, color, start_pos, end_pos, width=1) -> Rect\nDraw a straight antialiased line."
#define DOC_DRAW_AALINES "aalines(surface, color, closed, points) -> Rect\nDraw multiple contiguous straight antialiased line segments."
#define DOC_DRAW_FLOODFILL "flood_fill(surface, color, start_point) -> Rect\nReplace the color of a cluster of connected same-color pixels, beginning"
Loading
Loading