Skip to content

Commit

Permalink
[chore]: add rrggbbaa color formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
rxyhn committed Jan 6, 2024
1 parent e2b246c commit 2c0b341
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/colors/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ lib:
with lib; rec {
x = c: "#${c}";

rrggbbaa = mapAttrs (_: opacityHex: baseColor: "${x baseColor}${opacityHex}") opacityHexMap;

opacityHexMap = {
"100" = "FF";
"90" = "E6";
"80" = "CC";
"70" = "B3";
"60" = "99";
"50" = "80";
"40" = "66";
"30" = "4D";
"20" = "33";
"10" = "1A";
"0" = "00";
};

rgba = c: let
r = toString (hexToDec (__substring 0 2 c));
g = toString (hexToDec (__substring 2 2 c));
Expand Down

0 comments on commit 2c0b341

Please sign in to comment.