fix: leftPad to hex

This commit is contained in:
KoenDR06 2025-12-24 18:08:58 +01:00
parent c158671e70
commit 418be1ed63

View file

@ -1,8 +1,11 @@
{inputs, ...}: let {inputs, ...}: let
inherit (inputs.nixpkgs.lib) toHexString concatStrings; inherit (inputs.nixpkgs.lib) toHexString concatStrings strings;
inherit (strings) fixedWidthString;
padHex = n: fixedWidthString 2 "0" (toHexString n);
in { in {
toHex = color: concatStrings ["#" (toHexString color.red) (toHexString color.green) (toHexString color.blue)]; toHex = color: concatStrings ["#" (padHex color.red) (padHex color.green) (padHex color.blue)];
toHexNoHash = color: concatStrings [(toHexString color.red) (toHexString color.green) (toHexString color.blue)]; toHexNoHash = color: concatStrings [(padHex color.red) (padHex color.green) (padHex color.blue)];
toRGB = color: concatStrings ["rgb(" (toString color.red) "," (toString color.green) "," (toString color.blue) ")"]; toRGB = color: concatStrings ["rgb(" (toString color.red) "," (toString color.green) "," (toString color.blue) ")"];
toRGBA = color: a: concatStrings ["rgba(" (toString color.red) "," (toString color.green) "," (toString color.blue) "," (toString a) ")"]; toRGBA = color: a: concatStrings ["rgba(" (toString color.red) "," (toString color.green) "," (toString color.blue) "," (toString a) ")"];
} }