@@ -143,22 +143,22 @@ class Surface:
143143 area : Optional [RectLike ] = None ,
144144 special_flags : int = 0 ,
145145 ) -> Rect :
146- """Draw another surface onto this one.
146+ """Draw another Surface onto this one.
147147
148148 Draws another Surface onto this Surface.
149149
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).
157157 If a ``Rect`` is passed, its size will not affect the blit.
158158 - ``area`` *(optional)*
159159 The rectangular portion of the ``source`` to draw.
160160 It can be a ``Rect`` object representing that section. If ``None`` or not provided,
161- the entire source surface will be drawn.
161+ the entire source Surface will be drawn.
162162 If the ``Rect`` has negative position, the final blit position will be
163163 ``dest`` - ``Rect.topleft``.
164164 - ``special_flags`` *(optional)*
@@ -176,11 +176,11 @@ class Surface:
176176 **Example Use**
177177 .. code-block:: python
178178
179- # create a surface of size 50x50 and fill it with red color
179+ # create a Surface of size 50x50 and fill it with red color
180180 red_surf = pygame.Surface((50, 50))
181181 red_surf.fill("red")
182182
183- # draw the surface on another surface at position (0, 0)
183+ # draw the Surface on another Surface at position (0, 0)
184184 another_surface.blit(red_surf, (0, 0))
185185
186186 **Notes**
@@ -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 regular blitting)
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 was 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,7 +439,8 @@ 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.
442+ blending will be disabled. This full alpha is compatible with other
443+ kinds of transparency.
440444
441445 This value is different than the per pixel Surface alpha. For a surface
442446 with per pixel alpha, blanket alpha is ignored and ``None`` is returned.
@@ -447,80 +451,19 @@ class Surface:
447451 The optional flags argument can be set to ``pygame.RLEACCEL`` to provide
448452 better performance on non accelerated displays. An ``RLEACCEL`` Surface
449453 will be slower to modify, but quicker to blit as a source.
454+
455+ .. versionchangedold:: 2.0 per-Surface alpha can be combined with per-pixel
456+ alpha.
450457 """
451458
452459 def get_alpha (self ) -> Optional [int ]:
453460 """Get the current Surface transparency value.
454461
455- Return the current alpha value for the Surface.
456- """
457-
458- def lock (self ) -> None :
459- """Lock the Surface memory for pixel access.
460-
461- Lock the pixel data of a Surface for access. On accelerated Surfaces, the
462- pixel data may be stored in volatile video memory or nonlinear compressed
463- forms. When a Surface is locked the pixel memory becomes available to
464- access by regular software. Code that reads or writes pixel values will
465- need the Surface to be locked.
466-
467- Surfaces should not remain locked for more than necessary. A locked
468- Surface can often not be displayed or managed by pygame.
469-
470- Not all Surfaces require locking. The :meth:`mustlock()` method can
471- determine if it is actually required. There is no performance penalty for
472- locking and unlocking a Surface that does not need it.
473-
474- All pygame functions will automatically lock and unlock the Surface data
475- as needed. If a section of code is going to make calls that will
476- repeatedly lock and unlock the Surface many times, it can be helpful to
477- wrap the block inside a lock and unlock pair.
478-
479- It is safe to nest locking and unlocking calls. The surface will only be
480- unlocked after the final lock is released.
481- """
482-
483- def unlock (self ) -> None :
484- """Unlock the Surface memory from pixel access.
485-
486- Unlock the Surface pixel data after it has been locked. The unlocked
487- Surface can once again be drawn and managed by pygame. See the
488- :meth:`lock()` documentation for more details.
489-
490- All pygame functions will automatically lock and unlock the Surface data
491- as needed. If a section of code is going to make calls that will
492- repeatedly lock and unlock the Surface many times, it can be helpful to
493- wrap the block inside a lock and unlock pair.
494-
495- It is safe to nest locking and unlocking calls. The surface will only be
496- unlocked after the final lock is released.
497- """
498-
499- def mustlock (self ) -> bool :
500- """Test if the Surface requires locking.
501-
502- Returns ``True`` if the Surface is required to be locked to access pixel
503- data. Usually pure software Surfaces do not require locking. This method
504- is rarely needed, since it is safe and quickest to just lock all Surfaces
505- as needed.
506-
507- All pygame functions will automatically lock and unlock the Surface data
508- as needed. If a section of code is going to make calls that will
509- repeatedly lock and unlock the Surface many times, it can be helpful to
510- wrap the block inside a lock and unlock pair.
511- """
512-
513- def get_locked (self ) -> bool :
514- """Test if the Surface is current locked.
515-
516- Returns ``True`` when the Surface is locked. It doesn't matter how many
517- times the Surface is locked.
518- """
519-
520- def get_locks (self ) -> tuple [Any , ...]:
521- """Gets the locks for the Surface.
522-
523- Returns the currently existing locks for the Surface.
462+ Return the current alpha value for the Surface. If the blendmode of the
463+ Surface is not ``pygame.BLENDMODE_NONE``, this method will always return
464+ a valid value in the range 0 (fully transparent) - 255 (fully opaque).
465+ Otherwise, this method will return None until an alpha is set with
466+ :meth:`set_alpha()` (the set alpha value will be returned).
524467 """
525468
526469 def get_at (self , x_y : Point , / ) -> Color :
@@ -710,8 +653,8 @@ class Surface:
710653 def get_abs_parent (self ) -> Surface :
711654 """Find the top level parent of a subsurface.
712655
713- Returns the parent Surface of a subsurface. If this is not a subsurface
714- then this surface will be returned.
656+ Returns the top level parent Surface of a subsurface. If this is not
657+ a subsurface then this Surface will be returned.
715658 """
716659
717660 def get_offset (self ) -> tuple [int , int ]:
@@ -958,15 +901,6 @@ class Surface:
958901 """
959902
960903 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-
970904 def premul_alpha (self ) -> Surface :
971905 """Returns a copy of the surface with the RGB channels pre-multiplied by the alpha channel.
972906
@@ -1024,6 +958,74 @@ class Surface:
1024958 .. versionadded:: 2.5.1
1025959 """
1026960
961+ def lock (self ) -> None :
962+ """Lock the Surface memory for pixel access.
963+
964+ Lock the pixel data of a Surface for access. On accelerated Surfaces, the
965+ pixel data may be stored in volatile video memory or nonlinear compressed
966+ forms. When a Surface is locked the pixel memory becomes available to
967+ access by regular software. Code that reads or writes pixel values will
968+ need the Surface to be locked.
969+
970+ Surfaces should not remain locked for more than necessary. A locked
971+ Surface can often not be displayed or managed by pygame.
972+
973+ Not all Surfaces require locking. The :meth:`mustlock()` method can
974+ determine if it is actually required. There is no performance penalty for
975+ locking and unlocking a Surface that does not need it.
976+
977+ All pygame functions will automatically lock and unlock the Surface data
978+ as needed. If a section of code is going to make calls that will
979+ repeatedly lock and unlock the Surface many times, it can be helpful to
980+ wrap the block inside a lock and unlock pair.
981+
982+ It is safe to nest locking and unlocking calls. The surface will only be
983+ unlocked after the final lock is released.
984+ """
985+
986+ def unlock (self ) -> None :
987+ """Unlock the Surface memory from pixel access.
988+
989+ Unlock the Surface pixel data after it has been locked. The unlocked
990+ Surface can once again be drawn and managed by pygame. See the
991+ :meth:`lock()` documentation for more details.
992+
993+ All pygame functions will automatically lock and unlock the Surface data
994+ as needed. If a section of code is going to make calls that will
995+ repeatedly lock and unlock the Surface many times, it can be helpful to
996+ wrap the block inside a lock and unlock pair.
997+
998+ It is safe to nest locking and unlocking calls. The surface will only be
999+ unlocked after the final lock is released.
1000+ """
1001+
1002+ def mustlock (self ) -> bool :
1003+ """Test if the Surface requires locking.
1004+
1005+ Returns ``True`` if the Surface is required to be locked to access pixel
1006+ data. Usually pure software Surfaces do not require locking. This method
1007+ is rarely needed, since it is safe and quickest to just lock all Surfaces
1008+ as needed.
1009+
1010+ All pygame functions will automatically lock and unlock the Surface data
1011+ as needed. If a section of code is going to make calls that will
1012+ repeatedly lock and unlock the Surface many times, it can be helpful to
1013+ wrap the block inside a lock and unlock pair.
1014+ """
1015+
1016+ def get_locked (self ) -> bool :
1017+ """Test if the Surface is current locked.
1018+
1019+ Returns ``True`` when the Surface is locked. It doesn't matter how many
1020+ times the Surface is locked.
1021+ """
1022+
1023+ def get_locks (self ) -> tuple [Any , ...]:
1024+ """Gets the locks for the Surface.
1025+
1026+ Returns the currently existing locks for the Surface.
1027+ """
1028+
10271029 @property
10281030 def width (self ) -> int :
10291031 """Surface width in pixels (read-only).
@@ -1050,5 +1052,14 @@ class Surface:
10501052 .. versionadded:: 2.5.0
10511053 """
10521054
1055+ @property
1056+ def _pixels_address (self ) -> int :
1057+ """Pixel buffer address.
1058+
1059+ The starting address of the surface's raw pixel bytes.
1060+
1061+ .. versionaddedold:: 1.9.2
1062+ """
1063+
10531064@deprecated ("Use `Surface` instead (SurfaceType is an old alias)" )
10541065class SurfaceType (Surface ): ...
0 commit comments