我如何让火车ascii看起来像是从右到左移动到linux shell?
_-====-__-____-============-__
_( _)
OO( )_
0 (_ _)
o0 (_ _)
o `=-___-===-_____-========-__)
.o _________
. ______ ______________ | | _____
_()_||__|| ________ | | |_________| __||___||__
( | | | | | |Y_____00_| |_ _|
/-OO----OO**=*OO--OO*=*OO--------OO*=*OO-------OO*=*OO-------OO*=P
答案 0 :(得分:1)
你可以安装linux命令' sl'如果你想让火车在你的屏幕上运行。
http://www.cyberciti.biz/tips/displays-animations-when-accidentally-you-type-sl-instead-of-ls.html
答案 1 :(得分:0)
你应该看一下ANSI Escape Codes,特别是在移动光标和清除屏幕时。要快速入门,您只需清除 \ e [2J 整个屏幕并重新绘制所有内容。
示例:
#include <iostream>
using namespace std;
/* ASCII control character for ESCAPE (ESC) is "\e"
* Alternatives: Oct 033, Dez 27, Hex 1B
*
* The '\e' escape sequence is not part of ISO C and many other language
* specifications. However, it is understood by several compilers.
* The Escape character can also be entered by pressing the "Escape" or
"Esc"
* key on some systems.
*/
int main() {
cout << "\e[35m" << "Purple\n" << "\e[m";
// cout << "\e[2J\e[H" << "\e[35mPlease enter\e[m: \n";
cout << "foo" << '\x2B' << "\n";
return 0;
}
或者您使用GNU中的库ncurses。
答案 2 :(得分:0)
编辑:
您可以使用pr -tro width
原始解决方案,并在下方展开:
将ascii图像放入文件(train.txt)中,但删除第一个空格(所有行都有共同点)。
i=0
while [ $i -lt 20 ]; do
clear
cat train.txt | pr -tro $i
sleep 1
(( i = i + 1 ))
done
扩展解决方案: 将ascii图像放在文件(train.txt)中,但用1个标签替换第一个空格(所有行都有共同点)。
i=0
while [ $i -lt 20 ]; do
clear
cat train.txt | expand -$i
sleep 1
(( i = i + 1 ))
done
替代(oneliner图像):使用\ r
替代扩展:使用格式字符串中宽度的printf
向左移动:从i = 20开始,使用-gt 0和((i = i - 1))