MCPcopy Index your code
hub / github.com/esimov/diagram

github.com/esimov/diagram @v1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.0 ↗ · + Follow
172 symbols 409 edges 21 files 124 documented · 72% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Diagram

Go Reference build Go Report Card license

Diagram is a small CLI application to generate hand drawn diagrams from ASCII art.

screencast

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.

Run the following commands to download the project and build the executable.

$ git clone https://github.com/esimov/diagram
$ cd diagram
$ go build

# Start the application
$ diagram

Build

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

$ make all

Usage

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

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.6

CLI 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

Key Action
F1 Show/hide help panel
Tab Next Panel
Shift+Tab Previous Panel
Ctrl+s Open Save Diagram Modal
Ctrl+s Save Diagram
Ctrl+d Convert Ascii to PNG
Ctrl+x Clear the editor content
Ctrl+z Restore the editor content
PageUp Jump to the top
PageDown Jump to the bottom
Home Jump to the line start
End Jump to the line end
Delete/Backspace Delete diagram
Ctrl+q Quit

Example

Input Output

The application was tested on Ubuntu, MacOS and Windows.

Acknowledgements

The ASCII to PNG conversion was ported from shaky.dart.

Dependencies

  • https://github.com/jroimartin/gocui
  • https://github.com/fogleman/gg
  • https://gioui.org/

Author

License

Copyright © 2017 Endre Simo

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

Extension points exported contracts — how you extend this code

Drawer (Interface)
Drawer interface defines the Canvas drawing method. Struct needs to implement the Draw method. [5 implementers]
canvas/canvas.go
Fn (FuncType)
Fn is a generic function acting as a closure function for event handlers.
ui/handlers.go
Easing (Interface)
(no doc) [1 implementers]
gui/animation.go
WidgetEmbedder (Interface)
(no doc) [1 implementers]
ui/widget.go
ComponentHandler (Interface)
(no doc) [1 implementers]
ui/component.go
HandlerFn (FuncType)
(no doc)
ui/widget.go
Key (Interface)
(no doc)
ui/component.go
WidgetOption (FuncType)
(no doc)
ui/widget.go

Core symbols most depended-on inside this repo

ToString
called by 20
ui/const.go
log
called by 10
ui/console.go
GetWidget
called by 9
ui/widget.go
Layout
called by 9
ui/panel.go
X
called by 8
canvas/canvas.go
Y
called by 8
canvas/canvas.go
String
called by 8
color/color.go
Update
called by 8
gui/animation.go

Shape

Method 96
Function 40
Struct 20
TypeAlias 8
Interface 5
FuncType 3

Languages

Go100%

Modules by API surface

ui/panel.go21 symbols
ui/widget.go20 symbols
ui/radio.go18 symbols
ui/editor.go14 symbols
canvas/canvas.go14 symbols
ui/handlers.go12 symbols
ui/ui.go11 symbols
canvas/parser.go10 symbols
ui/modal.go8 symbols
gui/animation.go8 symbols
gui/window.go7 symbols
ui/component.go6 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add diagram \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact