nix-config/lib/catppuccin.nix

19 lines
1 KiB
Nix

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