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

Add draw.aalines width argument #3154

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions buildconfig/stubs/pygame/draw.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ def aalines(
color: ColorLike,
closed: bool,
points: SequenceLike[Point],
width: int = 1,
) -> Rect: ...
Binary file modified docs/reST/ref/code_examples/draw_module_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions docs/reST/ref/code_examples/draw_module_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
screen, "black", False, [[0, 80], [50, 90], [200, 80], [220, 30]], 5
)

# Draw on the screen 3 black antialiased lines, each 5 pixels wide.
# The 'False' means the first and last points are not connected.
pygame.draw.aalines(
screen, "black", False, [[70, 40], [160, 50], [130, 65], [70, 55]], 5
)

# Draw a rectangle outline
pygame.draw.rect(screen, "black", [75, 10, 50, 20], 2)

Expand Down
15 changes: 13 additions & 2 deletions docs/reST/ref/draw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,10 @@ object around the draw calls (see :func:`pygame.Surface.lock` and

| :sl:`draw multiple contiguous straight antialiased line segments`
| :sg:`aalines(surface, color, closed, points) -> Rect`
| :sg:`lines(surface, color, closed, points, width=1) -> Rect`

Draws a sequence of contiguous straight antialiased lines on the given
surface.
Draws a sequence of contiguous straight lines on the given surface.
For thick lines, the edges have miter joints and the ends are squared off.

:param Surface surface: surface to draw on
:param color: color to draw with, the alpha value is optional if using a
Expand All @@ -525,6 +526,15 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
additionally if the ``closed`` parameter is ``True`` another line segment
will be drawn from ``(x3, y3)`` to ``(x1, y1)``
:type points: tuple(point) or list(point)
:param int width: (optional) used for line thickness

| if width >= 1, used for line thickness (default is 1)
| if width < 1, nothing will be drawn
|

.. note::
When using ``width`` values ``> 1`` refer to the ``width`` notes
of :func:`line` for details on how thick lines grow.

: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
Expand All @@ -539,6 +549,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
.. versionchangedold:: 2.0.0 Added support for keyword arguments.
.. versionchanged:: 2.4.0 Removed deprecated ``blend`` argument
.. versionchanged:: 2.5.0 ``blend`` argument readded for backcompat, but will always raise a deprecation exception when used
.. versionchanged:: 2.5.3 Added line width

.. ## pygame.draw.aalines ##

Expand Down
2 changes: 1 addition & 1 deletion src_c/doc/draw_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
#define DOC_DRAW_LINE "line(surface, color, start_pos, end_pos) -> Rect\nline(surface, color, start_pos, end_pos, width=1) -> Rect\ndraw a straight line"
#define DOC_DRAW_LINES "lines(surface, color, closed, points) -> Rect\nlines(surface, color, closed, points, width=1) -> Rect\ndraw multiple contiguous straight line segments"
#define DOC_DRAW_AALINE "aaline(surface, color, start_pos, end_pos) -> Rect\naaline(surface, color, start_pos, end_pos, width=1) -> Rect\ndraw a straight antialiased line"
#define DOC_DRAW_AALINES "aalines(surface, color, closed, points) -> Rect\ndraw multiple contiguous straight antialiased line segments"
#define DOC_DRAW_AALINES "aalines(surface, color, closed, points) -> Rect\nlines(surface, color, closed, points, width=1) -> Rect\ndraw multiple contiguous straight antialiased line segments"
Loading
Loading