• Linux下C 更改字符在终端的显示颜色


    使用33[01;04;32;41m之类的配色方案在需要输出显示的文本之前,可以改变应用程序输出文本的颜色或者背景颜色。


    比如:

    #include <stdio.h>


    int main(void) {
    printf("33[01;34m Hello World!33[0m ");

    return 0;
    }

    上面的01表示加粗,34表示是蓝色,后面33[0m表示恢复所有的属性为原来的默认值。也可以把上述的33字符用e替换。可以采用多种配色方案,比如上面提到的33[01;04;32;41m,04表示下划线,32表示前景色是绿色,然后41表示背景色是红色。

    由于使用的是Linux系统为终端提供的配色方案,所以该程序不具备移植性。可以看到,该程序在Windows会打印一些奇怪的符号。 

    Some fun

    You can paste the following into a terminal to get a stupid matrix like screensaver, or for an infinitely better example, see cmatrix.

    tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock |
    GREP_COLOR="1;32" grep --color "[^ ]"
    

    For a silly 256 colour demo here is a command line to cycle through all shades of gray

    yes "$(seq 232 255;seq 254 -1 233)" |
    while read i; do printf "x1b[48;5;${i}m
    "; sleep .01; done
    

    Note also the venerable game 0verkill, and the Colour AsCii Art library, which is included with mplayer for example:

    mplayer -vo caca video.mpg
  • 相关阅读:
    PhoneGap 数据库操作
    eclipse打开html文件
    Android 播放音频
    本地搭建 Apache 服务器
    C# CSV 导出
    .NET中使用MySQL数据库
    搭建一个phonegap环境,用eclipse+phonegap
    js test()
    Dom指针函数
    Js 禁用输入法 imemode 全角转换成半角
  • 原文地址:https://www.cnblogs.com/Stomach-ache/p/3703244.html
Copyright © 2020-2023  润新知