PixelArray
An array of pixel color data.
Constructor
-
PixelArray(size: Vec2) -
PixelArray(file_path: str)
Parameters
size: The size of the pixel array as (width, height).file_path: Path to the image file to load.
Properties
| Name | Description | Type |
|---|---|---|
color_key | The color key used for transparency in the pixel array | Color |
alpha_mod | The alpha modulation value for the pixel array (0-255) | int |
width | The width of the pixel array in pixels | int |
height | The height of the pixel array in pixels | int |
size | The size of the pixel array | Vec2 |
Methods
Fill
fill(color: Color) → NoneFill the pixel array with a color.
Parameters
color: The color to fill the pixel array with.
Blit
blit(
pixel_array: PixelArray,
pos: Vec2,
anchor: Anchor = Anchor.CENTER,
src: Rect = None
) → NoneBlit another pixel array onto this one via position and anchor.
Parameters
pixel_array: The pixel array to blit onto this one.pos: The position to blit the pixel array at.anchor: The anchor point for the blit operation.src: The source rectangle to blit from.
blit(pixel_array: PixelArray, dst: Rect, src: Rect = None) → NoneBlit another pixel array onto this one via destination and source rectangles.
Parameters
pixel_array: The pixel array to blit onto this one.dst: The destination rectangle to blit to.src: The source rectangle to blit from.
Scroll
scroll(dx: int, dy: int, scroll_mode: ScrollMode) → NoneScroll the pixel array by the specified amounts in the x and y directions.
Parameters
dx: The amount to scroll in the x direction.dy: The amount to scroll in the y direction.scroll_mode: The scroll mode to use.
Get Rect
get_rect() → RectGet the rectangle representing the pixel array's dimensions.
Returns
Rect : The pixel array's rectangle.
Get At
get_at(pos: Vec2) → ColorGet the color of the pixel at the specified position.
Parameters
pos: The position of the pixel to get the color of.
Returns
Color : The color of the pixel at the specified position.
Set At
set_at(pos: Vec2, color: Color) → NoneSet the color of the pixel at the specified position.
Parameters
pos: The position of the pixel to set the color of.color: The color to set the pixel to.
Copy
copy() → PixelArrayCreate a copy of the pixel array.
Returns
PixelArray : A new pixel array object that is a copy of the original.