porescene.color package

Subpackages

Submodules

Module contents

class porescene.color.Color(h='#000')[source]

Bases: object

Simple representation of a color.

Parameters:

hexstr – HEX color string

Examples

Suppose you have two :class:Color instances, just mix them by literal addition operation +:

Example:
>>> blue = Color('#00f')
>>> red = Color('#f00')
>>> purple = red + blue
>>> print(purple)

Be aware that all properties of the color, which includes alpha, will be mixed.

classmethod from_nrgb(nr, ng, nb, a=1.0)[source]
Return type:

Self

classmethod from_rgb(r, g, b, a=1.0)[source]
Return type:

Self

mix(other, ratio=0.5)[source]

Create a new color by mixing the current instance with others.

Parameters:
  • other (Self) – The color to mix with.

  • ratio (float) – The amount of color other to mix to the current instance.

  • space – The colorspace to use for mixing the colors. Mixing in RGB space is subtractive, while Lab is additive. Lab mixes more accurate but still does not reach real color mixing results.

Return type:

Color

property alpha: float

Normalized value from interval [0, 1] of the transparent (A) color channel.

property blue: float

Normalized value from interval [0, 1] of the blue (B) color channel.

property green: float

Normalized value from interval [0, 1] of the green (G) color channel.

property hex: str

HEX str without hash.

property hexa: str

HEXA str without hash.

property lnrgb: tuple[float, float, float]

Returns current color in normalized values fom linear RGB color space.

property lnrgb_str: str
property lnrgba: tuple[float, float, float, float]
property lnrgba_str: str
property nrgb: tuple[float, float, float]

Returns current color in normlized values (interval [0, 1]) from sRGB color space.

property nrgba: tuple[float, float, float, float]

Returns current color in normlized values (interval [0, 1]) from sRGBA color space.

property red: float

Normalized value from interval [0, 1] of the red (R) color channel.

property rgb: tuple[int, int, int]

Returns current color in values (interval [0, 255]) from sRGB color space.

property rgba: tuple[int, int, int, float]
property str_hex: str

HEX str with hash.

property str_hexa: str

HEXA str with hash.

property str_rgb: str

Current color formatted as rgb(R, G, B).

property str_rgba: str

Current color formatted as rgb(R, G, B, A).