Search code examples
html5-canvascmykkonvajs

CMYK color support - HTML5 Canvas


I have a requirement to work with CMYK. Any recommendations for how we could pass fill color CMYK instead of RGB or HEX. I use the Konvajs library.

Example


Solution

  • HTML and therefore I assume (happy to be corrected) CSS and HTML5 canvas do not support CMYK. Certainly, it is unlikely to be supported cross-browser in any meaningful way natively. W3Schools provide some kind of JS based conversion library approach and there are undoubtedly others and the logic to do the conversion both ways is out there, for example here.

    So you could achieve something with JS where you get the RGB equivalent and use that in the fill.

    However, CMYK colors when converted to RGB do not tend to give like-for-like visual effect and if you are trying to do any kind of web-to-print you need to give careful consideration to how you intervene in the interpretation of CMYK to RGB so that your users accept what they see as the color they want.