Gradient maps, they’re not just for desktop anymore…
gradientmaps.js is a library I wrote that leverages SVG Filters to enable you to easily apply a Gradient Map to any DOM element.
I’ve been writing a few posts about the new gradientmaps.js library, and it occurred to me that gradient maps are a little hard to get your head around. How would you use them in a real-world scenario? From a pure creativity standpoint, they’re a no-brainer. But are there any practical use cases?
Here’s a thought. Say you’re selling shirts on your website. You’re able to print the shirts in a myriad of colors and want to let the consumer pick the color they want. In order to implement this, you could have an image for every possible color, or you could do the following (only works in Chrome & Firefox at present, sorry):
Check out this Pen!
In the above example, when you click on the color button and select a color, that new color is used as the right edge of a color gradient which starts with black. So, if you choose red, the color gradient will go from black to red. The image of the shirt you see has a transparent background. And, if you’ll notice if you look at the JS tab, the start of the gradient is actually transparent itself “rgba(0, 0, 0, 0)”. This is so we don’t recolor the background itself.
The resulting gradient is then applied to the image using:
gradientmaps.js makes use of SVG filters being applied to HTML content. At present that is only supported on Chrome and Firefox.
Pretty easy, and pretty useful. Play around with it and let me know what you think.
As you can read here, I’ve just open sourced gradientmaps.js, a library that allows you to apply Photoshop-like gradient maps to HTML content in Chrome and Firefox.
Now that the library is out there, let’s have a little fun. Continue reading
I’ve just released gradientmaps.js on Github. You can use this library to apply gradient maps to any HTML content using SVG filters. You can find all the details on the Adobe Web Platform team blog:
The library makes use of SVG filters. As indicated on this table of browser support for CSS graphics, applying SVG filters to HTML content is currently supported only on Chrome and Firefox at present.
Check it out, it’s a ton o’ fun.