Represents a 2D pixel buffer for image manipulation and blitting operations.
PixelArray(width: int, height: int) → PixelArrayPixelArray(width: int, height: int) → PixelArray
PixelArray(file_path: str | PathLike[str]) → PixelArrayPixelArray(file_path: str | PathLike[str]) → PixelArray
Represents a 2D pixel buffer for image manipulation and blitting operations.
| Name | Description | Type |
|---|---|---|
alpha_mod | The alpha modulation value for the pixel array. | int |
color_key | The color key for transparency. | Color |
height | The height of the pixel array. | int |
size | The size of the pixel array as a Vec2. | Vec2 |
width | The width of the pixel array. | int |
blit(pixel_array: PixelArray, pos: Vec2, anchor: Vec2 = ..., src: Rect = ...) → Noneblit(pixel_array: PixelArray, pos: Vec2, anchor: Vec2 = ..., src: Rect = ...) → NoneBlit (copy) another pixel array onto this pixel array at the specified position with anchor alignment.
Args
pixel_array : The source pixel array to blit from.pos : The position to blit to.anchor : The anchor point for positioning. Defaults to (0,0) TopLeft.src : The source rectangle to blit from. Defaults to entire source pixel array.Raises
RuntimeError : If the blit operation fails.blit(pixel_array: PixelArray, dst: Rect, src: Rect = ...) → Noneblit(pixel_array: PixelArray, dst: Rect, src: Rect = ...) → NoneBlit (copy) another pixel array onto this pixel array with specified destination and source rectangles.
Args
pixel_array : The source pixel array to blit from.dst : The destination rectangle on this pixel array.src : The source rectangle to blit from. Defaults to entire source pixel array.Raises
RuntimeError : If the blit operation fails.copy() → PixelArraycopy() → PixelArrayCreate a copy of this pixel array.
Returns
PixelArray : A new PixelArray that is an exact copy of this one.
Raises
RuntimeError : If pixel array copying fails.fill(color: Color) → Nonefill(color: Color) → NoneFill the entire pixel array with a solid color.
Args
color : The color to fill the pixel array with.get_at(x: int, y: int) → Colorget_at(x: int, y: int) → ColorGet the color of a pixel at the specified coordinates.
Args
x : The x-coordinate of the pixel.y : The y-coordinate of the pixel.Returns
Color : The color of the pixel at the specified coordinates.
Raises
IndexError : If coordinates are outside the pixel array bounds.get_rect() → Rectget_rect() → RectGet a rectangle representing the pixel array bounds.
Returns
Rect : A rectangle with position (0, 0) and the pixel array's dimensions.
scroll(dx: int, dy: int, scroll_mode: ScrollMode) → Nonescroll(dx: int, dy: int, scroll_mode: ScrollMode) → NoneScroll the pixel array's contents by the specified offset.
Args
dx : Horizontal scroll offset in pixels.dy : Vertical scroll offset in pixels.scroll_mode : Behavior for pixels scrolled off the edge.- REPEAT : Wrap pixels around to the opposite edge.- ERASE : Fill scrolled areas with transparent pixels.- SMEAR : Extend edge pixels into scrolled areas.set_at(x: int, y: int, color: Color) → Noneset_at(x: int, y: int, color: Color) → NoneSet the color of a pixel at the specified coordinates.
Args
x : The x-coordinate of the pixel.y : The y-coordinate of the pixel.color : The color to set the pixel to.Raises
IndexError : If coordinates are outside the pixel array bounds.