bahaghari/lib: update color.hsl

This commit is contained in:
Gabriel Arazas 2024-06-15 19:54:28 +08:00
parent ff0ddb0e27
commit f7a9452ee5
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360

View File

@ -71,14 +71,14 @@ in rec {
toRgb = { h, s, l, ... }@color:
let
inherit (self.colors.rgb) RGB valueMax;
inherit (self.math) abs sub mod';
inherit (self.math) abs sub remainder round;
l' = l / valueParamMax;
s' = s / valueParamMax;
# This may as well turn into Scheme code.
C = (1 - (abs ((2 * l') - 1))) * s';
X = C * (1 - (abs (sub (mod' (h / 60.0) 2) 1)));
X = C * (1 - (abs (sub (remainder (h / 60.0) 2) 1)));
m = l' - (C / 2);
isHueWithin = min: max:
@ -98,7 +98,7 @@ in rec {
{ r = C; g = 0; b = X; }
else throw "WHAT IN THE HELL";
scaleValue = x: self.math.round ((x + m) * valueMax);
scaleValue = x: round ((x + m) * valueMax);
in
RGB {
r = scaleValue rgb'.r;