Transform

Functions for transforming pixel arrays.


Flip

flip(pixel_array: PixelArray, flip_x: bool, flip_y: bool) PixelArray

Flip 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) PixelArray

Scale 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) PixelArray

Scale 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) PixelArray

Rotate 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) PixelArray

Parameters

  • pixel_array : The pixel array to blur.
  • radius : The radius of the blur.
  • repeat_edge_pixels : Whether to repeat edge pixels when blurring.

Returns

PixelArray : The blurred pixel array.

Gaussian Blur

gaussian_blur(pixel_array: PixelArray, radius: int, repeat_edge_pixels: bool = True) PixelArray

Parameters

  • pixel_array : The pixel array to blur.
  • radius : The radius of the blur.
  • repeat_edge_pixels : Whether to repeat edge pixels when blurring.

Returns

PixelArray : The blurred pixel array.

Invert

invert(pixel_array: PixelArray) PixelArray

Invert the colors of a pixel array.

Parameters

  • pixel_array : The pixel array to invert.

Returns

PixelArray : The color-inverted pixel array.

Grayscale

grayscale(pixel_array: PixelArray) PixelArray

Convert a pixel array to luma grayscale.

Parameters

  • pixel_array : The pixel array to convert to grayscale.

Returns PixelArray : The grayscale pixel array.