mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
Ran nixfmt.
This commit is contained in:
parent
4fddb23df3
commit
7e4b442fd9
14 changed files with 148 additions and 159 deletions
|
|
@ -1,19 +1,21 @@
|
|||
{ lib }:
|
||||
rec {
|
||||
hexChars = [ "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" ];
|
||||
hexCharToInt = char: let
|
||||
pairs = lib.imap0 (lib.flip lib.nameValuePair) hexChars;
|
||||
idx = builtins.listToAttrs pairs;
|
||||
in idx.${lib.toLower char};
|
||||
{ lib }: rec {
|
||||
hexChars =
|
||||
[ "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" ];
|
||||
hexCharToInt = char:
|
||||
let
|
||||
pairs = lib.imap0 (lib.flip lib.nameValuePair) hexChars;
|
||||
idx = builtins.listToAttrs pairs;
|
||||
in idx.${lib.toLower char};
|
||||
hexToInt = str:
|
||||
lib.foldl (value: chr: value * 16 + hexCharToInt chr) 0 (lib.stringToCharacters str);
|
||||
hextorgba = hex: (
|
||||
let r_hex = lib.substring 1 2 hex;
|
||||
g_hex = lib.substring 3 2 hex;
|
||||
b_hex = lib.substring 5 2 hex;
|
||||
r_dec = hexToInt r_hex;
|
||||
g_dec = hexToInt g_hex;
|
||||
b_dec = hexToInt b_hex;
|
||||
in "rgba(${toString r_dec}, ${toString g_dec}, ${toString b_dec}, 0.75)"
|
||||
);
|
||||
}
|
||||
lib.foldl (value: chr: value * 16 + hexCharToInt chr) 0
|
||||
(lib.stringToCharacters str);
|
||||
hextorgba = hex:
|
||||
(let
|
||||
r_hex = lib.substring 1 2 hex;
|
||||
g_hex = lib.substring 3 2 hex;
|
||||
b_hex = lib.substring 5 2 hex;
|
||||
r_dec = hexToInt r_hex;
|
||||
g_dec = hexToInt g_hex;
|
||||
b_dec = hexToInt b_hex;
|
||||
in "rgba(${toString r_dec}, ${toString g_dec}, ${toString b_dec}, 0.75)");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue