Created
November 14, 2014 09:45
-
-
Save beshur/40b2bdae8ee17e994bf2 to your computer and use it in GitHub Desktop.
Sass: HSB to HSL converter
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
// Simple HSB to HSL converter by Alexander Futekov (@futekov) | |
// http://www.sitepoint.com/hsb-colors-with-sass/ | |
// | |
@function hsb($h-hsb, $s-hsb, $b-hsb, $a: 1) { | |
@if $b-hsb == 0 { | |
@return hsla(0, 0, 0, $a) | |
} @else { | |
$l-hsl: ($b-hsb/2) * (2 - ($s-hsb/100)); | |
$s-hsl: ($b-hsb * $s-hsb) / if($l-hsl < 50, $l-hsl * 2, 200 - $l-hsl * 2); | |
@return hsla($h-hsb, $s-hsl, $l-hsl, $a); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment