Color

class pyto_ui.Color(py_color)

A Color object represents a color to be displayed on screen.

Example:

import pyto_ui as ui

# RGB
black = ui.Color.rgb(0, 0, 0, 1)

# White
white = ui.Color.white(1, 1)

# Dynamic
background = ui.Color.dynamic(light=white, dark=black)

For pre-defined colors, see SystemColors.

alpha() → float

Returns the alpha value of the color.

Return type:

float

blue() → float

Returns the blue value of the color.

Return type:

float

classmethod dynamic(light: Color, dark: Color) → Color

Initializes and returns a color that dynamically changes in dark or light mode.

Parameters:
  • light – Color object to be displayed in light mode.

  • dark – Color object to be displayed in dark mode.

Return type:

pyto_ui.Color

green() → float

Returns the green value of the color.

Return type:

float

red() → float

Returns the red value of the color.

Return type:

float

classmethod rgb(red: float, green: float, blue, alpha: float = 1) → Color

Initializes a color from RGB values.

All values should be located between 0 and 1, not between 0 and 255.

Parameters:
  • red – The red value.

  • green – The geen value.

  • blue – The blue value.

  • alpha – The opacity value.

Return type:

pyto_ui.Color

classmethod white(white: float, alpha: float) → Color

Initializes and returns a color from white value.

All values should be located between 0 and 1, not between 0 and 255.

Parameters:
  • white – The grayscale value.

  • alpha – The opacity value.

Return type:

pyto_ui.Color