Created
March 13, 2012 11:22
-
-
Save efedorenko/2028193 to your computer and use it in GitHub Desktop.
Function for alpha blending
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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