Quantcast
Channel: User Marco A. - Stack Overflow
Viewing all articles
Browse latest Browse all 45

Answer by Marco A. for Convert RGBA to HEX

$
0
0

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)


Viewing all articles
Browse latest Browse all 45

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>