Skip to content

Instantly share code, notes, and snippets.

@tqc
Created May 1, 2012 01:39
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tqc/2564280 to your computer and use it in GitHub Desktop.
Save tqc/2564280 to your computer and use it in GitHub Desktop.
Convert RGBA to RGB
function RGBAtoRGB(r, g, b, a, r2,g2,b2){
var r3 = Math.round(((1 - a) * r2) + (a * r))
var g3 = Math.round(((1 - a) * g2) + (a * g))
var b3 = Math.round(((1 - a) * b2) + (a * b))
return "rgb("+r3+","+g3+","+b3+")";
}
$("#result").html(RGBAtoRGB(225,110,0,0.5,255,255,255));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment