Add palette report
This commit is contained in:
parent
5ccce02366
commit
506dd3687a
1 changed files with 7 additions and 3 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
let
|
||||
inherit (builtins) listToAttrs mapAttrs;
|
||||
inherit (lib) imap0 mapAttrsRecursive nameValuePair;
|
||||
inherit (import ./lib.nix { inherit lib; }) oklchToRgb rgbToHex;
|
||||
inherit (lib) concatLines imap0 mapAttrsRecursive mapAttrsToList nameValuePair;
|
||||
inherit (import ./lib.nix { inherit lib; }) oklchToRgb rgbToHex round;
|
||||
|
||||
ansiNames = [ "black" "red" "green" "yellow" "blue" "magenta" "cyan" "white" ];
|
||||
|
||||
|
@ -47,11 +47,15 @@ rec {
|
|||
base = listToAttrs (imap0 (i: n: nameValuePair n (toString (30 + i))) ansiNames);
|
||||
effect = p: mapAttrs (_: a: "${p};${a}") base;
|
||||
in
|
||||
base // { bold = effect "1"; dim = effect "2" // { italic = effect "2;3"; }; italic = effect "3"; };
|
||||
base
|
||||
// { bold = effect "1"; dim = effect "2" // { italic = effect "2;3"; }; italic = effect "3"; }
|
||||
// { true = mapAttrs (_: c: with mapAttrs (_: v: toString (round (v * 255))) c; "38;2;${r};${g};${b}") rgb; };
|
||||
|
||||
ansiFormat = mapAttrsRecursive (_: a: t: "[${a}m${t}[0m") ansi;
|
||||
|
||||
hex = mapAttrs (_: rgbToHex) rgb;
|
||||
|
||||
report = concatLines (mapAttrsToList (n: f: f "██ ${n}") ansiFormat.true);
|
||||
|
||||
rgb = mapAttrs (_: oklchToRgb) oklch;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue