From be6bc729f6e105d8c2674244eb3a322e6f80c4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Fri, 29 Jun 2018 00:48:38 +0200 Subject: [PATCH] Doubled resolution of ANSI-art screenshots, by using FG and BG colours. The drawback is that there are less color choices for the background color. --- ansi-screenshots/to_ansi.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ansi-screenshots/to_ansi.sh b/ansi-screenshots/to_ansi.sh index 966ac88..e698e36 100755 --- a/ansi-screenshots/to_ansi.sh +++ b/ansi-screenshots/to_ansi.sh @@ -7,6 +7,10 @@ mini_png="$(tempfile --suffix=".png")" colors_gif="$(tempfile --suffix=".gif")" indexed_gif="$(tempfile --suffix=".gif")" indexed_pgm="$(tempfile --suffix=".pgm")" +odd_lines="$(tempfile --suffix=".odd")" +even_lines="$(tempfile --suffix=".even")" +odd_lines_px="$(tempfile --suffix=".odd.px")" +even_lines_px="$(tempfile --suffix=".even.px")" colors=(78,78,78 255,108,96 0,170,0 288,288,182 150,203,254 255,115,253 85,255,255 238,238,238 124,124,124 255,155,147 177,253,121 255,255,145 181,220,254 255,156,254 85,255,255 255,255,255) args=() @@ -25,8 +29,15 @@ done && convert "${indexed_gif}" "${indexed_pgm}" \ && tail -n +4 "${indexed_pgm}" \ | hexdump -Cv \ - | sed -n -r -e 's/^[0-9a-f]* (([0-9a-f]{2} ){8}) (([0-9a-f]{2} ){7}[0-9a-f]{2}).*$/\1\3/p' \ + | sed -n -r -e 's/^[0-9a-f]* (([0-9a-f]{2} ?){1,16}).*$/\1/p' \ | tr '\n' ' ' \ + | sed -r -e 's/ +/ /g' \ | fold -w $((width*3)) \ - | sed -r -e 's/([01])([0-7]) /[\1;3\2m█/g' \ + | awk "{ if (NR % 2 == 0) print > \"$even_lines\"; else print > \"$odd_lines\"; }" +cat "$odd_lines" | sed -e 's/ $//' | tr ' ' '\n' > "$odd_lines_px" +cat "$even_lines" | sed -e 's/ $//' | tr ' ' '\n' > "$even_lines_px" +paste "$odd_lines_px" "$even_lines_px" \ + | tr '\t\n' ' ' \ + | fold -w $((width*6)) \ + | sed -r -e 's/([01])([0-7]) ([01])([0-7]) /[\1;3\2;4\4m▀/g' -e 's/$//' \ | if test "$CI" = "true" -a "$TRAVIS" = "true"; then while read ab; do echo "$ab"; sleep 0.05; done; else cat; echo; fi