Skip to content

Commit aa236dd

Browse files
authored
Merge pull request #3605 from damusss/clean-surface-docs-3
Clean Surface docs 3: minor clarifications, typos and movements
2 parents 757a3e5 + 4185490 commit aa236dd

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

buildconfig/stubs/pygame/surface.pyi

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class Surface:
150150
**Parameters**
151151
- ``source``
152152
The ``Surface`` object to draw onto this ``Surface``.
153-
If it has transparency, transparent pixels will be ignored when blittting to an 8-bit ``Surface``.
153+
If it has transparency, transparent pixels will be ignored when blitting to an 8-bit ``Surface``.
154154
- ``dest`` *(optional)*
155155
The ``source`` draw position onto this ``Surface``, defaults to (0, 0).
156156
It can be a coordinate pair ``(x, y)`` or a ``Rect`` (using its top-left corner).
@@ -271,7 +271,7 @@ class Surface:
271271
:param special_flags: the flag(s) representing the blend mode used for each Surface.
272272
See :doc:`special_flags_list` for a list of possible values.
273273
274-
:returns: ``None``
274+
:returns: ``None`` (unlike `blit()` and `blits()`)
275275
276276
.. note:: This method only accepts a sequence of (source, dest) pairs and a single
277277
special_flags value that's applied to all Surfaces drawn. This allows faster
@@ -341,6 +341,9 @@ class Surface:
341341
attributes then it should override ``copy()``. Shallow copy and deepcopy
342342
are supported, Surface implements __copy__ and __deepcopy__ respectively.
343343
344+
If the Surface is a subsurface, the returned Surface will *not* retain
345+
the parent and will be a regular Surface with its own pixel data.
346+
344347
.. versionadded:: 2.3.1
345348
Added support for deepcopy by implementing __deepcopy__, calls copy() internally.
346349
"""
@@ -436,23 +439,23 @@ class Surface:
436439
onto a destination, the pixels will be drawn slightly transparent. The
437440
alpha value is an integer from 0 to 255, 0 is fully transparent and 255
438441
is fully opaque. If ``None`` is passed for the alpha value, then alpha
439-
blending will be disabled, including per-pixel alpha.
440-
441-
This value is different than the per pixel Surface alpha. For a Surface
442-
with per pixel alpha, blanket alpha is ignored and ``None`` is returned.
443-
444-
.. versionchangedold:: 2.0 per-Surface alpha can be combined with per-pixel
445-
alpha.
442+
blending will be disabled. This full alpha is compatible with other
443+
kinds of transparency.
446444
447445
The optional flags argument can be set to ``pygame.RLEACCEL`` to provide
448446
better performance on non accelerated displays. An ``RLEACCEL`` Surface
449447
will be slower to modify, but quicker to blit as a source.
448+
449+
.. versionchangedold:: 2.0 per-Surface alpha can be combined with per-pixel
450+
alpha.
450451
"""
451452

452453
def get_alpha(self) -> int | None:
453454
"""Get the current Surface transparency value.
454455
455-
Return the current alpha value for the Surface.
456+
Return the current alpha value for the Surface, which is an integer in the
457+
range 0 (fully transparent) - 255 (fully opaque) set by :meth:`set_alpha()`.
458+
Until an alpha is set this method will return None.
456459
"""
457460

458461
def lock(self) -> None:
@@ -710,8 +713,8 @@ class Surface:
710713
def get_abs_parent(self) -> Surface:
711714
"""Find the top level parent of a subsurface.
712715
713-
Returns the parent Surface of a subsurface. If this is not a subsurface
714-
then this Surface will be returned.
716+
Returns the top level parent Surface of a subsurface. If this is not
717+
a subsurface then this Surface will be returned.
715718
"""
716719

717720
def get_offset(self) -> tuple[int, int]:
@@ -958,15 +961,6 @@ class Surface:
958961
"""
959962

960963
def get_blendmode(self) -> int: ...
961-
@property
962-
def _pixels_address(self) -> int:
963-
"""Pixel buffer address.
964-
965-
The starting address of the Surface's raw pixel bytes.
966-
967-
.. versionaddedold:: 1.9.2
968-
"""
969-
970964
def premul_alpha(self) -> Surface:
971965
"""Returns a copy of the Surface with the RGB channels pre-multiplied by the alpha channel.
972966
@@ -1050,5 +1044,14 @@ class Surface:
10501044
.. versionadded:: 2.5.0
10511045
"""
10521046

1047+
@property
1048+
def _pixels_address(self) -> int:
1049+
"""Pixel buffer address.
1050+
1051+
The starting address of the surface's raw pixel bytes.
1052+
1053+
.. versionaddedold:: 1.9.2
1054+
"""
1055+
10531056
@deprecated("Use `Surface` instead (SurfaceType is an old alias)")
10541057
class SurfaceType(Surface): ...

src_c/doc/surface_doc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
#define DOC_SURFACE_GETBOUNDINGRECT "get_bounding_rect(min_alpha=1) -> Rect\nFind the smallest rect containing data."
5151
#define DOC_SURFACE_GETVIEW "get_view(kind='2', /) -> BufferProxy\nReturn a buffer view of the Surface's pixels."
5252
#define DOC_SURFACE_GETBUFFER "get_buffer() -> BufferProxy\nAcquires a buffer object for the pixels of the Surface."
53-
#define DOC_SURFACE_PIXELSADDRESS "_pixels_address -> int\nPixel buffer address."
5453
#define DOC_SURFACE_PREMULALPHA "premul_alpha() -> Surface\nReturns a copy of the Surface with the RGB channels pre-multiplied by the alpha channel."
5554
#define DOC_SURFACE_PREMULALPHAIP "premul_alpha_ip() -> Surface\nMultiplies the RGB channels by the Surface alpha channel."
5655
#define DOC_SURFACE_WIDTH "width -> int\nSurface width in pixels (read-only)."
5756
#define DOC_SURFACE_HEIGHT "height -> int\nSurface height in pixels (read-only)."
5857
#define DOC_SURFACE_SIZE "size -> tuple[int, int]\nSurface size in pixels (read-only)."
58+
#define DOC_SURFACE_PIXELSADDRESS "_pixels_address -> int\nPixel buffer address."

0 commit comments

Comments
 (0)