2024-02-22 06:34:18 +00:00
|
|
|
{ pkgs, lib }:
|
|
|
|
|
2024-02-23 12:37:06 +00:00
|
|
|
let
|
|
|
|
isBaseX = i: palette:
|
|
|
|
let
|
|
|
|
paletteNames = pkgs.lib.attrNames palette;
|
2024-02-24 13:37:53 +00:00
|
|
|
maxDigitLength = pkgs.lib.lists.length (pkgs.lib.toBaseDigits 10 i);
|
|
|
|
mkBaseAttr = hex: "base${lib.hex.pad maxDigitLength hex}";
|
|
|
|
schemeNames = builtins.map mkBaseAttr (lib.hex.range 0 (i - 1));
|
2024-02-23 12:37:06 +00:00
|
|
|
in
|
2024-02-25 10:20:13 +00:00
|
|
|
(pkgs.lib.count (name: pkgs.lib.elem name schemeNames) paletteNames) == i;
|
2024-02-23 12:37:06 +00:00
|
|
|
in
|
2024-02-22 06:34:18 +00:00
|
|
|
{
|
2024-02-23 06:47:49 +00:00
|
|
|
# TODO: Return a Nix object to generate a Tinted Theming color scheme from an
|
|
|
|
# image.
|
|
|
|
generateScheme = image: { };
|
|
|
|
|
2024-02-24 13:39:02 +00:00
|
|
|
/* A very naive implementation of checking whether the given palette is a
|
|
|
|
valid Base16 palette. It simply checks if `base00` to `base0F` is present.
|
|
|
|
|
|
|
|
Type: isBase16 :: Attrs -> Bool
|
|
|
|
|
|
|
|
Example:
|
|
|
|
isBase16 (bahaghariLib.importYAML ./base16.yml).palette
|
|
|
|
=> true
|
|
|
|
|
|
|
|
isBase16 (bahaghariLib.importYAML ./base16-scheme-with-missing-base0F.yml).palette
|
|
|
|
=> false
|
|
|
|
*/
|
2024-02-23 12:37:06 +00:00
|
|
|
isBase16 = isBaseX 16;
|
2024-02-22 06:34:18 +00:00
|
|
|
|
2024-02-24 13:39:02 +00:00
|
|
|
/* Similar to `isBase16` but for Base24 schemes. It considers the scheme as
|
|
|
|
valid if `base00` to `base17` from the palette are present.
|
|
|
|
|
|
|
|
Type: isBase24 :: Attrs -> Bool
|
|
|
|
|
|
|
|
Example:
|
|
|
|
isBase24 (bahaghariLib.importYAML ./base24.yml).palette
|
|
|
|
=> true
|
|
|
|
|
|
|
|
isBase24 (bahaghariLib.importYAML ./base24-scheme-with-missing-base0F.yml).palette
|
|
|
|
=> false
|
|
|
|
*/
|
2024-02-23 12:37:06 +00:00
|
|
|
isBase24 = isBaseX 24;
|
2024-02-22 06:34:18 +00:00
|
|
|
}
|