def _create_colours(light_colours=False) -> np.ndarray: saturation = 100 luminance = 60 if light_colours: saturation = 80 luminance = 80 colours = [] for hue in range(360): r, g, b = hpluv_to_rgb((hue, saturation, luminance)) colours.append(RGB(r * 256, g * 256, b * 256)) return np.array(colours)
def make_anglemap(N=256, use_hpl=True): h = np.ones(N) # hue h[:N // 2] = 11.6 # red h[N // 2:] = 258.6 # blue s = 100 # saturation l = np.linspace(0, 100, N // 2) # luminosity l = np.hstack((l, l[::-1])) colorlist = np.zeros((N, 3)) for ii in range(N): if use_hpl: colorlist[ii, :] = hsluv.hpluv_to_rgb((h[ii], s, l[ii])) else: colorlist[ii, :] = hsluv.hsluv_to_rgb((h[ii], s, l[ii])) colorlist[colorlist > 1] = 1 # correct numeric errors colorlist[colorlist < 0] = 0 return col.ListedColormap(colorlist)
import hsluv # from https://github.com/hsluv/hsluv-python import numpy as np npoints = 255 hsluv_data = [] hpluv_data = [] hues = np.linspace(0, 360, npoints, endpoint=False) for h in hues: hsluv_data.append(hsluv.hsluv_to_rgb([h, 100., 60.])) hpluv_data.append(hsluv.hpluv_to_rgb([h, 100., 60.])) hsluv_data = np.array(hsluv_data) hpluv_data = np.array(hpluv_data) np.savetxt('hsluv.txt', hsluv_data, fmt='%.15g') np.savetxt('hpluv.txt', hpluv_data, fmt='%.15g')