From 1932b82552bae33651b9b35382dcd4104602dcc9 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Wed, 16 Oct 2024 14:29:13 +0200 Subject: [PATCH 1/7] Changes to be commited: new file: test.txt --- test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000..e69de29bb2 From 49dbee5fd853456b345f7c210ec41b2c989badd4 Mon Sep 17 00:00:00 2001 From: GabrieleLS Date: Wed, 16 Oct 2024 14:30:57 +0200 Subject: [PATCH 2/7] Delete test.txt --- test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test.txt diff --git a/test.txt b/test.txt deleted file mode 100644 index e69de29bb2..0000000000 From 61e8204807ff12f19ce90686edfe4bfb324bc64f Mon Sep 17 00:00:00 2001 From: Gabriele Date: Wed, 20 Nov 2024 09:03:28 +0100 Subject: [PATCH 3/7] Update mixer.rst suite (documentation generated) --- docs/reST/ref/mixer.rst | 6 +++++- examples/go_over_there.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/reST/ref/mixer.rst b/docs/reST/ref/mixer.rst index 5a441c7f81..9f5d57105b 100644 --- a/docs/reST/ref/mixer.rst +++ b/docs/reST/ref/mixer.rst @@ -79,6 +79,10 @@ The following file formats are supported The channels argument is used to specify whether to use mono or stereo. 1 for mono and 2 for stereo. + + ``NOTE``: The channels argument is not related to the number + of channels for playback of sounds, that you can get with the function + ``get_num_channels`` or set with the function ``set_num_channels`` (see below). The buffer argument controls the number of internal samples used in the sound mixer. The default value should work for most cases. It can be lowered @@ -220,7 +224,7 @@ The following file formats are supported | :sl:`set the total number of playback channels` | :sg:`set_num_channels(count, /) -> None` - Sets the number of available channels for the mixer. The default value is 8. + Sets the number of available playback channels for the mixer. The default value is 8. The value can be increased or decreased. If the value is decreased, sounds playing on the truncated channels are stopped. diff --git a/examples/go_over_there.py b/examples/go_over_there.py index 10ff3742ee..aa0ba51193 100644 --- a/examples/go_over_there.py +++ b/examples/go_over_there.py @@ -14,7 +14,7 @@ import random MIN_SPEED = 0.25 -MAX_SPEED = 5 +MAX_SPEED = 1 MAX_BALLS = 1600 SCREEN_SIZE = pygame.Vector2(1000, 600) CIRCLE_RADIUS = 5 From b2cf32c42b01026f14629b555ad1ecd5fe53f2c0 Mon Sep 17 00:00:00 2001 From: Neri19 Date: Wed, 20 Nov 2024 10:34:38 +0100 Subject: [PATCH 4/7] rect modified to avoid problems with negative values on radius --- src_c/draw.c | 6 +++--- tests.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tests.py diff --git a/src_c/draw.c b/src_c/draw.c index 0d6b9fc8a8..96998526bf 100644 --- a/src_c/draw.c +++ b/src_c/draw.c @@ -1185,11 +1185,11 @@ rect(PyObject *self, PyObject *args, PyObject *kwargs) } if (width > rect->w / 2 || width > rect->h / 2) { - width = MAX(rect->w / 2, rect->h / 2); + width = MIN(rect->w / 2, rect->h / 2); } draw_round_rect(surf, rect->x, rect->y, rect->x + rect->w - 1, - rect->y + rect->h - 1, radius, width, color, + rect->y + rect->h - 1, MAX(radius, 0), width, color, top_left_radius, top_right_radius, bottom_left_radius, bottom_right_radius, drawn_area); if (!pgSurface_Unlock(surfobj)) { @@ -3188,7 +3188,7 @@ draw_round_rect(SDL_Surface *surf, int x1, int y1, int x2, int y2, int radius, pts[8] = y1 + top_left; pts[9] = y1; pts[10] = y1; - pts[11] = y1 + top_right; + pts[11] = y1 + top_right; pts[12] = y2 - bottom_right; pts[13] = y2; pts[14] = y2; diff --git a/tests.py b/tests.py new file mode 100644 index 0000000000..8428f00db9 --- /dev/null +++ b/tests.py @@ -0,0 +1,30 @@ +import pygame as pg +pg.init() +running = True +display = pg.display.set_mode((600, 600)) +clock = pg.time.Clock() +n = 50 +delta = -1 + +while running: + for event in pg.event.get(): + if event.type == pg.QUIT: + pg.quit() + quit() + + display.fill("black") + + pg.draw.rect(display, (255, 255, 255), (100, 100, 50, 50), 4, n, n, n, -n, n) + pg.draw.rect(display, (255, 255, 255), (100, 400, 50, 50), 100, n, n, n, -n, n) + pg.draw.rect(display, (255, 255, 255), (400, 400, 50, 100), 0, n, n, n, -n, n) + + n += delta + + pg.display.update() + + if n == -100: + delta = 1 + elif n == 10: + delta = -1 + + clock.tick(10) \ No newline at end of file From 0d8512b107903df0f3b3daa48dc9c14d35433f4a Mon Sep 17 00:00:00 2001 From: Neri19 Date: Wed, 20 Nov 2024 10:38:07 +0100 Subject: [PATCH 5/7] without my tests --- tests.py | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 tests.py diff --git a/tests.py b/tests.py deleted file mode 100644 index 8428f00db9..0000000000 --- a/tests.py +++ /dev/null @@ -1,30 +0,0 @@ -import pygame as pg -pg.init() -running = True -display = pg.display.set_mode((600, 600)) -clock = pg.time.Clock() -n = 50 -delta = -1 - -while running: - for event in pg.event.get(): - if event.type == pg.QUIT: - pg.quit() - quit() - - display.fill("black") - - pg.draw.rect(display, (255, 255, 255), (100, 100, 50, 50), 4, n, n, n, -n, n) - pg.draw.rect(display, (255, 255, 255), (100, 400, 50, 50), 100, n, n, n, -n, n) - pg.draw.rect(display, (255, 255, 255), (400, 400, 50, 100), 0, n, n, n, -n, n) - - n += delta - - pg.display.update() - - if n == -100: - delta = 1 - elif n == 10: - delta = -1 - - clock.tick(10) \ No newline at end of file From 078857bb3a95fdda6bc1905999e936b2c13ac836 Mon Sep 17 00:00:00 2001 From: Neri19 Date: Wed, 20 Nov 2024 10:56:36 +0100 Subject: [PATCH 6/7] remove some useless add --- src_c/draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src_c/draw.c b/src_c/draw.c index 96998526bf..d967d22a51 100644 --- a/src_c/draw.c +++ b/src_c/draw.c @@ -1185,7 +1185,7 @@ rect(PyObject *self, PyObject *args, PyObject *kwargs) } if (width > rect->w / 2 || width > rect->h / 2) { - width = MIN(rect->w / 2, rect->h / 2); + width = MAX(rect->w / 2, rect->h / 2); } draw_round_rect(surf, rect->x, rect->y, rect->x + rect->w - 1, @@ -3188,7 +3188,7 @@ draw_round_rect(SDL_Surface *surf, int x1, int y1, int x2, int y2, int radius, pts[8] = y1 + top_left; pts[9] = y1; pts[10] = y1; - pts[11] = y1 + top_right; + pts[11] = y1 + top_right; pts[12] = y2 - bottom_right; pts[13] = y2; pts[14] = y2; From 727fecdcb4f56b41166395a065bf785ff6dc149f Mon Sep 17 00:00:00 2001 From: Gabriele Date: Wed, 4 Dec 2024 15:10:12 +0100 Subject: [PATCH 7/7] Addition of a function that tests the good initialization of all the attributes of a rect, in rect_tests.py --- test/rect_test.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/rect_test.py b/test/rect_test.py index 0ad1af77c3..e032242db6 100644 --- a/test/rect_test.py +++ b/test/rect_test.py @@ -52,6 +52,41 @@ def testCalculatedAttributes(self): self.assertEqual((r.left, r.centery), r.midleft) self.assertEqual((r.right, r.centery), r.midright) + def testAttributes(self): + """Checks that all the attributes are initialized correctly.""" + r = Rect(1, 2, 3, 4) + + self.assertEqual(1, r.left) + self.assertEqual(2, r.top) + self.assertEqual(4, r.right) + self.assertEqual(6, r.bottom) + + self.assertEqual(1, r.x) + self.assertEqual(2, r.y) + + self.assertEqual(3, r.w) + self.assertEqual(4, r.h) + + self.assertEqual((1, 2), r.topleft) + self.assertEqual((4, 2), r.topright) + self.assertEqual((1, 6), r.bottomleft) + self.assertEqual((4, 6), r.bottomright) + + self.assertEqual((3, 4), r.size) + self.assertEqual(3, r.width) + self.assertEqual(4, r.height) + + self.assertEqual(2, r.centerx) + self.assertEqual(4, r.centery) + self.assertEqual((2, 4), r.center) + + self.assertEqual((2, 2), r.midtop) + self.assertEqual((2, 6), r.midbottom) + self.assertEqual((1, 4), r.midleft) + self.assertEqual((4, 4), r.midright) + + + def testRepr(self): rect = Rect(12, 34, 56, 78) self.assertEqual(repr(rect), "Rect(12, 34, 56, 78)")