Convert a colour between HEX, HSL and CMYK.
Lightness is the average of the highest and lowest RGB channel, hue is derived from which channel is highest and by how much, and saturation is based on the spread between the highest and lowest channel relative to lightness.
K (black) = 1 − max(R, G, B). C, M and Y are each 1 − that channel − K, divided by 1 − K — giving the ink percentages a printer would use to reproduce the colour.
CMYK is the colour model used for print (ink mixing), while RGB and HEX are for screens (light mixing). Use CMYK values when preparing artwork for a printer.