ipygame.surface
pygame-compatible Surface class.
Surface Objects
Section titled “Surface Objects”class Surface()A 2-D image stored as a NumPy RGBA pixel buffer.
Parameters
Section titled “Parameters”size : (int, int) Width and height of the surface. flags : int Surface flags (currently unused; kept for API compatibility). depth : int Bit depth (always treated as 32).
__init__
Section titled “__init__”def __init__(size: tuple[int, int] = (0, 0), flags: int = 0, depth: int = 32, *, _pixels: np.ndarray | None = None, _parent: "Surface | None" = None)@propertydef width() -> intheight
Section titled “height”@propertydef height() -> int@propertydef size() -> tuple[int, int]get_width
Section titled “get_width”def get_width() -> intget_height
Section titled “get_height”def get_height() -> intget_size
Section titled “get_size”def get_size() -> tuple[int, int]get_rect
Section titled “get_rect”def get_rect(**kwargs) -> Rectget_frect
Section titled “get_frect”def get_frect(**kwargs) -> FRectget_bitsize
Section titled “get_bitsize”def get_bitsize() -> intget_bytesize
Section titled “get_bytesize”def get_bytesize() -> intget_flags
Section titled “get_flags”def get_flags() -> intget_pitch
Section titled “get_pitch”def get_pitch() -> intget_masks
Section titled “get_masks”def get_masks() -> tuple[int, int, int, int]get_shifts
Section titled “get_shifts”def get_shifts() -> tuple[int, int, int, int]get_losses
Section titled “get_losses”def get_losses() -> tuple[int, int, int, int]get_at
Section titled “get_at”def get_at(pos) -> Colorset_at
Section titled “set_at”def set_at(pos, color) -> Noneget_at_mapped
Section titled “get_at_mapped”def get_at_mapped(pos) -> intmap_rgb
Section titled “map_rgb”def map_rgb(color) -> intunmap_rgb
Section titled “unmap_rgb”def unmap_rgb(mapped: int) -> Colordef fill(color, rect=None, special_flags: int = 0) -> RectFill the surface (or a sub-region) with color.
def blit(source: "Surface", dest=(0, 0), area=None, special_flags: int = 0) -> RectDraw source onto this surface at dest.
def blits(blit_sequence, doreturn: bool = True) -> list[Rect] | Nonefblits
Section titled “fblits”def fblits(blit_sequence, special_flags: int = 0) -> Noneconvert
Section titled “convert”def convert(*args) -> "Surface"Return a copy (everything is 32-bit RGBA in ipygame).
convert_alpha
Section titled “convert_alpha”def convert_alpha(*args) -> "Surface"Return a copy (everything is 32-bit RGBA in ipygame).
def copy() -> "Surface"subsurface
Section titled “subsurface”def subsurface(rect) -> "Surface"Return a Surface sharing pixels with a region of this Surface.
scroll
Section titled “scroll”def scroll(dx: int = 0, dy: int = 0) -> Noneset_colorkey
Section titled “set_colorkey”def set_colorkey(color=None, flags: int = 0) -> Noneget_colorkey
Section titled “get_colorkey”def get_colorkey() -> tuple[int, int, int, int] | Noneset_alpha
Section titled “set_alpha”def set_alpha(value: int | None = None, flags: int = 0) -> Noneget_alpha
Section titled “get_alpha”def get_alpha() -> int | Noneset_clip
Section titled “set_clip”def set_clip(rect=None) -> Noneget_clip
Section titled “get_clip”def get_clip() -> Rectdef lock() -> Noneunlock
Section titled “unlock”def unlock() -> Nonemustlock
Section titled “mustlock”def mustlock() -> boolget_locked
Section titled “get_locked”def get_locked() -> boolget_locks
Section titled “get_locks”def get_locks() -> tupleget_view
Section titled “get_view”def get_view(kind: str = "2") -> memoryviewget_buffer
Section titled “get_buffer”def get_buffer() -> memoryviewget_bounding_rect
Section titled “get_bounding_rect”def get_bounding_rect(min_alpha: int = 1) -> RectReturn the smallest Rect containing all pixels with alpha >= min_alpha.
premul_alpha
Section titled “premul_alpha”def premul_alpha() -> "Surface"premul_alpha_ip
Section titled “premul_alpha_ip”def premul_alpha_ip() -> None