Skip to content

Commit 4021ee0

Browse files
committed
formatting
1 parent 88d3eff commit 4021ee0

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src_c/transform.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4246,30 +4246,28 @@ surf_pixelate(PyObject *self, PyObject *args, PyObject *kwargs)
42464246
double testWidth = round((double)src->surf->w / pixel_size);
42474247
double testHeight = round((double)src->surf->h / pixel_size);
42484248

4249-
if (testWidth > INT_MAX || testWidth <= 0)
4250-
{
4251-
PyErr_SetString(PyExc_OverflowError, "Cannot scale width outside the range [0, INT_MAX]");
4249+
if (testWidth > INT_MAX || testWidth <= 0) {
4250+
PyErr_SetString(PyExc_OverflowError,
4251+
"Cannot scale width outside the range [0, INT_MAX]");
42524252
return NULL;
42534253
}
42544254

4255-
if (testHeight > INT_MAX || testHeight <= 0)
4256-
{
4257-
PyErr_SetString(PyExc_OverflowError, "Cannot scale height outside the range [0, INT_MAX]");
4255+
if (testHeight > INT_MAX || testHeight <= 0) {
4256+
PyErr_SetString(PyExc_OverflowError,
4257+
"Cannot scale height outside the range [0, INT_MAX]");
42584258
return NULL;
42594259
}
42604260

42614261
int width = (int)testWidth;
42624262
int height = (int)testHeight;
42634263

4264-
SDL_Surface* temp = scale_to(src, NULL, width, height);
4264+
SDL_Surface *temp = scale_to(src, NULL, width, height);
42654265
intermediate = pgSurface_New(temp);
4266-
if (intermediate == NULL)
4267-
{
4266+
if (intermediate == NULL) {
42684267
return NULL; /* Exception already set in scale_to */
42694268
}
42704269
new_surf = scale_to(intermediate, dst, src->surf->w, src->surf->h);
4271-
if (new_surf == NULL)
4272-
{
4270+
if (new_surf == NULL) {
42734271
return NULL; /* Exception already set in scale_to */
42744272
}
42754273

test/transform_test.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
from pygame.tests import test_utils
99
from pygame.tests.test_utils import example_path
1010

11+
1112
def surfaces_have_same_pixels(surf1, surf2):
1213
if surf1.get_size() != surf2.get_size():
1314
return False
14-
15+
1516
for row in range(surf1.get_height()):
1617
for col in range(surf1.get_width()):
1718
if surf1.get_at((col, row)) != surf2.get_at((col, row)):
1819
return False
19-
20+
2021
return True
2122

23+
2224
def show_image(s, images=[]):
2325
# pygame.display.init()
2426
size = s.get_rect()[2:]
@@ -1769,7 +1771,7 @@ def smoothscale_invalid_scale():
17691771
smaller_surface.get_at(((k // 2), 0)), pygame.Color(127, 127, 127)
17701772
)
17711773
self.assertEqual(smaller_surface.get_size(), (k, 1))
1772-
1774+
17731775
def test_pixelate(self):
17741776
"""Test pygame.transform.pixelate"""
17751777
# test that pixelating the original with a pixel_size of 1 yields the original back
@@ -1780,18 +1782,18 @@ def test_pixelate(self):
17801782
no_change = pygame.transform.pixelate(image, 1)
17811783

17821784
self.assertTrue(surfaces_have_same_pixels(image, no_change))
1783-
1785+
17841786
# test that pixelating a square image with a pixel_size equal to the side length
17851787
# yields a surface of a single color, which is the average of the surf
17861788
square = pygame.transform.scale(image, (50, 50))
17871789
square_pixelated = pygame.transform.pixelate(square, 50)
17881790
square_resized = pygame.transform.scale(
1789-
pygame.transform.scale(square, (1, 1)),
1790-
square.get_size()
1791+
pygame.transform.scale(square, (1, 1)), square.get_size()
17911792
)
17921793

17931794
self.assertTrue(surfaces_have_same_pixels(square_pixelated, square_resized))
17941795

1796+
17951797
class TransformDisplayModuleTest(unittest.TestCase):
17961798
def setUp(self):
17971799
pygame.display.init()

0 commit comments

Comments
 (0)