Skip to content

Border radius for pygame.draw.polygon (resolves #1527) #2610

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions buildconfig/stubs/pygame/draw.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def polygon(
color: ColorValue,
points: Sequence[Coordinate],
width: int = 0,
border_radius: int = 0,
) -> Rect: ...
def circle(
surface: Surface,
Expand Down
8 changes: 6 additions & 2 deletions docs/reST/ref/draw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and

| :sl:`draw a polygon`
| :sg:`polygon(surface, color, points) -> Rect`
| :sg:`polygon(surface, color, points, width=0) -> Rect`
| :sg:`polygon(surface, color, points, width=0, border_radius=0) -> Rect`

Draws a polygon on the given surface.

Expand All @@ -129,14 +129,18 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
outside the original boundary of the polygon. For more details on
how the thickness for edge lines grow, refer to the ``width`` notes
of the :func:`pygame.draw.line` function.
:param int border_radius: (optional, default: 0) determines the radius for rounded corners of the polygon.
Only active when both ``width > 0`` and ``border_radius > 0``.

:returns: a rect bounding the changed pixels, if nothing is drawn the
bounding rect's position will be the position of the first point in the
``points`` parameter (float values will be truncated) and its width and
height will be 0
:rtype: Rect

:raises ValueError: if ``len(points) < 3`` (must have at least 3 points)
:raises ValueError: if ``len(points) < 3`` (must have at least 3 points),
or if three of the given points provided in inputs are aligned,
or if the radius is very large in relation to the size of the adjacent edges.
:raises TypeError: if ``points`` is not a sequence or ``points`` does not
contain number pairs

Expand Down
2 changes: 1 addition & 1 deletion src_c/doc/draw_doc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Auto generated file: with make_docs.py . Docs go in docs/reST/ref/ . */
#define DOC_DRAW "pygame module for drawing shapes"
#define DOC_DRAW_RECT "rect(surface, color, rect) -> Rect\nrect(surface, color, rect, width=0, border_radius=0, border_top_left_radius=-1, border_top_right_radius=-1, border_bottom_left_radius=-1, border_bottom_right_radius=-1) -> Rect\ndraw a rectangle"
#define DOC_DRAW_POLYGON "polygon(surface, color, points) -> Rect\npolygon(surface, color, points, width=0) -> Rect\ndraw a polygon"
#define DOC_DRAW_POLYGON "polygon(surface, color, points) -> Rect\npolygon(surface, color, points, width=0, border_radius=0) -> Rect\ndraw a polygon"
#define DOC_DRAW_CIRCLE "circle(surface, color, center, radius) -> Rect\ncircle(surface, color, center, radius, width=0, draw_top_right=None, draw_top_left=None, draw_bottom_left=None, draw_bottom_right=None) -> Rect\ndraw a circle"
#define DOC_DRAW_ELLIPSE "ellipse(surface, color, rect) -> Rect\nellipse(surface, color, rect, width=0) -> Rect\ndraw an ellipse"
#define DOC_DRAW_ARC "arc(surface, color, rect, start_angle, stop_angle) -> Rect\narc(surface, color, rect, start_angle, stop_angle, width=1) -> Rect\ndraw an elliptical arc"
Expand Down
Loading
Loading