test() {
if [[ -z "${1}" ]]; then return 1; fi
hex=$(echo "${1^^}" | sed 's/#//g')
a=$(echo $hex | cut -c-2)
b=$(echo $hex | cut -c3-4)
c=$(echo $hex | cut -c5-6)
r=$(echo "ibase=16; $a" | bc)
g=$(echo "ibase=16; $b" | bc)
b=$(echo "ibase=16; $c" | bc)
python - <<START
import colorsys
h, l, s = colorsys.rgb_to_hls(${r}/255, ${g}/255, ${b}/255)
print (int(round(h*360)), int(round(l*100)), int(round(s*100)))
r, g, b = colorsys.hls_to_rgb(h, l, s)
print (round(r*255), round(g*255), round(b*255))
START
}
test "#91379d" |