Pixel Array
Functions for transforming pixel arrays.
Flip
flip(pixel_array: PixelArray, flip_x: bool, flip_y: bool) → PixelArrayFlip a pixel array horizontally and/or vertically.
Parameters
pixel_array: The pixel array to flip.flip_x: Whether to flip the pixel array horizontally.flip_y: Whether to flip the pixel array vertically.
Returns
PixelArray : The flipped pixel array.
Scale To
scale_to(pixel_array: PixelArray, size: Vec2) → PixelArrayScale a pixel array to a specific size.
Parameters
pixel_array: The pixel array to scale.size: The size to scale the pixel array to.
Returns
PixelArray : The scaled pixel array.
Scale By
scale_by(pixel_array: PixelArray, factor: float) → PixelArrayScale a pixel array by a specific factor.
Parameters
pixel_array: The pixel array to scale.factor: The factor by which to scale the pixel array.
Returns
PixelArray : The scaled pixel array.
Rotate
rotate(pixel_array: PixelArray, angle: float) → PixelArrayRotate a pixel array by a specific angle.
Parameters
pixel_array: The pixel array to rotate.angle: The angle in degrees to rotate the pixel array.
Returns
PixelArray : The rotated pixel array.
Box Blur
box_blur(pixel_array: PixelArray, radius: int, repeat_edge_pixels: bool = True) → PixelArrayApply a box blur effect to a pixel array.
Box blur creates a uniform blur effect by averaging pixels within a square kernel. It's faster than Gaussian blur but produces a more uniform, less natural look.
Parameters
pixel_array: The pixel array to blur.radius: The blur radius in pixels. Larger values create stronger blur.repeat_edge_pixels: Whether to repeat edge pixels when sampling outside the pixel array bounds. Defaults to True.
Returns
PixelArray : A new pixel array with the box blur effect applied.
Gaussian Blur
gaussian_blur(pixel_array: PixelArray, radius: int, repeat_edge_pixels: bool = True) → PixelArrayApply a Gaussian blur effect to a pixel array.
Gaussian blur creates a natural, smooth blur effect using a Gaussian distribution for pixel weighting. It produces higher quality results than box blur but is computationally more expensive.
Parameters
pixel_array: The pixel array to blur.radius: The blur radius in pixels. Larger values create stronger blur.repeat_edge_pixels: Whether to repeat edge pixels when sampling outside the pixel array bounds. Defaults to True.
Returns
PixelArray : A new pixel array with the Gaussian blur effect applied.
Invert
invert(pixel_array: PixelArray) → PixelArrayInvert the colors of a pixel array. The alpha channel is preserved.
Parameters
pixel_array: The pixel array to invert.
Returns
PixelArray : A new pixel array with inverted colors.
Grayscale
grayscale(pixel_array: PixelArray) → PixelArrayConvert a pixel array to grayscale. The alpha channel is preserved.
Converts the pixel array to grayscale using the standard luminance formula:
gray = 0.299 * red + 0.587 * green + 0.114 * blue
Parameters
pixel_array: The pixel array to convert to grayscale.
Returns
PixelArray : A new grayscale pixel array.