This commit is contained in:
wittmannzl103469 committed 2026-11-05 15:08:42 +01:00
1 parent de41a02749
commit 9af09cebd3
764 files changed
+54218 -78859

No files matched your search

@@ -1,4 +1,4 @@
## pygame-ce - Python Game Library
## pygame - Python Game Library
## Copyright (C) 2007 Marcus von Appen
##
## This library is free software; you can redistribute it and/or
@@ -37,21 +37,23 @@ to as 3D arrays, and the last index is 0 for red, 1 for green, and 2 for
blue.
"""
import warnings # will be removed in the future
from pygame.pixelcopy import (
array_to_surface,
surface_to_array,
map_array as pix_map_array,
make_surface as pix_make_surface,
)
import numpy
from numpy import (
array as numpy_array,
empty as numpy_empty,
ndarray as numpy_ndarray,
uint32 as numpy_uint32,
ndarray as numpy_ndarray,
)
from pygame.pixelcopy import (
array_to_surface,
make_surface as pix_make_surface,
map_array as pix_map_array,
surface_to_array,
)
import warnings # will be removed in the future
# float96 not available on all numpy versions.
numpy_floats = [
@@ -59,7 +61,7 @@ numpy_floats = [
for type_name in "float32 float64 float96".split()
if hasattr(numpy, type_name)
]
# Added below due to deprecation of numpy.float. See pygame-ce issue #1440
# Added below due to deprecation of numpy.float. See issue #2814
numpy_floats.append(float)
# Pixel sizes corresponding to NumPy supported integer sizes, and therefore
@@ -95,19 +97,12 @@ __all__ = [
def blit_array(surface, array):
"""pygame.surfarray.blit_array(Surface, array): return None
Blit directly from an array of values.
Blit directly from a array values.
Directly copy values from an array into a Surface. This is faster than
converting the array into a Surface and blitting. The array must be the
same dimensions as the Surface and will completely replace all pixel
values. Accepted array types are integer, ascii character and record
arrays, as well as ``float32``, ``float64`` and (where available)
``float96`` NumPy arrays.
Float arrays are first rounded to the nearest integer and copied into
a new array before blitting. This extra copy defeats the performance
benefit this function is meant to provide, so pass an integer array
directly whenever possible.
values. Only integer, ascii character and record arrays are accepted.
This function will temporarily lock the Surface as the new values are
copied.
@@ -123,11 +118,7 @@ def make_surface(array):
Copy an array to a new surface.
Create a new Surface that best resembles the data and format on the
array. The array can be 2D or 3D with any sized integer values, or
``float32``, ``float64`` or (where available) ``float96`` NumPy arrays.
Float arrays are first rounded to the nearest integer and copied into
a new array before creating the surface.
array. The array can be 2D or 3D with any sized integer values.
"""
if isinstance(array, numpy_ndarray) and array.dtype in numpy_floats:
array = array.round(0).astype(numpy_uint32)
@@ -395,9 +386,9 @@ def map_array(surface, array):
format to control the conversion.
Note: arrays do not need to be 3D, as long as the minor axis has
three elements giving the component colors, any array shape can be
used (for example, a single color can be mapped, or an array of
colors). The array shape is limited to eleven dimensions maximum,
three elements giving the component colours, any array shape can be
used (for example, a single colour can be mapped, or an array of
colours). The array shape is limited to eleven dimensions maximum,
including the three element minor axis.
"""
if array.ndim == 0: