Convert RGBA to HEX

Since alpha value both attenuates the background color and the color value, something like this could do the trick: function rgba2rgb(RGB_background, RGBA_color) { var alpha = RGBA_color.a; return new Color( (1 – alpha) * RGB_background.r + alpha * RGBA_color.r, (1 – alpha) * RGB_background.g + alpha * RGBA_color.g, (1 – alpha) * RGB_background.b + alpha … Read more

Convert 8-digit hex colors to rgba colors?

I have made a quick JSfiddle form that allows you to convert from 8-digit hex code into CSS rgba values 😉 https://jsfiddle.net/teddyrised/g02s07n4/embedded/result/ The basis is rather simple — to split the string you have provided into parts of 2-digits, and perform conversion into percentage ratios for the alpha channel, and to decimals for the RGB … Read more

How can I stop the alpha-premultiplication with canvas imageData?

Bleh, this is an acknowledged issue as far as the canvas spec is concerned. It notes: Due to the lossy nature of converting to and from premultiplied alpha color values, pixels that have just been set using putImageData() might be returned to an equivalent getImageData() as different values. So this: var can = document.createElement(‘canvas’); var … Read more