schemes: cache schemes

This commit is contained in:
2 * r + 2 * t
2025-04-05 18:03:42 +11:00
parent f9c60a483d
commit bf6ddf7963
+14 -3
View File
@@ -8,10 +8,21 @@ test -f "$argv[1]" && set -l img (realpath "$argv[1]") || set -l img $C_STATE/wa
contains -- "$argv[2]" light dark && set -l theme $argv[2] || set -l theme dark
set -l variants vibrant tonalspot expressive fidelity fruitsalad rainbow neutral content monochrome
set -l hash (sha1sum $img | cut -d ' ' -f 1)
# Generate colours
set -l colours ($src/score.py $img)
# Cache schemes
mkdir -p $C_CACHE/schemes
if ! test -d $C_CACHE/schemes/$hash
# Generate colours
set -l colours ($src/score.py $img)
for variant in $variants
mkdir -p $C_CACHE/schemes/$hash/$variant
$src/autoadjust.py $theme $variant $colours | head -c -1 > $C_CACHE/schemes/$hash/$variant/$theme.txt
end
end
# Copy schemes from cache
for variant in $variants
mkdir -p $src/../data/schemes/dynamic/$variant
$src/autoadjust.py $theme $variant $colours | head -c -1 > $src/../data/schemes/dynamic/$variant/$theme.txt
cp $C_CACHE/schemes/$hash/$variant/$theme.txt $src/../data/schemes/dynamic/$variant/$theme.txt
end