configuration/common/resources/palette.nix
2024-04-22 22:46:14 -07:00

57 lines
2 KiB
Nix
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ lib }:
let
inherit (builtins) listToAttrs mapAttrs;
inherit (lib) imap0 mapAttrsRecursive nameValuePair;
inherit (import ./lib.nix { inherit lib; }) oklchToRgb rgbToHex;
ansiNames = [ "black" "red" "green" "yellow" "blue" "magenta" "cyan" "white" ];
oklch = rec {
# Monokai
black = { l = 0.22; c = 0.000; h = 0; };
blue = { l = 0.83; c = 0.108; h = 212; };
gray = { l = 0.51; c = 0.000; h = 0; };
green = { l = 0.84; c = 0.204; h = 127; };
orange = { l = 0.77; c = 0.168; h = 62; };
purple = { l = 0.70; c = 0.181; h = 298; };
red = { l = 0.64; c = 0.240; h = 7; };
white = { l = 0.98; c = 0.000; h = 0; };
yellow = { l = 0.88; c = 0.125; h = 103; };
# Extended
orange-red = { l = 0.68; c = 0.205; h = 36; };
teal = { l = 0.81; c = 0.152; h = 171; };
# Derived
alt-blue = blue // { l = 0.76; };
alt-green = green // { l = 0.77; c = 0.198; };
alt-orange = orange // { l = 0.70; c = 0.161; };
alt-orange-red = orange-red // { l = 0.61; };
alt-purple = purple // { l = 0.64; };
alt-red = red // { l = 0.57; c = 0.217; };
alt-teal = teal // { l = 0.74; c = 0.144; };
alt-yellow = yellow // { l = 0.81; };
dark-gray = gray // { l = 0.35; };
dark-orange-red = orange-red // { l = 0.34; c = 0.060; };
dark-orange-red-text-contrast = orange-red // { l = 0.60; c = 0.030; };
dark-purple = purple // { l = 0.47; };
dark-red = red // { l = 0.54; c = 0.216; };
dark-teal = teal // { l = 0.36; c = 0.060; };
light-gray = gray // { l = 0.90; };
};
in
rec {
ansi =
let
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"; };
ansiFormat = mapAttrsRecursive (_: a: t: "[${a}m${t}") ansi;
hex = mapAttrs (_: rgbToHex) rgb;
rgb = mapAttrs (_: oklchToRgb) oklch;
}