Skip to content

Commit 0749a81

Browse files
authored
Merge pull request #2346 from rethanon/main
Add Named Colors to docs for pygame.draw and pygame.Surface
2 parents 500dce0 + 51b3765 commit 0749a81

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

docs/reST/ref/draw.rst

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ bounding box that encloses the affected area.
2323
All the drawing functions accept a color argument that can be one of the
2424
following formats:
2525

26-
- a :mod:`pygame.Color` object
27-
- an ``(RGB)`` triplet (tuple/list)
28-
- an ``(RGBA)`` quadruplet (tuple/list)
29-
- an integer value that has been mapped to the surface's pixel format
26+
- a :mod:`pygame.Color` object, or a type (apart from ``int``) that can be passed to
27+
its constructor
28+
- an ``int`` value which must be mapped to the pixel format of the surface
3029
(see :func:`pygame.Surface.map_rgb` and :func:`pygame.Surface.unmap_rgb`)
3130

3231
A color's alpha value will be written directly into the surface (if the
@@ -53,7 +52,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
5352
:param Surface surface: surface to draw on
5453
:param color: color to draw with, the alpha value is optional if using a
5554
tuple ``(RGB[A])``
56-
:type color: Color or int or tuple(int, int, int, [int])
55+
:type color: Color or string (for :doc:`color_list`) or int or tuple(int, int, int, [int])
5756
:param Rect rect: rectangle to draw, position and dimensions
5857
:param int width: (optional) used for line thickness or to indicate that
5958
the rectangle is to be filled (not to be confused with the width value
@@ -111,7 +110,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
111110
:param Surface surface: surface to draw on
112111
:param color: color to draw with, the alpha value is optional if using a
113112
tuple ``(RGB[A])``
114-
:type color: Color or int or tuple(int, int, int, [int])
113+
:type color: Color or string (for :doc:`color_list`) or int or tuple(int, int, int, [int])
115114
:param points: a sequence of 3 or more (x, y) coordinates that make up the
116115
vertices of the polygon, each *coordinate* in the sequence must be a
117116
tuple/list/:class:`pygame.math.Vector2` of 2 ints/floats,
@@ -159,7 +158,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
159158
:param Surface surface: surface to draw on
160159
:param color: color to draw with, the alpha value is optional if using a
161160
tuple ``(RGB[A])``
162-
:type color: Color or int or tuple(int, int, int, [int])
161+
:type color: Color or string (for :doc:`color_list`) or int or tuple(int, int, int, [int])
163162
:param center: center point of the circle as a sequence of 2 ints/floats,
164163
e.g. ``(x, y)``
165164
:type center: tuple(int or float, int or float) or
@@ -218,7 +217,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
218217
:param Surface surface: surface to draw on
219218
:param color: color to draw with, the alpha value is optional if using a
220219
tuple ``(RGB[A])``
221-
:type color: Color or int or tuple(int, int, int, [int])
220+
:type color: Color or string (for :doc:`color_list`) or int or tuple(int, int, int, [int])
222221
:param Rect rect: rectangle to indicate the position and dimensions of the
223222
ellipse, the ellipse will be centered inside the rectangle and bounded
224223
by it
@@ -259,7 +258,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
259258
:param Surface surface: surface to draw on
260259
:param color: color to draw with, the alpha value is optional if using a
261260
tuple ``(RGB[A])``
262-
:type color: Color or int or tuple(int, int, int, [int])
261+
:type color: Color or string (for :doc:`color_list`) or int or tuple(int, int, int, [int])
263262
:param Rect rect: rectangle to indicate the position and dimensions of the
264263
ellipse which the arc will be based on, the ellipse will be centered
265264
inside the rectangle
@@ -309,7 +308,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
309308
:param Surface surface: surface to draw on
310309
:param color: color to draw with, the alpha value is optional if using a
311310
tuple ``(RGB[A])``
312-
:type color: Color or int or tuple(int, int, int, [int])
311+
:type color: Color or string (for :doc:`color_list`) or int or tuple(int, int, int, [int])
313312
:param start_pos: start position of the line, (x, y)
314313
:type start_pos: tuple(int or float, int or float) or
315314
list(int or float, int or float) or Vector2(int or float, int or float)
@@ -361,7 +360,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
361360
:param Surface surface: surface to draw on
362361
:param color: color to draw with, the alpha value is optional if using a
363362
tuple ``(RGB[A])``
364-
:type color: Color or int or tuple(int, int, int, [int])
363+
:type color: Color or string (for :doc:`color_list`) or int or tuple(int, int, int, [int])
365364
:param bool closed: if ``True`` an additional line segment is drawn between
366365
the first and last points in the ``points`` sequence
367366
:param points: a sequence of 2 or more (x, y) coordinates, where each
@@ -482,7 +481,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
482481
:param Surface surface: surface to draw on
483482
:param color: color to draw with, the alpha value is optional if using a
484483
tuple ``(RGB[A])``
485-
:type color: Color or int or tuple(int, int, int, [int])
484+
:type color: Color or string (for :doc:`color_list`) or int or tuple(int, int, int, [int])
486485
:param start_pos: start position of the line, (x, y)
487486
:type start_pos: tuple(int or float, int or float) or
488487
list(int or float, int or float) or Vector2(int or float, int or float)
@@ -516,7 +515,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
516515
:param Surface surface: surface to draw on
517516
:param color: color to draw with, the alpha value is optional if using a
518517
tuple ``(RGB[A])``
519-
:type color: Color or int or tuple(int, int, int, [int])
518+
:type color: Color or string (for :doc:`color_list`) or int or tuple(int, int, int, [int])
520519
:param bool closed: if ``True`` an additional line segment is drawn between
521520
the first and last points in the ``points`` sequence
522521
:param points: a sequence of 2 or more (x, y) coordinates, where each

docs/reST/ref/surface.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@
248248
entire Surface will be filled. The rect argument will limit the fill to a
249249
specific area. The fill will also be contained by the Surface clip area.
250250

251-
The color argument can be either a ``RGB`` sequence, a ``RGBA`` sequence
252-
or a mapped color index. If using ``RGBA``, the Alpha (A part of
253-
``RGBA``) is ignored unless the surface uses per pixel alpha (Surface has
254-
the ``SRCALPHA`` flag).
251+
The color argument can be an ``RGB`` sequence, an ``RGBA`` sequence,
252+
a string (for :doc:`color_list`), or a mapped color index. If using ``RGBA``,
253+
the Alpha (A part of ``RGBA``) is ignored unless the surface uses per pixel
254+
alpha (Surface has the ``SRCALPHA`` flag).
255255

256256
.. versionaddedold:: 1.8
257257
Optional ``special_flags``: ``BLEND_ADD``, ``BLEND_SUB``,
@@ -285,13 +285,14 @@
285285
.. method:: set_colorkey
286286

287287
| :sl:`Set the transparent colorkey`
288-
| :sg:`set_colorkey(Color, flags=0) -> None`
288+
| :sg:`set_colorkey(color, flags=0) -> None`
289289
| :sg:`set_colorkey(None) -> None`
290290
291291
Set the current color key for the Surface. When blitting this Surface
292292
onto a destination, any pixels that have the same color as the colorkey
293-
will be transparent. The color can be an ``RGB`` color or a mapped color
294-
integer. If ``None`` is passed, the colorkey will be unset.
293+
will be transparent. The color can be an ``RGB`` color, a string
294+
(for :doc:`color_list`), or a mapped color integer. If ``None`` is passed,
295+
the colorkey will be unset.
295296

296297
The colorkey will be ignored if the Surface is formatted to use per pixel
297298
alpha values. The colorkey can be mixed with the full Surface alpha
@@ -461,10 +462,10 @@
461462
| :sl:`set the color value for a single pixel`
462463
| :sg:`set_at((x, y), Color) -> None`
463464
464-
Set the ``RGBA`` or mapped integer color value for a single pixel. If the
465-
Surface does not have per pixel alphas, the alpha value is ignored.
466-
Setting pixels outside the Surface area or outside the Surface clipping
467-
will have no effect.
465+
Set the color of a single pixel at the specified coordinates to be an ``RGB``,
466+
``RGBA``, string (for :doc:`color_list`), or mapped integer color value. If the Surface
467+
does not have per pixel alphas, the alpha value is ignored. Setting pixels outside the
468+
Surface area or outside the Surface clipping will have no effect.
468469

469470
Getting and setting pixels one at a time is generally too slow to be used
470471
in a game or realtime situation.
@@ -534,7 +535,7 @@
534535
Set the full palette for an 8-bit Surface. This will replace the colors in
535536
the existing palette. A partial palette can be passed and only the first
536537
colors in the original palette will be changed.
537-
538+
538539
This function has no effect on a Surface with more than 8-bits per pixel.
539540

540541
.. ## Surface.set_palette ##
@@ -546,7 +547,7 @@
546547
547548
Set the palette value for a single entry in a Surface palette. The index
548549
should be a value from 0 to 255.
549-
550+
550551
This function has no effect on a Surface with more than 8-bits per pixel.
551552

552553
.. ## Surface.set_palette_at ##

src_c/doc/surface_doc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define DOC_SURFACE_COPY "copy() -> Surface\ncreate a new copy of a Surface"
99
#define DOC_SURFACE_FILL "fill(color, rect=None, special_flags=0) -> Rect\nfill Surface with a solid color"
1010
#define DOC_SURFACE_SCROLL "scroll(dx=0, dy=0) -> None\nShift the surface image in place"
11-
#define DOC_SURFACE_SETCOLORKEY "set_colorkey(Color, flags=0) -> None\nset_colorkey(None) -> None\nSet the transparent colorkey"
11+
#define DOC_SURFACE_SETCOLORKEY "set_colorkey(color, flags=0) -> None\nset_colorkey(None) -> None\nSet the transparent colorkey"
1212
#define DOC_SURFACE_GETCOLORKEY "get_colorkey() -> RGB or None\nGet the current transparent colorkey"
1313
#define DOC_SURFACE_SETALPHA "set_alpha(value, flags=0) -> None\nset_alpha(None) -> None\nset the alpha value for the full Surface image"
1414
#define DOC_SURFACE_GETALPHA "get_alpha() -> int_value\nget the current Surface transparency value"

0 commit comments

Comments
 (0)