V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
WaJueJiPrince
V2EX  ›  Python

Python 模拟“黑客帝国”影片中的终端动画脚本

  •  
  •   WaJueJiPrince · 2018-08-18 15:51:41 +08:00 · 4719 次点击
    这是一个创建于 2281 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Python 模拟“黑客帝国”影片中的终端动画脚本

    前言

    翻阅Github发现一个模拟黑客帝国终端动画的效果!只需要安装以后运行简单命令就好!效果图:

    安装

    采用 Python 包管理工具pip安装即可:

    pip install git+https://github.com/will8211/unimatrix.git
    

    运行

    安装好以后在终端运行下面命令即可:

    unimatrix -n -s 96 -l o
    
    unimatrix -c blue -u ILovePython
    
    unimatrix -c yellow -l e
    

    命令参数

    USAGE
      unimatrix [-a] [-b] [-c COLOR] [-f] [-g COLOR] [-h] [-l CHARACTER_LIST] [-n]
                [-o] [-s SPEED] [-u CUSTOM_CHARACTERS]
    
    OPTIONAL ARGUMENTS
      -a                   Asynchronous scroll. Lines will move at varied speeds.
    
      -b                   Use only bold characters
    
      -c COLOR             One of: green (default), red, blue, white, yellow, cyan,
                           magenta, black
    
      -f                   Enable "flashers," characters that continuously change.
    
      -g COLOR             Background color (See -c). Defaults to keeping
                           terminal's current background.
    
      -h                   Show this help message and exit
    
      -l CHARACTER_LIST    Select character set(s) using a string over letter
                           codes (see CHARACTER SETS below.)
    
      -n                   Do not use bold characters (overrides -b)
    
      -o                   Disable on-screen status
    
      -s SPEED             Integer up to 100. 0 uses a one-second delay before
                           refreshing, 100 uses none. Use negative numbers for
                           even lower speeds. Default=85
    
      -t TIME              Exit the process after TIME seconds
    
      -u CUSTOM_CHARACTERS Your own string of characters to display. Enclose in
                           single quotes ('') to escape special characters. For
                           example: -u '#$('
    
      -w                   Single-wave mode: Does a single burst of green rain,
                           exits. You can put in a .bashrc file to run when your
                           terminal launches. Works well with speed at 95.
    
    LONG ARGUMENTS
      -a --asynchronous
      -b --all-bold
      -c --color=COLOR
      -f --flashers
      -g --bg-color=COLOR
      -h --help
      -l --character-list=CHARACTER_LIST
      -s --speed=SPEED
      -n --no-bold
      -o --status-off
      -t --time
      -u --custom_characters=CUSTOM_CHARACTERS
      -w --single_wave
    
    CHARACTER SETS
      When using '-l' or '--character_list=' option, follow it with one or more of
      the following letters:
    
      a   Lowercase alphabet
      A   Uppercase alphabet
      c   Lowercase Russian Cyrillic alphabet
      C   Uppercase Russian Cyrillic alphabet
      e   A few common emoji ( ☺☻✌♡♥❤⚘❀❃❁✼☀✌♫♪☃❄❅❆☕☂★ )
      g   Lowercase Greek alphabet
      G   Uppercase Greek alphabet
      k   Japanese katakana (half-width)
      m   Default 'Matrix' set, equal to 'knnssss'
      n   Numbers 0-9
      o   'Old' style non-unicode set, like cmatrix. Equal to 'AaSn'
      p   Klingon pIqaD (requires 'Horta' family font)*
      P   Klingon pIqaD (requires 'Klingon-pIqaD' or 'Code2000' family font)*
      r   Lowercase Roman numerals ( mcclllxxxxvvvvviiiiii )
      R   Uppercase Roman numerals ( MCCLLLXXXXVVVVVIIIIII )
      s   A subset of symbols actually used in the Matrix films ( -=*_+|:<>" )
      S   All common keyboard symbols ( `-=~!z#$%^&*()_+[]{}|\;':",./<>?" )
      u   Custom characters selected using -u switch
    
      For example: '-l naAS' or '--character_list=naAS' will give something similar
      to the output of the original cmatrix program in its default mode.
      '-l ACG' will use all the upper-case character sets. Use the same
      letter multiple times to increase the frequency of the character set. For
      example, the default setting is equal to '-l knnssss'.
    
      * With most modern Linux terminals (gnome-terminal, konsole, lxterminal,
        xfce4-terminal, mate-terminal) simply having the font installed system-wide
        is enough. The terminal will fall back to it for the Klingon, meaning that
        you don't have to select it in your terminal settings. 'Horta' seems not to
        work in Konsole. Fonts may need to be set manually as fallbacks in
        .Xresources for older terminals, such as urxvt and xterm.
    
    KEYBOARD CONTROL
      SPACE, CTRL-c or q   exit
      - or LEFT            decrease speed by 1
      + or RIGHT           increase speed by 1
      [ or DOWN            decrease speed by 10
      ] or UP              increase speed by 10
      a                    toggle asynchronous scrolling
      b                    cycle through bold character options
                               (bold off-->bold on-->all bold)
      f                    toggle flashing characters
      o                    toggle on-screen status
      1 to 9               set color: (1) Green   (2) Red   (3) Blue     (4) White
                                      (5) Yellow  (6) Cyan  (7) Magenta  (8) Black
                                      (9) Terminal default
      ! to (               set background color (same colors as above, but pressing
                               shift + number)
    
    EXAMPLES
      Mimic default output of cmatrix (no unicode characters, works in TTY):
        $ unimatrix -n -s 96 -l o
    
      Use the letters from the name of your favorite operating system in bold blue:
        $ unimatrix -B -u Linux -c blue
    
      Use default character set, plus dollar symbol (note single quotes around
          special character):
        $ unimatrix -l knnssssu -u '$'
    
      No bold characters, slowly, using emojis, numbers and a few symbols:
        $ unimatrix -n -l ens -s 50
    

    项目链接

    UniMatrix

    14 条回复    2018-08-20 12:43:47 +08:00
    frmongo
        1
    frmongo  
       2018-08-18 16:04:47 +08:00 via Android
    酷炫
    xiiin
        2
    xiiin  
       2018-08-18 16:41:21 +08:00
    很久以前用 VB6 的时候,做过类似的应用。
    但是我做的每一列都是相同的字符,采用了透明度近似实现成“虚影”的效果。
    JCZ2MkKb5S8ZX9pq
        3
    JCZ2MkKb5S8ZX9pq  
       2018-08-18 17:30:07 +08:00
    前一阵试多行内容刷新的时候,顺便也写过一个。不过倒是没想到用半角日文字。
    LvMax
        4
    LvMax  
       2018-08-18 17:57:26 +08:00 via iPhone
    下次朋友看我工作就给他看这个了
    likuku
        5
    likuku  
       2018-08-18 18:01:11 +08:00 via iPhone
    几年前用过类似的,上班有时会完全在终端下工作,就索性全屏,临时离开就开启一个这种字幕瀑布程序
    ACool
        6
    ACool  
       2018-08-18 18:30:36 +08:00 via Android   ❤️ 1
    不用这么麻烦,直接 sudo apt-get install cmatrix
    按 F11 把 terminal 全屏,输入『 cmatrix -b 』
    dobelee
        7
    dobelee  
       2018-08-18 18:46:36 +08:00 via Android
    下载个源码编译,比这个炫酷。
    captainjack
        8
    captainjack  
       2018-08-18 19:33:03 +08:00
    6 楼才是正解。。。
    MOmc
        9
    MOmc  
       2018-08-19 00:12:21 +08:00 via iPhone
    脑阔忽然想到这个以后给来参观的领导演示
    cz5424
        10
    cz5424  
       2018-08-19 01:59:02 +08:00 via Android
    收藏收藏
    NicholasWangC
        11
    NicholasWangC  
       2018-08-19 03:49:30 +08:00
    wm5d8b
        12
    wm5d8b  
       2018-08-19 18:18:57 +08:00
    黑客帝国中下落的究竟是什么文字?
    viho
        13
    viho  
       2018-08-19 19:51:16 +08:00
    大神,您好,我是萌新,我想问问您,有接触过用 python 爬取 app 数据的么
    WaJueJiPrince
        14
    WaJueJiPrince  
    OP
       2018-08-20 12:43:47 +08:00
    @viho 我抓取过今日头条等 APP,是你需要的吗?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   995 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 21:49 · PVG 05:49 · LAX 13:49 · JFK 16:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.