fix: leftPad to hex
This commit is contained in:
parent
c158671e70
commit
418be1ed63
1 changed files with 6 additions and 3 deletions
|
|
@ -1,8 +1,11 @@
|
||||||
{inputs, ...}: let
|
{inputs, ...}: let
|
||||||
inherit (inputs.nixpkgs.lib) toHexString concatStrings;
|
inherit (inputs.nixpkgs.lib) toHexString concatStrings strings;
|
||||||
|
inherit (strings) fixedWidthString;
|
||||||
|
|
||||||
|
padHex = n: fixedWidthString 2 "0" (toHexString n);
|
||||||
in {
|
in {
|
||||||
toHex = color: concatStrings ["#" (toHexString color.red) (toHexString color.green) (toHexString color.blue)];
|
toHex = color: concatStrings ["#" (padHex color.red) (padHex color.green) (padHex color.blue)];
|
||||||
toHexNoHash = color: concatStrings [(toHexString color.red) (toHexString color.green) (toHexString color.blue)];
|
toHexNoHash = color: concatStrings [(padHex color.red) (padHex color.green) (padHex color.blue)];
|
||||||
toRGB = color: concatStrings ["rgb(" (toString color.red) "," (toString color.green) "," (toString color.blue) ")"];
|
toRGB = color: concatStrings ["rgb(" (toString color.red) "," (toString color.green) "," (toString color.blue) ")"];
|
||||||
toRGBA = color: a: concatStrings ["rgba(" (toString color.red) "," (toString color.green) "," (toString color.blue) "," (toString a) ")"];
|
toRGBA = color: a: concatStrings ["rgba(" (toString color.red) "," (toString color.green) "," (toString color.blue) "," (toString a) ")"];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue