Compute Maximum Chroma for Given Hue and Luminance in HCL

Description

Compute approximately the maximum chroma possible for a given hue and luminance combination in the HCL color space.

H and L can be single values or multiple values. If both have length > 1, the length must match. If one is of length 1 it will be recycled to match the length of the other argument. In case the function is not able to create two arrays of the same length an error will be thrown.

Usage

max_chroma(H, L, floor=False)

Arguments

Hint, float, list, numpy.ndarray
hue, one or multiple values (must be convertable to float).
Lint, float, list, numpy.ndarray
luminance, one or multiple values (must be convertable to float).
floorbool
should return be rounded? Defaults to False.

Return

numpy.ndarray: Array of the same length as max(len(H), len(L)) with maximum possible chroma for these hue-luminance combinations.

Examples

from colorspace import max_chroma
# Max Chroma for Hue = 0 (red) with Luminance = 50
max_chroma(0, 50)
array([137.96])
# Max Chroma for Hue = 0 (red) for different Luminance levels
max_chroma(0, [25, 50, 75])
array([ 69.51, 137.96,  64.37])
# Max Chroma for Hue in sequence [0, 360] by 60, Luminace = 50
import numpy as np
max_chroma(np.arange(0, 360, 60), 50)
array([137.96,  59.99,  69.06,  39.81,  65.45, 119.54])
# Same as above but floored
max_chroma(np.arange(0, 360, 60), 50, floor = True)
array([137.,  59.,  69.,  39.,  65., 119.])

Raises

  • TypeError: If unexpected input on H or L.
  • TypeError: If length of H and L do not match (see description).
  • TypeError: If input floor is not bool.