My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Is it possible to use JavaScript to convert a batch of hex colour codes using a filter such as the feColorMatrix effect, into hex codes of colours that are desaturated/saturated accordingly?

Gustavo Benedito Costa's photo
Gustavo Benedito Costa
·Feb 9, 2019

I would like to convert a batch of hex colour codes into colours that are desaturated/saturated according to a filter such as a colour matrix. This visual effect can be achieved using SVG filters, but I hope to find a way to convert the actual hex codes using pure JS. Here is: codepen.io/anon/pen/aXEPvg, readapted by Sakal.

example.png

bitmap.png

References

  1. SVG Gradient Map
  2. How to transform black into any given colour using only CSS filters
  3. PineTools - Original colour to Grayscale