@brybrant/sass-okhsv-okhsl
v1.0.1
Published
Sass functions to convert OkHSV and OkHSL to sRGB
Readme
OkHSV / OkHSL to RGB Sass Functions
Sass functions to convert OkHSV and OkHSL to sRGB.
Credit to Björn Ottosson
Install
$ npm i -D @brybrant/sass-okhsv-okhslSetup
@use 'pkg:@brybrant/sass-okhsv-okhsl' as convert;
$red: convert.okhsv_to_rgba(29deg, 100%, 100%); // rgb(255, 0, 4)
$blue: convert.okhsl_to_rgba(265, 100%, 0.37); // rgb(14, 3, 255)
$blue_hex: convert.color_to_hex($blue); // #0E03FFFunctions
okhsv_to_rgba( $hue, $saturation, $value, $alpha )
Converts OkHSV color space to sRGB color space.
$hueA
numberor ananglerepresenting the color'shueangle in OkHSV color space.
▪ Default:0deg$saturationA float (between 0 and 1) or
percentagerepresenting the color's saturation.1or100%is completely saturated, while0is completely unsaturated (gray).
▪ Default:1$valueA float (between 0 and 1) or
percentagerepresenting the color's brightness.1or100%is completely bright, while0is completely black.
▪ Default:1$alphaAn
alpha valuerepresenting the color's transparency.1or100%is completely opaque, while0is completely transparent.
▪ Default:1
Usage example
@debug okhsv_to_rgba(29deg, 1, 100%); // rgb(255, 0, 4)
@debug okhsv_to_rgba($hue: 170); // rgb(0, 255, 201)okhsl_to_rgba( $hue, $saturation, $lightness, $alpha )
Converts OkHSL color space to sRGB color space.
$hueA
numberor ananglerepresenting the color'shueangle in OkHSL color space.
▪ Default:0deg$saturationA float (between 0 and 1) or
percentagerepresenting the color's saturation.1or100%is completely saturated, while0is completely unsaturated (gray).
▪ Default:1$lightnessA float (between 0 and 1) or
percentagerepresenting the color's lightness.1or100%is white,0is black, and0.5or50%is "normal".
▪ Default:0.5$alphaAn
alpha valuerepresenting the color's transparency.1or100%is completely opaque, while0is completely transparent.
▪ Default:1
Usage example
@debug okhsl_to_rgba(265, 100%, 0.37); // rgb(14, 3, 255)
@debug okhsl_to_rgba($lightness: 40%); // rgb(172, 0, 89)color_to_hex( $color )
Converts any color to hexadecimal format.
Any valid CSS color (rgb, hsl, etc.)$color
Usage example
@debug color_to_hex(okhsv_to_rgba(143deg, 1, 1, 0.5)); // #00FF1F80
@debug color_to_hex(rgb(0 255 31 / 0.5)); // #00FF1F80