-
Notifications
You must be signed in to change notification settings - Fork 2
Identify similar colours
This collection of one-line shell-scripts aims at ultimately replacing hooks/pre-commit
with something better.
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort | sed -e 's/^\(....\)\(..\)/\1 0x\2/' -e 's/^\(..\)\(..\)/\1 0x\2/' -e 's/^\(..\)/0x\1/'
printf '%d %d %d %s\n' $(grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort | sed -e 's/^\(....\)\(..\)/\1 0x\2/' -e 's/^\(..\)\(..\)/\1 0x\2/' -e 's/^\(..\)/0x\1/') | column -t
Notes:
-
$(wc -l outfile_xxx.txt)
may count a line too much (i.e. the concluding\n
aka "newline" character): Use$(($(wc -l outfile_xxx.txt)-1)
then. - If a PNG image is wanted, replace
> outimage_xxx.ppm
by either| pnmtopng > outimage_xxx.png
or| convert - outimage_xxx.png
or| ffmpeg -i - outimage_xxx.png
/> outimage_xxx.ppm; ffmpeg -i outimage_xxx.ppm outimage_xxx.png
.
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort | tee outfilee_rgb.txt | cut -f 1 -d ' ' | sed -e p -e p -e p -e p -e p -e p -e p | tr -d '\n' | xxd -r -ps | rawtoppm 8 $(wc -l outfile_rgb.txt) > outimage_rgb.ppm
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed -e 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' -e 's/^\(..\)\(..\)\(..\) /\2\1\3 /' | sort | tee outfile_grb.txt | cut -f 1 -d ' ' | sed -e p -e p -e p -e p -e p -e p -e p | tr -d '\n' | xxd -r -ps | rawtoppm -grb 8 $(wc -l outfile_grb.txt) > outimage_grb.ppm
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed -e 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' -e 's/^\(..\)\(..\)\(..\) /\3\2\1 /' | sort | tee outfile_bgr.txt | cut -f 1 -d ' ' | sed -e p -e p -e p -e p -e p -e p -e p | tr -d '\n' | xxd -r -ps | rawtoppm -bgr 8 $(wc -l outfile_bgr.txt) > outimage_bgr.ppm
Other RGB-permutations can be constructed accordingly.