galactic.algebras.lattice.examples.color.core

galactic.algebras.lattice.examples.color.core#

Defines a simple partially ordered set of colors.

Classes

  • Color which represents partially comparable colors


class Color(red=0.0, green=0.0, blue=0.0)#

Bases: Element

Represents colors in a partial order.

The relation \((r_a, g_a, b_a) \leq (r_b, g_b, b_b)\) is equivalent to \(r_a \leq r_b \wedge g_a \leq g_b \wedge b_a \leq b_b\).

Parameters:
Raises:

ValueError – If a color component is not between 0 and 1.

Examples

>>> from galactic.algebras.lattice.examples.color.core import Color
>>> red = Color(red=1)
>>> green = Color(green=1)
>>> blue = Color(blue=1)
>>> yellow = red | green
>>> yellow
Color(red=1, green=1)
>>> print(yellow)
(1.0, 1.0, 0.0)
property red: float#

Return the red component of the color.

Returns:

The red component.

Return type:

float

property green: float#

Return the green component of the color.

Returns:

The green component.

Return type:

float

property blue: float#

Return the blue component of the color.

Returns:

The blue component.

Return type:

float

__hash__()#

Return the hash of the color.

Returns:

The hash of the color

Return type:

int

hexadecimal()#

Return the color as an HTML hexadecimal string.

Returns:

The HTML hexadecimal color notation.

Return type:

str