I'm trying to animate the following ASCII art. (I have two files right now and may add more later for more fine grained animation.)
$ cat ~/aks1.txt
\ RTX /
\ /
\ WAZUH LAB /
] [ ,'|
] [ / |
]___ ___[ ,' |
] ]\ /[ [ |: |
] ] \ / [ [ |: |
] ] ] [ [ [ |: |
] ] ]__ __[ [ [ |: |
] ] ] ]\ _ /[ [ [ [ |: |
] ] ] ] (A) [ [ [ [ :===='
] ] ]_].nRn.[_[ [ [
] ] ] HHUHH. [ [ [
] ] / `HN("N \ [ [
]__]/ HNH " \[__[
] NNN [
] / N/" \ [
] / N H \ [
/ N \
/ q, \
/ \
$ cat ~/aks2.txt
\ RTX /
\ /
\ WAZUH LAB /
] [ ,'|
] [ / |
]___ ___[ ,' |
] ]\ /[ [ |: |
] ] \ / [ [ |: |
] ] ] [ [ [ |: |
] ] ]__ __[ [ [ |: |
] ] ] ]\ _ /[ [ [ [ |: |
] ] ] ] (A) [ [ [ [ :===='
] ] ]_].nRn.[_[ [ [
] ] ] .HHUHH [ [ [
] ] / #")NH` \ [ [
]__]/ " HNH \[__[
] NNN [
] / "\N [
] H N \ [
/ / N \ \
/ / ,p \ \
/ \
Here's my code so far:
if [[ -t 0 ]]; then
old_tty=$(stty --save)
stty raw -echo min 0
fi
while IFS= read -r REPLY; [[ -z "$REPLY" ]]; do
clear
cat ~/aks1.txt
usleep 500000
clear
cat ~/aks2.txt
((c++)) && usleep 500000
done
if [[ -t 0 ]]; then
stty "$old_tty"
fi
echo
Pros:
- Simple approach/solution
- No complex variable substitution required (at tput cup screen locations)
- Works well until ANY key is pressed so no hard-coded COUNTER variable is required for running the life of the animation.
- Animation is kind of working (animation is happening, but the output is not rendering perfectly).
Cons:
- Animation output is GARBLED/SHITTY.
How can I fix the output?