Effects

pygamecv.effect.darken(surface: Surface, factor: float | ndarray)

Darken the colors of a pygame.Surface by a darkening factor.

Params:

  • surface: pygame.Surface, the surface to modify.

  • factor: float | numpy.ndarray, the factor to use to darken the surface.

if factor is a float, all the surface is darkened by the same factor. if factor is a numpy.ndarray, it must have the same shape as the surface. In this case, each pixel will be darkened according to the factor.

Raises:

  • ValueError(“This factor has the wrong shape.”) if the factor is a numpy.ndarray with a different shape than the surface.

pygamecv.effect.desaturate(surface: Surface, factor: float | ndarray)

Desaturate the colors of a pygame.Surface by a desaturation factor.

Params:

  • surface: pygame.Surface, the surface to modify.

  • factor: float | numpy.ndarray, the factor to use to desaturate the surface.

if factor is a float, all the surface is desaturated by the same factor. if factor is a numpy.ndarray, it must have the same shape as the surface. In this case, each pixel will be desaturated according to the factor.

Raises:

  • ValueError(“This factor has the wrong shape.”) if the factor is a numpy.ndarray with a different shape than the surface.

pygamecv.effect.lighten(surface: Surface, factor: float | ndarray)

Lighten the colors of a pygame.Surface by a lightening factor.

Params:

  • surface: pygame.Surface, the surface to modify.

  • factor: float | numpy.ndarray, the factor to use to lighten the surface.

if factor is a float, all the surface is lightened by the same factor. if factor is a numpy.ndarray, it must have the same shape as the surface. In this case, each pixel will be lightened according to the factor.

Raises:

  • ValueError(“This factor has the wrong shape.”) if the factor is a numpy.ndarray with a different shape than the surface.

pygamecv.effect.saturate(surface: Surface, factor: float | ndarray)

Saturate the colors of a pygame.Surface by a saturation factor.

Params:

  • surface: pygame.Surface, the surface to modify.

  • factor: float | numpy.ndarray, the factor to use to saturate the surface.

if factor is a float, all the surface is saturated by the same factor. if factor is a numpy.ndarray, it must have the same shape as the surface. In this case, each pixel will be saturated according to the factor.

Raises:

  • ValueError(“This factor has the wrong shape.”) if the factor is a numpy.ndarray with a different shape than the surface.

pygamecv.effect.set_hue(surface: Surface, value: int | ndarray, mask: ndarray | None = None)

Set the hue of the color of each pixel to a new value.

Params:

  • surface: pygame.Surface, the surface to modify.

  • value: int | numpy.ndarray, the value used to set the surface’s colors hue.

if value is a float, all the surface is set to the same value. if value is a numpy.ndarray, it must have the same shape as the surface. In this case, each pixel’s hue will be set according to the value. Hues are integers between 0° and 180° - mask: numpy.ndarray of bool | None = None. If specified, only the pixels in the mask will be changed.

Raises:

  • ValueError(“This factor has the wrong shape.”) if the factor is a numpy.ndarray with a different shape than the surface.

  • ValueError(“This mask has the wrong shape”) if the mask is a numpy.ndarray with a different shape than the surface.

pygamecv.effect.set_luminosity(surface: Surface, value: float | ndarray, mask: ndarray | None = None)

Set the luminosity of the color of each pixel to a new value.

Params:

  • surface: pygame.Surface, the surface to modify.

  • value: int | numpy.ndarray, the value used to set the surface’s colors luminosity.

if value is a float, all the surface is set to the same value. if value is a numpy.ndarray, it must have the same shape as the surface. In this case, each pixel’s luminosity will be set according to the value. Luminosities are integers between 0 and 255. - mask: numpy.ndarray of bool | None = None. If specified, only the pixels in the mask will be changed.

Raises:

  • ValueError(“This factor has the wrong shape.”) if the factor is a numpy.ndarray with a different shape than the surface.

  • ValueError(“This mask has the wrong shape”) if the mask is a numpy.ndarray with a different shape than the surface

pygamecv.effect.set_saturation(surface: Surface, value: float | ndarray, mask: ndarray | None = None)

Set the saturation of the color of each pixel to a new value.

Params:

  • surface: pygame.Surface, the surface to modify.

  • value: int | numpy.ndarray, the value used to set the surface’s colors saturation.

if value is a float, all the surface is set to the same value. if value is a numpy.ndarray, it must have the same shape as the surface. In this case, each pixel’s saturation will be set according to the value. Saturations are integers between 0 and 255. - mask: numpy.ndarray of bool | None = None. If specified, only the pixels in the mask will be changed.

Raises:

  • ValueError(“This factor has the wrong shape.”) if the factor is a numpy.ndarray with a different shape than the surface.

  • ValueError(“This mask has the wrong shape”) if the mask is a numpy.ndarray with a different shape than the surface

pygamecv.effect.shift_hue(surface: Surface, value: int | ndarray)

Shift the hue of the colors of a pygame.Surface by a value.

Params:

  • surface: pygame.Surface, the surface to modify.

  • value: int | numpy.ndarray, the value used to shift the surface.

if value is a float, all the surface is shifted by the same value. if value is a numpy.ndarray, it must have the same shape as the surface. In this case, each pixel will be shifted according to the value. Hues are integers between 0° and 180°