public:it:linux:cmatrix

CMatrix

  • 这是个模拟《骇客帝国》里屏幕绿色字符飘泊而下的程序, 很是酷炫,在 ubuntu 下可安装
    sudo apt-get install cmatrix

    然后直接命令行执行cmatrix.

  • 看源码, 是使用了 Linux/Unix 下的一个图形库 curses, curses的名字源于“cursor optimization”.
  • 使用curses, ubuntu 一般默认安装了链接库, 但头文件还要安装开发库:
     sudo apt-get install libncurses5-dev
  • 下面是个示例程序, 我在 ubuntu 14.04 虚拟机上可编译执行:
    #include <unistd.h>  
    #include <stdlib.h>  
    #include <curses.h>  
    int main() {  
      initscr();  
      /* We move the cursor to the point (5,15) on the logical screen, 
      print "Hello World" and refresh the actual screen. 
      Lastly, we use the call sleep(2) to suspend the program for two seconds, 
      so we can see the output before the program ends. */  
      move(5, 15);  
      printw("%s", "Hello World");  
      refresh();  
      sleep(2);  
      endwin();  
      exit(EXIT_SUCCESS);  
    }  

    使用 gcc 编译

    gcc -o screen1 screen1.c -lcurses  
  • public/it/linux/cmatrix.txt
  • 最后更改: 2018/02/28 13:48
  • 127.0.0.1