Convert RGBA To HEX
Answer :
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 * RGBA_color.b
);
}
(Try it interactively: https://marcodiiga.github.io/rgba-to-rgb-conversion)
Comments
Post a Comment