Created
April 5, 2016 12:11
-
-
Save matori/b09d78969e9c8231c31373f88d23aa48 to your computer and use it in GitHub Desktop.
Convert colort to alpha
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
// http://paulownia.hatenablog.com/entry/20100420/1271769659 | |
@function alphafy($front, $back, $alpha) { | |
$r: round((red($front) - red($back) * (1 - $alpha)) / $alpha); | |
$g: round((green($front) - green($back) * (1 - $alpha)) / $alpha); | |
$b: round((blue($front) - blue($back) * (1 - $alpha)) / $alpha); | |
@if($r < 0) {$r: 0;} | |
@if($r > 255) {$r: 255} | |
@if($g < 0) {$g: 0;} | |
@if($g > 255) {$g: 255} | |
@if($b < 0) {$b: 0;} | |
@if($b > 255) {$b: 255} | |
@return rgba($r, $g, $b, $alpha); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment