ASCII码(字符集)绘制流程图

在阅读RFC文档时,发现里面的图片都是字符构成的,觉得很是有趣,这样不仅节省了存储空间、减少网络传输,也能清楚地表达含义。何乐而不为?
于是,就像自己写博客时,也采用这种形式来绘制流程图,于是找到以下工具。

将图片转为字符不是我的目的,所以不考虑。

在线绘制ASCII流程图

如下网站,很简单好用。

http://asciiflow.com/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
            +------------------+                +-------------------+
| | | |
| | | |
+-----------+ A +----------------> B |
| | | | |
| | | | |
| | | | |
| +------------------+ +-------------------+
|
|
|
| 好 戏 才 开 始
| ^
| |
+-----------------------------+

Graph Easy

当我们不能联网时,需要有个本地工具也能绘制,这就要本地安装了,使用Graph-Easy

在ubuntu下安装也很简单:

1
$ sudo apt install libgraph-easy-perl

因为这是一个perl模块,然而我不熟悉perl语言,就不通过编程使用了,只是学会用法就好,具体语法参加文档

命令行使用:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
$ echo "[ Bonn ] - car -> [ Berlin ]" | graph-easy
+------+ car +--------+
| Bonn | -----> | Berlin |
+------+ +--------+

# 需要多个时,直接分开就是
$ graph-easy <<< "[a]->[b]->[c] [d]->[e]"
+---+ +---+ +---+
| a | --> | b | --> | c |
+---+ +---+ +---+
+---+ +---+
| d | --> | e |
+---+ +---+

$ graph-easy <<< "[a]->[b]->[c] [d]->[e]->[b]"
+---+ +---+ +---+
| a | --> | b | --> | c |
+---+ +---+ +---+
^
|
|
+---+ +---+
| d | --> | e |
+---+ +---+

$ graph-easy <<< "[a]->[b]->[c] [d]->[e]->[b] [e]->[e]"
+---+ +------+ +---+
| a | --> | b | --> | c |
+---+ +------+ +---+
^
|
|
+---+ +------+
| d | --> | e |
+---+ +------+
^ |
+--+

# 垂直绘制
$ graph-easy <<< "graph{flow:south;}[a]->[b]->[c]"
+---+
| a |
+---+
|
|
v
+---+
| b |
+---+
|
|
v
+---+
| c |
+---+

# 使用点绘制线
$ graph-easy <<< "[a]->[b]->[c]->[e] [b]..>[e]"

.....................
: v
+---+ +---+ +---+ +---+
| a | --> | b | --> | c | --> | e |
+---+ +---+ +---+ +---+

参考:https://juejin.im/post/5a09c43451882535c56c6bbf