color#

Colors and utility functions for conversion between different color models.

Classes

Colors

A list of pre-defined colors.

Functions

average_color(*colors)[source]#
Parameters

colors (Color) –

Return type

Color

color_gradient(reference_colors, length_of_output)[source]#
Parameters
  • reference_colors (Iterable[Color]) –

  • length_of_output (int) –

Return type

list[Color]

color_to_int_rgb(color)[source]#
Parameters

color (Color) –

Return type

ndarray

color_to_int_rgba(color, opacity=1.0)[source]#
Parameters
  • color (Color) –

  • opacity (float) –

Return type

ndarray

color_to_rgb(color)[source]#
Parameters

color (Color | str) –

Return type

np.ndarray

color_to_rgba(color, alpha=1)[source]#
Parameters
  • color (Color | str) –

  • alpha (float) –

Return type

np.ndarray

get_shaded_rgb(rgb, point, unit_normal_vect, light_source)[source]#
Parameters
  • rgb (ndarray) –

  • point (ndarray) –

  • unit_normal_vect (ndarray) –

  • light_source (ndarray) –

Return type

ndarray

hex_to_rgb(hex_code)[source]#
Parameters

hex_code (str) –

Return type

ndarray

interpolate_color(color1, color2, alpha)[source]#
Parameters
  • color1 (Color) –

  • color2 (Color) –

  • alpha (float) –

Return type

Color

invert_color(color)[source]#
Parameters

color (Color) –

Return type

Color

print_constant_definitions()[source]#

A simple function used to generate the constant values below. To run it paste this function and the Colors class into a file and run them.

random_bright_color()[source]#
Return type

Color

random_color()[source]#
Return type

Color

rgb_to_color(rgb)[source]#
Parameters

rgb (Iterable[float]) –

Return type

Color

rgb_to_hex(rgb)[source]#
Parameters

rgb (Iterable[float]) –

Return type

str

rgba_to_color(rgba)[source]#
Parameters

rgba (Iterable[float]) –

Return type

Color