Create HLS Color Object

Description

Creates a color object in the Hue-Lightness-Saturation (HLS) color space. Can be converted to: RGB, sRGB, HSV, and hexcols. Not allowed (ambiguous) are transformations to CIEXYZ, CIELUV, CIELAB, polarLUV, and polarLAB.

Usage

HLS(H, L, S, alpha=None)

Arguments

Hint, float, list, numpy.array
Numeric value(s) for Hue dimension.
Lint, float, list, numpy.array
Numeric value(s) for Lightness dimension.
Sint, float, list, numpy.array
Numeric value(s) for Saturation dimension.
alphaNone, float, list, numpy.array
Numeric value(s) for the alpha channel ([0., 1.]) where 0. equals full transparency, 1. full opacity. If None (default) no transparency is added.

Methods

HLS.colors(fixup=True, rev=False)
Extract Hex Colors
HLS.dropalpha()
Remove Alpha Channel
HLS.get(dimname=None)
Extracting Color Coordinates
HLS.get_whitepoint()
Get White Point
HLS.hasalpha()
Check for Alpha Channel
HLS.hclplot(**kwargs)
Palette Plot in HCL Space
HLS.length()
Get Number of Colors
HLS.set(**kwargs)
Set Coordinates/Manipulate Colors
HLS.set_whitepoint(**kwargs)
Set White Point
HLS.specplot(**kwargs)
Color Spectrum Plot
HLS.swatchplot(**kwargs)
Palette Swatch Plot
HLS.to(to, fixup=True)
Transform Color Space

Examples

from colorspace import HLS
# Constructing color object with one single color via float
HLS(150, 0.1, 3)
HLS color object (1 colors)
            H       L       S
  1:   150.00    0.10    3.00
# Constructing object via lists
HLS([150, 0, 10], [0.1, 0.7, 0.1], [3, 0, 3])
HLS color object (3 colors)
            H       L       S
  1:   150.00    0.10    3.00
         0.00    0.70    0.00
        10.00    0.10    3.00
# Constructing object via numpy arrays
from numpy import asarray
cols = HLS(asarray([150, 0, 10]),
           asarray([0.1, 0.7, 0.1]),
           asarray([3, 0, 3]))
cols
HLS color object (3 colors)
            H       L       S
  1:   150.00    0.10    3.00
         0.00    0.70    0.00
        10.00    0.10    3.00
# Converting to RGB
cols.to("RGB")
cols
RGB color object (3 colors)
            R       G       B
  1:    -0.20    0.40    0.10
         0.70    0.70    0.70
         0.40   -0.10   -0.20