Colors

Color type and functions to produce colors.

class Color(red: int, green: int, blue: int, alpha: int)

Represents a color in the RGBA color space (using integers between 0 and 255).

rgb_color(red: int, green: int, blue: int) Color

Returns a fully-opaque color with the provided components for red, green and blue.

Parameters
  • red – red component (0 – 255)

  • green – green component (0 – 255)

  • blue – blue component (0 – 255)

Returns

a color with the provided RGB components

rgba_color(red: int, green: int, blue: int, alpha: int) Color

Returns a color with the provided components for red, green and blue and a certain degree of transparency controlled by alpha.

Parameters
  • red – red component (0 – 255)

  • green – green component (0 – 255)

  • blue – blue component (0 – 255)

  • alpha – alpha (transparency) component where 0 means fully transparent and 255 fully opaque

Returns

a color with the provided RGBA components

Names of notable colors because they are at the vertices of the RGB cube, plus the fully-transparent one.

black

Black color

blue

Blue color

cyan

Cyan color

green

Green color

magenta

Magenta color

red

Red color

transparent

Fully-transparent color

white

White color

yellow

Yellow color