If I understand what you need, you basically want to turn certain colors into transparent images. For this you need to use getImageDatato find out how to manipulate mdn pixels .
Here is a sample code
var imgd = ctx.getImageData(0, 0, imageWidth, imageHeight),
pix = imgd.data;
for (var i = 0, n = pix.length; i <n; i += 4) {
var r = pix[i],
g = pix[i+1],
b = pix[i+2];
if(g > 150){
pix[i + 3] = 0;
}
}
ctx.putImageData(imgd, 0, 0);
And a working demo
With the code above you can check fuschia using
if(r == 255 && g == 0 && b == 255)
source
share