Diagram - 一个Go的CLI应用程序将ascii艺术转换为手绘图

网友投稿 802 2022-10-27

Diagram - 一个Go的CLI应用程序将ascii艺术转换为手绘图

Diagram - 一个Go的CLI应用程序将ascii艺术转换为手绘图

Diagram

Diagram is a CLI tool to generate hand drawn diagrams from ASCII arts.

It's a full featured CLI application which converts the ASCII text into hand drawn diagrams. The CLI part is based on gocui and the ascii to png conversion is done using the gg library.

Installation

In order to run the application please make sure that Go is installed on your local machine and check if $GOPATH/bin is included into the PATH directory.

$ export GOPATH="$HOME/go"$ export PATH="$PATH:$GOPATH/bin"

In order to visualize the generated output (with CTRL-d) please make sure that glfw is installed on your machine.

A shell script is bundled into the library to mitigate the generation of binary files for the most widespread operating systems, but take care: different dependencies are needed for different operating systems. To build the executables type:

$ make all

For a full list of the required external dependencies check the official documentation of go-glfw (https://github.com/go-gl/glfw/blob/master/README.md).

$ go get github.com/esimov/diagram$ go install# Start the application$ diagram

Usage

Once you are inside the terminal application you can create, edit or delete the ascii diagrams. By pressing CTRL+d you can convert the ASCII art into a handwritten diagram. The PNG file will be saved into the output folder relative to the current path.

A shell script is included to watch the output folder and automatically open the generated image files.

Update:

This is not needed anymore, since an internal image viewer is bundled into the application.

Command Line support

The application also supports the generation of hand drawn diagrams directly from command line without to enter into the CLI application.

$ diagram --help will show the currently supported options:

┌┬┐┬┌─┐┌─┐┬─┐┌─┐┌┬┐ │││├─┤│ ┬├┬┘├─┤│││─┴┘┴┴ ┴└─┘┴└─┴ ┴┴ ┴ Version: 1.0.4CLI app to convert ASCII arts into hand drawn diagrams. -font string Path to the font file (default "/Users/esimov/Projects/Go/src/github.com/esimov/diagram/font/gloriahallelujah.ttf") -in string Source -out string Destination -preview Show the preview window (default true)

CLI Examples

Read input from sample.txt and write image to sample.png showing a preview window with the hand drawn diagram:

diagram -in sample.txt -out sample.png

Read input from sample.txt and write image to sample.png, and exit immediately without showing a preview window:

diagram -in sample.txt -out sample.png -preview=false

Generate diagram as above but use a font at a different location:

diagram -in sample.txt -out sample.png -preview=false -font /path/to/my/font/MyHandwriting.ttf

Key bindings

KeyDescription
TabNext Panel
Shift+TabPrevious Panel
Ctrl+sOpen Save Diagram Modal
Ctrl+sSave Diagram
Ctrl+dConvert Ascii to PNG
Ctrl+xClear the editor content
Ctrl+zRestore the editor content
PageUpJump to the top
PageDownJump to the bottom
HomeJump to the line start
EndJump to the line end
Delete/BackspaceDelete diagram
Ctrl+cQuit

Example

The app was tested on Ubuntu and MacOS.

Acknowledgements

The ascii to png conversion was ported from shaky.dart.

Author

Endre Simo (@simo_endre)

License

Copyright © 2017 Endre Simo

This project is under the MIT License. See the LICENSE file for the full license text.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:aslist(A Sorted List)是golang语言实现的线程安全可排序的list
下一篇:使用deno开发post请求,get请求,监测文件变化自动重启(类似于nodemon)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~