Convert palette to OKLCH

This commit is contained in:
Andrew Kvalheim 2024-04-22 22:01:05 -07:00
parent a9f123991d
commit 4743612db0
3 changed files with 33 additions and 34 deletions

View file

@ -46,7 +46,6 @@ sudo nix-channel --add 'https://github.com/NixOS/nixos-hardware/archive/master.t
# User # User
nix-channel --add "https://github.com/nix-community/home-manager/archive/release-$RELEASE.tar.gz" 'home-manager' nix-channel --add "https://github.com/nix-community/home-manager/archive/release-$RELEASE.tar.gz" 'home-manager'
nix-channel --add 'https://github.com/misterio77/nix-colors/archive/main.tar.gz' 'nix-colors'
nix-channel --add 'https://github.com/xddxdd/nix-math/archive/master.tar.gz' 'nix-math' nix-channel --add 'https://github.com/xddxdd/nix-math/archive/master.tar.gz' 'nix-math'
nix-channel --add 'https://nixos.org/channels/nixos-unstable' 'unstable' nix-channel --add 'https://nixos.org/channels/nixos-unstable' 'unstable'
nix-channel --add 'https://github.com/nix-community/nix-vscode-extensions/archive/master.tar.gz' 'community-vscode-extensions' nix-channel --add 'https://github.com/nix-community/nix-vscode-extensions/archive/master.tar.gz' 'community-vscode-extensions'

View file

@ -34,7 +34,7 @@ in
dconf.settings."org/gnome/desktop/background".picture-uri-dark = host.background; dconf.settings."org/gnome/desktop/background".picture-uri-dark = host.background;
dconf.settings."org/gnome/desktop/screensaver".picture-uri = host.background; dconf.settings."org/gnome/desktop/screensaver".picture-uri = host.background;
dconf.settings."org/gtk/settings/color-chooser".custom-colors = with palette.rgb; dconf.settings."org/gtk/settings/color-chooser".custom-colors = with palette.rgb;
map (rgb: mkTuple (rgb ++ [ 1.0 ])) map ({ r, g, b }: mkTuple [ r g b 1.0 ])
[ red green yellow blue orange purple ]; [ red green yellow blue orange purple ];
# Shell # Shell

View file

@ -1,49 +1,47 @@
{ lib }: { lib }:
let let
inherit (builtins) listToAttrs mapAttrs substring; inherit (builtins) listToAttrs mapAttrs;
inherit (lib) imap0 mapAttrsRecursive nameValuePair; inherit (lib) imap0 mapAttrsRecursive nameValuePair;
inherit ((import <nix-colors> { }).lib.conversions) hexToRGB; inherit (import ./lib.nix { inherit lib; }) oklchToRgb rgbToHex;
ansiNames = [ "black" "red" "green" "yellow" "blue" "magenta" "cyan" "white" ]; ansiNames = [ "black" "red" "green" "yellow" "blue" "magenta" "cyan" "white" ];
hex = { oklch = rec {
# Monokai # Monokai
black = "#1b1b1b"; black = { l = 0.22; c = 0.000; h = 0; };
blue = "#66d9ef"; blue = { l = 0.83; c = 0.108; h = 212; };
gray = "#666666"; gray = { l = 0.51; c = 0.000; h = 0; };
green = "#a6e22e"; green = { l = 0.84; c = 0.204; h = 127; };
orange = "#fd971f"; orange = { l = 0.77; c = 0.168; h = 62; };
purple = "#ae81ff"; purple = { l = 0.70; c = 0.181; h = 298; };
red = "#f92672"; red = { l = 0.64; c = 0.240; h = 7; };
white = "#f8f8f8"; white = { l = 0.98; c = 0.000; h = 0; };
yellow = "#e6db74"; yellow = { l = 0.88; c = 0.125; h = 103; };
# Extended # Extended
orange-red = "#fc5b2d"; orange-red = { l = 0.68; c = 0.205; h = 36; };
teal = "#29e0b4"; teal = { l = 0.81; c = 0.152; h = 171; };
# Derived # Derived
alt-blue = "#5ac1d5"; alt-blue = blue // { l = 0.76; };
alt-green = "#93c928"; alt-green = green // { l = 0.77; c = 0.198; };
alt-orange = "#e1851a"; alt-orange = orange // { l = 0.70; c = 0.161; };
alt-orange-red = "#dd4915"; alt-orange-red = orange-red // { l = 0.61; };
alt-purple = "#9f60ff"; alt-purple = purple // { l = 0.64; };
alt-red = "#d71b60"; alt-red = red // { l = 0.57; c = 0.217; };
alt-teal = "#23c7a0"; alt-teal = teal // { l = 0.74; c = 0.144; };
alt-yellow = "#cdc367"; alt-yellow = yellow // { l = 0.81; };
dark-gray = "#3a3a3a"; dark-gray = gray // { l = 0.35; };
dark-orange-red = "#522c21"; dark-orange-red = orange-red // { l = 0.34; c = 0.060; };
dark-orange-red-text-contrast = "#917a74"; dark-orange-red-text-contrast = orange-red // { l = 0.60; c = 0.030; };
dark-purple = "#634994"; dark-purple = purple // { l = 0.47; };
dark-red = "#c4265e"; dark-red = red // { l = 0.54; c = 0.216; };
dark-teal = "#134739"; dark-teal = teal // { l = 0.36; c = 0.060; };
light-gray = "#dddddd"; light-gray = gray // { l = 0.90; };
}; };
in in
rec { rec {
inherit hex;
ansi = ansi =
let let
base = listToAttrs (imap0 (i: n: nameValuePair n (toString (30 + i))) ansiNames); base = listToAttrs (imap0 (i: n: nameValuePair n (toString (30 + i))) ansiNames);
@ -53,5 +51,7 @@ rec {
ansiFormat = mapAttrsRecursive (_: a: t: "[${a}m${t}") ansi; ansiFormat = mapAttrsRecursive (_: a: t: "[${a}m${t}") ansi;
rgb = mapAttrs (_: h: map (c: c / 255.0) (hexToRGB (substring 1 6 h))) hex; hex = mapAttrs (_: rgbToHex) rgb;
rgb = mapAttrs (_: oklchToRgb) oklch;
} }