Skip to content

Instantly share code, notes, and snippets.

@MChorfa
Forked from efedorenko/gist:2028193
Created April 25, 2012 01:36
Show Gist options
  • Save MChorfa/2485287 to your computer and use it in GitHub Desktop.
Save MChorfa/2485287 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