Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification in draw.rect #3229

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion docs/reST/ref/mixer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion examples/go_over_there.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src_c/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ rect(PyObject *self, PyObject *args, PyObject *kwargs)
}

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)) {
Expand Down
35 changes: 35 additions & 0 deletions test/rect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down