To achieve the color transformation from red to green and blue, I utilized the grayscale
filter and determined the appropriate hue-rotate
degree by referring to this resource.
Now, I am looking to create a mixin
in scss
where I can input a hex color code and calculate the hue-rotation degree before returning it. How can I implement this mixin effectively?
.colorRed,.colorBlue, .colorGreen {filter:grayscale(0);}
.colorRed img {filter:hue-rotate(0deg);}
.colorBlue img {filter:hue-rotate(215deg);}
.colorGreen img {filter:hue-rotate(100deg);}
<span class="original"><img src="https://i.imgur.com/ZbOHifU.png" width="100px";></span>
<span class="colorGreen"><img src="https://i.imgur.com/ZbOHifU.png" width="100px";></span>
<span class="colorBlue"><img src="https://i.imgur.com/ZbOHifU.png" width="100px";></span>
<span class="colorRed"><img src="https://i.imgur.com/ZbOHifU.png" width="100px";></span>
p.s
I prefer not to use SVG solutions as indicated here
I also do not want to rely on JavaScript solutions for this task.