Skip to content

Instantly share code, notes, and snippets.

@efedorenko
Created March 13, 2012 11:22
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save efedorenko/2028193 to your computer and use it in GitHub Desktop.
Save efedorenko/2028193 to your computer and use it in GitHub Desktop.
Function for alpha blending
// Turns out this function already exists in Sass: mix(fg, bg, %) (http://d.pr/mGqa)
// Alpha blending
@function blend($bg, $fg) {
$r: red($fg) * alpha($fg) + red($bg) * (1 - alpha($fg));
$g: green($fg) * alpha($fg) + green($bg) * (1 - alpha($fg));
$b: blue($fg) * alpha($fg) + blue($bg) * (1 - alpha($fg));
@return rgb($r, $g, $b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment