lit/cmd-draw

There is no license information available for the latest version (0.0.5) of this package.

命令行绘画

0.0.5 2021-01-25 07:36 UTC

This package is not auto-updated.

Last update: 2021-02-22 08:13:05 UTC


README

CmdDraw PHP 帮助文件.

通过数据绘制表格

//效果
//-------------------------------------
//| title1 | title2 | title3 | title4 |
//|--------+--------+--------+--------|
//|   1    |   2    |   3    |   4    |
//|   5    |   6    |   7    |   8    |
//|   9    |   10   |   11   |   12   |
//-------------------------------------
$title = ['title1', 'title2', 'title3', 'title4']; //表格标题
$data = [ //表格数据
    ["aaa" => 1, "ccc" => 2, "bbb" => 3, "eee" => 4],
    ["aaa1" => 5, "ccc1" => 6, "bbb1" => 7, "eee1" => 8],
    ["aaa2" => 9, "ccc2" => 10, "bbb2" => 11, "eee2" => 12],
];
$drawLine = "-"; //表格线最小组成
$separator = "|"; //表格边界分隔符最小组成
$middleSeparator = "+"; //中线线分割组成
\Lit\CmdDraw\Table::draw($title, $data, $drawLine, "|", "+");

进度条

//效果
//[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-----] (96%)
//注意中间不能有其他输出,会破坏进度条显示
\Lit\CmdDraw\ProgressBar::firstShow(100); //进度条总宽度 不是进度 取决于屏幕宽度.
for ($i = 0; $i <= 9999; $i++) {
    \Lit\CmdDraw\ProgressBar::loopShow($i, 9999); //每完成一次逻辑调用就执行一次
}
//效果
//2600accb361b268.58336873                                                                                         
//3600accb386f798.42531805                                                                                         
//4600accb3acbfe9.71762105                                                                                         
//5600accb3d16b28.75228175                                                                                         
//6600accb4029171.37010576                                                                                         
//7600accb427f902.47444407                                                                                           
//8600accb44d1e01.53938303                                                                                           
//9600accb4728882.62165862                                                                                           
//10600accb497d8a5.70041610                                                                                          
//11600accb4bda8f8.32240463                                                                                           
//12600accb4e31800.30233695                                                                                           
//[>>>>>>>>>>>>----------------------------------------------------------------------------------------] (12% / 00:07)
//带详细信息的进度条
\Lit\CmdDraw\RollingBar::firstShow();
$time = time();
for ($i = 0; $i <= 100; $i++) {
    \Lit\CmdDraw\RollingBar::loopShow($i, 100, $i . " hhahaha", $time);
    usleep(150000);
}

画家

//佛陀效果
//                   _ooOoo_
//                  o8888888o
//                  88" . "88
//                  (| -_- |)
//                  O\  =  /O
//               ____/`---'\____
//             .'  \|     |//  `.
//            /  \|||  :  |||//  \
//           /  _||||| -:- |||||-  \
//           |   | \\  -  /// |   |
//           | \_|  ''\---/''  |   |
//           \  .-\__  `-`  ___/-. /
//         ___`. .'  /--.--\  `. . __
//      ."" '<  `.___\_<|>_/___.'  >'"".
//     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//     \  \ `-.   \_ __\ /__ _/   .-` /  /
//======`-.____`-.___\_____/___.-`____.-'======
//                   `=---='
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                 永 无 B U G
//佛陀           
\Lit\CmdDraw\Artist::buddha('永 无 B U G');
//键盘效果
//┌─────────────────────────────────────────────────────────────┐
//│┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐│
//││Esc│!1 │@2 │#3 │$4 │%5 │^6 │&7 │*8 │(9 │)0 │_- │+= │|\ │`~ ││
//│├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤│
//││ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │{[ │}] │ BS  ││
//│├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤│
//││ Ctrl │ A │ S │ D │ F │ G │ H │ J │ K │ L │: ;│" '│ Enter  ││
//│├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┤│
//││ Shift  │ Z │ X │ C │ V │ B │ N │ M │< ,│> .│? /│Shift │Fn ││
//│└─────┬──┴┬──┴──┬┴───┴───┴───┴───┴───┴──┬┴───┴┬──┴┬─────┴───┘│
//│      │Fn │ Alt │         Space         │ Alt │Win│   HHKB   │
//│      └───┴─────┴───────────────────────┴─────┴───┘          │
//└─────────────────────────────────────────────────────────────┘
//                          永 无 B U G
//键盘
\Lit\CmdDraw\Artist::keyboard('永 无 B U G');