Skip to content

Commit 84ade6e

Browse files
committed
formatting
1 parent decc5da commit 84ade6e

File tree

2 files changed

+39
-34
lines changed

2 files changed

+39
-34
lines changed

buildconfig/stubs/pygame/draw.pyi

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
2828
See the :mod:`pygame.gfxdraw` module for alternative draw methods.
2929
"""
3030

31-
from typing import overload, Union
31+
from typing import Union, overload
3232

3333
from pygame.rect import Rect
3434
from pygame.surface import Surface
@@ -570,26 +570,24 @@ def aalines(
570570
"""
571571

572572
def flood_fill(
573-
surface: Surface,
574-
color: Union[ColorLike, Surface],
575-
start_point: Point
573+
surface: Surface, color: Union[ColorLike, Surface], start_point: Point
576574
) -> Rect:
577-
"""Replace the color of a cluster of connected same-color pixels, beginning
578-
from the starting point, with a repeating pattern or solid single color
579-
580-
:param Surface surface: surface to draw on
581-
:param color: color, or surface pattern, to draw with. The alpha value is optional if using a
582-
tuple ``(RGB[A])``
583-
:type color: :data:`pygame.typing.ColorLike` or a pattern to fill with, as a Surface
584-
:param start_point: starting point as a sequence of 2 ints/floats,
585-
e.g. ``(x, y)``
586-
:type start_point: tuple(int or float, int or float) or
587-
list(int or float, int or float) or Vector2(int or float, int or float)
588-
589-
:returns: a rect bounding the changed pixels, if nothing is drawn the
590-
bounding rect's position will be the position of the starting point
591-
and its width and height will be 0
592-
:rtype: Rect
593-
594-
.. versionadded:: 2.5.6
595-
"""
575+
"""Replace the color of a cluster of connected same-color pixels, beginning
576+
from the starting point, with a repeating pattern or solid single color
577+
578+
:param Surface surface: surface to draw on
579+
:param color: color, or surface pattern, to draw with. The alpha value is optional if using a
580+
tuple ``(RGB[A])``
581+
:type color: :data:`pygame.typing.ColorLike` or a pattern to fill with, as a Surface
582+
:param start_point: starting point as a sequence of 2 ints/floats,
583+
e.g. ``(x, y)``
584+
:type start_point: tuple(int or float, int or float) or
585+
list(int or float, int or float) or Vector2(int or float, int or float)
586+
587+
:returns: a rect bounding the changed pixels, if nothing is drawn the
588+
bounding rect's position will be the position of the starting point
589+
and its width and height will be 0
590+
:rtype: Rect
591+
592+
.. versionadded:: 2.5.6
593+
"""

src_c/draw.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,9 +1333,10 @@ flood_fill(PyObject *self, PyObject *arg, PyObject *kwargs)
13331333

13341334
if (pgSurface_Check(colorobj)) {
13351335
pat_surfobj = (pgSurfaceObject *)colorobj;
1336-
pattern = pat_surfobj->surf; /* No conversion: we will map per-pixel */
1337-
color = 0; /* new_color unused for pattern path */
1338-
} else {
1336+
pattern = pat_surfobj->surf; /* No conversion: we will map per-pixel */
1337+
color = 0; /* new_color unused for pattern path */
1338+
}
1339+
else {
13391340
CHECK_LOAD_COLOR(colorobj);
13401341
}
13411342

@@ -1369,7 +1370,8 @@ flood_fill(PyObject *self, PyObject *arg, PyObject *kwargs)
13691370
if (did_lock_surf) {
13701371
pgSurface_Unlock(surfobj);
13711372
}
1372-
return RAISE(PyExc_RuntimeError, "error unlocking pattern surface");
1373+
return RAISE(PyExc_RuntimeError,
1374+
"error unlocking pattern surface");
13731375
}
13741376
}
13751377
if (did_lock_surf) {
@@ -1384,12 +1386,14 @@ flood_fill(PyObject *self, PyObject *arg, PyObject *kwargs)
13841386

13851387
/* Compute return rect. */
13861388
if (drawn_area[0] != INT_MAX && drawn_area[1] != INT_MAX &&
1387-
drawn_area[2] != INT_MIN && drawn_area[3] != INT_MIN)
1389+
drawn_area[2] != INT_MIN && drawn_area[3] != INT_MIN) {
13881390
return pgRect_New4(drawn_area[0], drawn_area[1],
13891391
drawn_area[2] - drawn_area[0] + 1,
13901392
drawn_area[3] - drawn_area[1] + 1);
1391-
else
1393+
}
1394+
else {
13921395
return pgRect_New4(startx, starty, 0, 0);
1396+
}
13931397
}
13941398
/* Functions used in drawing algorithms */
13951399

@@ -1401,7 +1405,7 @@ swap(float *a, float *b)
14011405
*b = temp;
14021406
}
14031407

1404-
#define WORD_BITS (CHAR_BIT * sizeof(unsigned int))
1408+
#define WORD_BITS (CHAR_BIT * sizeof(unsigned int))
14051409

14061410
struct point2d {
14071411
Uint32 x;
@@ -1423,10 +1427,12 @@ _bitarray_set(unsigned int *bitarray, size_t idx, SDL_bool value)
14231427
static inline SDL_bool
14241428
_bitarray_get(unsigned int *bitarray, size_t idx)
14251429
{
1426-
if (bitarray[idx / WORD_BITS] & (1u << (idx % WORD_BITS)))
1430+
if (bitarray[idx / WORD_BITS] & (1u << (idx % WORD_BITS))) {
14271431
return SDL_TRUE;
1428-
else
1432+
}
1433+
else {
14291434
return SDL_FALSE;
1435+
}
14301436
}
14311437

14321438
static int
@@ -2502,7 +2508,7 @@ draw_line(SDL_Surface *surf, SDL_Rect surf_clip_rect, int x1, int y1, int x2,
25022508
*((Uint32 *)(p_pixels + (p_y) * p_surf->pitch) + (p_x)); \
25032509
break; \
25042510
}
2505-
#endif //SURF_GET_AT
2511+
#endif // SURF_GET_AT
25062512

25072513
static int
25082514
flood_fill_inner(SDL_Surface *surf, int x1, int y1, Uint32 new_color,
@@ -2609,8 +2615,9 @@ flood_fill_inner(SDL_Surface *surf, int x1, int y1, Uint32 new_color,
26092615
}
26102616

26112617
mask_idx = (ny - cliprect.y) * cliprect.w + (nx - cliprect.x);
2612-
if (_bitarray_get(mask, mask_idx))
2618+
if (_bitarray_get(mask, mask_idx)) {
26132619
continue;
2620+
}
26142621

26152622
// only queue node once
26162623
_bitarray_set(mask, mask_idx, SDL_TRUE);

0 commit comments

Comments
 (0)