Skip to content

ipygame.surface

pygame-compatible Surface class.

class Surface()

A 2-D image stored as a NumPy RGBA pixel buffer.

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).

def __init__(size: tuple[int, int] = (0, 0),
flags: int = 0,
depth: int = 32,
*,
_pixels: np.ndarray | None = None,
_parent: "Surface | None" = None)

@property
def width() -> int

@property
def height() -> int

@property
def size() -> tuple[int, int]

def get_width() -> int

def get_height() -> int

def get_size() -> tuple[int, int]

def get_rect(**kwargs) -> Rect

def get_frect(**kwargs) -> FRect

def get_bitsize() -> int

def get_bytesize() -> int

def get_flags() -> int

def get_pitch() -> int

def get_masks() -> tuple[int, int, int, int]

def get_shifts() -> tuple[int, int, int, int]

def get_losses() -> tuple[int, int, int, int]

def get_at(pos) -> Color

def set_at(pos, color) -> None

def get_at_mapped(pos) -> int

def map_rgb(color) -> int

def unmap_rgb(mapped: int) -> Color

def fill(color, rect=None, special_flags: int = 0) -> Rect

Fill the surface (or a sub-region) with color.

def blit(source: "Surface",
dest=(0, 0),
area=None,
special_flags: int = 0) -> Rect

Draw source onto this surface at dest.

def blits(blit_sequence, doreturn: bool = True) -> list[Rect] | None

def fblits(blit_sequence, special_flags: int = 0) -> None

def convert(*args) -> "Surface"

Return a copy (everything is 32-bit RGBA in ipygame).

def convert_alpha(*args) -> "Surface"

Return a copy (everything is 32-bit RGBA in ipygame).

def copy() -> "Surface"

def subsurface(rect) -> "Surface"

Return a Surface sharing pixels with a region of this Surface.

def scroll(dx: int = 0, dy: int = 0) -> None

def set_colorkey(color=None, flags: int = 0) -> None

def get_colorkey() -> tuple[int, int, int, int] | None

def set_alpha(value: int | None = None, flags: int = 0) -> None

def get_alpha() -> int | None

def set_clip(rect=None) -> None

def get_clip() -> Rect

def lock() -> None

def unlock() -> None

def mustlock() -> bool

def get_locked() -> bool

def get_locks() -> tuple

def get_view(kind: str = "2") -> memoryview

def get_buffer() -> memoryview

def get_bounding_rect(min_alpha: int = 1) -> Rect

Return the smallest Rect containing all pixels with alpha >= min_alpha.

def premul_alpha() -> "Surface"

def premul_alpha_ip() -> None