plotlp.color module

plotlp.color(auto=None, *, name: str = None, hex: str = None, wl: float = None, gray: int = None, rgb: tuple = None, RGB: tuple = None, alpha: float = 1.0)[source]

Gets a custom Color object.

Parameters:
  • auto (str or tuple or int or float) – Defines what is asked automatically.

  • name (str) – Name of color.

  • hex (str) – hexadecimal string.

  • wl (str) – wavelength [nm] float.

  • gray (str) – gray luminosity [0-255].

  • rgb (tuple) – rgb(a) tuple [0.-1.].

  • RGB (tuple) – RGB(A) tuple [0-255].

Returns:

instance – Color object instance.

Return type:

Color

Examples

>>> from plotlp import color
...
>>> color(name="blue") # from plt
>>> color(name="blueLP") # from custom
>>> color(hex="#2F7089") # from hexadecimals
>>> color(wl=480) # from wavelenght
>>> color(gray=180) # from grayscale
>>> color(rgb=(0, 0, 255)) # from RGB
...
>>> blued, greened = color(name="blueLP")
>>> desaturated = blued.desaturate(0.5) # 1=completely gray
>>> dark = blued.luminosity(-0.5) # <0 darker down to -1
>>> light = blued.luminosity(+0.5) # >0 lighter up to +1
>>> transparent = blued * 0.5 # color * alpha
>>> opaque = +blued
>>> invisible = -blued
>>> mixed = blued.mix(greened, 0.5) # 50/50 mixing blue/green
>>> complementary = ~blued # complementary color