Skip to content

Instantly share code, notes, and snippets.

@beshur
Created November 14, 2014 09:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beshur/40b2bdae8ee17e994bf2 to your computer and use it in GitHub Desktop.
Save beshur/40b2bdae8ee17e994bf2 to your computer and use it in GitHub Desktop.
Sass: HSB to HSL converter
// 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