imgdye
Version:
Tint PNG images using JavaScript.
2 lines (1 loc) • 406 B
JavaScript
function imgdye(e,t,o){if(null==t)throw new Error("Expecting second argument to be a color.");var l=document.createElement("canvas");l.width=e.width,l.height=e.height;var a=l.getContext("2d");return a.fillStyle=t,null!=o&&(a.globalAlpha=o),a.fillRect(0,0,l.width,l.height),a.globalCompositeOperation="destination-atop",a.globalAlpha=1,a.drawImage(e,0,0),l}"object"==typeof module&&(module.exports=imgdye);