Home

Awesome

<!-- XX Move this file down to .github/, because its contents are GitHub-specific. -->

GoAT: Go ASCII Tool

<!-- Github-specific status icon Github requires explicitly binding a repository owner's username in the text of a README, implying that a badge in README.md cannot both reflect the status of a test Action after a contributor pushes to his pull request branch, and the run of that same test Action after the upstream owner merges the pull request into his 'main' branch. See: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/adding-a-workflow-status-badge GitHub Community forum shows numerous similar issues with badges: https://github.com/orgs/community/discussions/categories/actions?discussions_q=is%3Aopen+category%3AActions++badge.svg => CONCLUSION: Don't use badges. Instead, pay attention to Action result status. --> <!-- ![](https://github.com/blampe/goat/actions/workflows/test.yml/badge.svg) -->

What GoAT Can Do For You

<!-- https://github.com/dmullis/goat/tree/main#installation -->

You Will Also Need

Graphical- or Rectangle-oriented text editing capability

Both vim and emacs offer useful support. In Emacs, see the built-in rectangle-editing commands, and picture-mode.

A fixed-pitch font with 2:1 height:width ratio as presented by your editor and terminal emulator

Most fixed-pitch or "monospace" Unicode fonts maintain a 2:1 aspect ratio for characters in the ASCII range, and all GoAT drawing characters are ASCII. However, certain Unicode graphical characters e.g. MIDDLE DOT may be useful, and conform to the width of the ASCII range.

CJK characters on the other hand are typically wider than 2:1. Non-standard width characters are not in general composable on the left-right axis within a plain-text drawing, because the remainder of the line of text to their right is pushed out of alignment with rows above and below.

Installation

    $ go install github.com/blampe/goat/cmd/goat@latest
<!-- https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections#creating-a-collapsed-section -->

Example Graphics

Here are some snippets of GoAT-formatted UTF-8 and the SVG each can generate. The SVG you see below was linked to by inline Markdown image references (howto, spec) from GoAT's README.md, then finally rendered to HTML <img> elements by Github's Markdown processor

Trees


          .               .                .               .--- 1          .-- 1     / 1
         / \              |                |           .---+            .-+         +
        /   \         .---+---.         .--+--.        |   '--- 2      |   '-- 2   / \ 2
       +     +        |       |        |       |    ---+            ---+          +
      / \   / \     .-+-.   .-+-.     .+.     .+.      |   .--- 3      |   .-- 3   \ / 3
     /   \ /   \    |   |   |   |    |   |   |   |     '---+            '-+         +
     1   2 3   4    1   2   3   4    1   2   3   4         '--- 4          '-- 4     \ 4


Trees -- mid-range color value

Setting a foreground color in the middle of the possible range of value or luminance is one way to work around a limitation of certain browsers e.g. Safari. Safari does not support inheritance of the color-scheme CSS property by goat's output <svg> element from within an enclosing <img> element such as are generated by Markdown.

Overlaps


           .-.           .-.           .-.           .-.           .-.           .-.
          |   |         |   |         |   |         |   |         |   |         |   |
       .---------.   .--+---+--.   .--+---+--.   .--|   |--.   .--+   +--.   .------|--.
      |           | |           | |   |   |   | |   |   |   | |           | |   |   |   |
       '---------'   '--+---+--'   '--+---+--'   '--|   |--'   '--+   +--'   '--|------'
          |   |         |   |         |   |         |   |         |   |         |   |
           '-'           '-'           '-'           '-'           '-'           '-'

Line Decorations

                ________                            o        *          *   .--------------.
   *---+--.    |        |     o   o      |         ^          \        /   |  .----------.  |
       |   |    '--*   -+-    |   |      v        /            \      /    | |  <------.  | |
       |    '----->       .---(---'  --->*<---   /      .+->*<--o----'     | |          | | |
   <--'  ^  ^             |   |                 |      | |  ^    \         |  '--------'  | |
          \/        *-----'   o     |<----->|   '-----'  |__|     v         '------------'  |
          /\                                                               *---------------'

Line Ends

   o--o    *--o     /  /   *  o  o o o o   * * * *   o o o o   * * * *      o o o o   * * * *
   o--*    *--*    v  v   ^  ^   | | | |   | | | |    \ \ \ \   \ \ \ \    / / / /   / / / /
   o-->    *-->   *  o   /  /    o * v '   o * v '     o * v \   o * v \  o * v /   o * v /
   o---    *---
                                 ^ ^ ^ ^   . . . .   ^ ^ ^ ^   \ \ \ \      ^ ^ ^ ^   / / / /
   |  |   *  o  \  \   *  o      | | | |   | | | |    \ \ \ \   \ \ \ \    / / / /   / / / /
   v  v   ^  ^   v  v   ^  ^     o * v '   o * v '     o * v \   o * v \  o * v /   o * v /
   *  o   |  |    *  o   \  \

   <--o   <--*   <-->   <---      ---o   ---*   --->   ----      *<--   o<--   -->o   -->*


Dot Grids


  o o o o o  * * * * *  * * o o *    o o o      * * *      o o o     · * · · ·     · · ·
  o o o o o  * * * * *  o o o o *   o o o o    * * * *    * o * *    · * * · ·    · · · ·
  o o o o o  * * * * *  o * o o o  o o o o o  * * * * *  o o o o o   · o · · o   · · * * ·
  o o o o o  * * * * *  o * o o o   o o o o    * * * *    o * o o    · · · · o    · · * ·
  o o o o o  * * * * *  * * * * o    o o o      * * *      o * o     · · · · ·     · · *


Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character, encoded with UTF-8.

Large Nodes


   .---.       .-.        .-.       .-.                                       .-.
   | A +----->| 1 +<---->| 2 |<----+ 4 +------------------.                  | 8 |
   '---'       '-'        '+'       '-'                    |                  '-'
                           |         ^                     |                   ^
                           v         |                     v                   |
                          .-.      .-+-.        .-.      .-+-.      .-.       .+.       .---.
                         | 3 +---->| B |<----->| 5 +---->| C +---->| 6 +---->| 7 |<---->| D |
                          '-'      '---'        '-'      '---'      '-'       '-'       '---'

Small Grids

     ___     ___      .---+---+---+---+---.     .---+---+---+---.
 ___/   \___/   \     |   |   |   |   |   |    / \ / \ / \ / \ /
/   \___/   \___/     +---+---+---+---+---+   +---+---+---+---+
\___/ b \___/   \     |   |   | b |   |   |    \ / \a/ \b/ \ / \
/ a \___/   \___/     +---+---+---+---+---+     +---+---+---+---+
\___/   \___/   \     |   | a |   |   |   |    / \ / \ / \ / \ /
    \___/   \___/     '---+---+---+---+---'   '---+---+---+---'

.---.   .---.   +--+  +-+  +-+ .-.  .--.    .-.      +-+  +--+  .-.  .--.
|   |   |   |   |  |  | |  | | | |  |  |   |   |     | |  |  |  | |  |  |
+---+   +---+   +--+  +-+  | | | |  |  |   |   |     +-+  +--+  '-'  '--'
|   +---+   |   |  |  | |  | | | |  |  |   |   |
+---+ b +---+   +--+  +-+  | | | |  |  |   |   |
| a +---+   |   |  |  | |  | | | |  |  |   |   |
'---'   '---'   +--+  +-+  +-+ '-'  '--'    '-'

+---+ .---. .---.
| B | | E | | F |
+---+ '---' '---'
.---. +---+ .---.
| D | | G | | H |
'---' +---+ '---'
0123456789012345678901232

Not Supported:
                              .---+---+---.
+---+    .-.   .-.  0     |   | a |   | b |
| A |   | A | | B | 1    +++  +--++-+-++--+
+---+    '-'   '-'  2    | |  |  |  |  |  |
+---+    .-.   .-.  3    +-+  +--++-+-++--+
| C |   | C | | D | 4    | |  |   |   |   |
+---+    '-'   '-'  5    +++  '---+---+---'
0123434567890123456       |

Big Grids

    .----.        .----.
   /      \      /      \            .-----+-----+-----.
  +        +----+        +----.      |     |     |     |          .-----+-----+-----+-----+
   \      /      \      /      \     |     |     |     |         /     /     /     /     /
    +----+   B    +----+        +    +-----+-----+-----+        +-----+-----+-----+-----+
   /      \      /      \      /     |     |     |     |       /     /     /     /     /
  +   A    +----+        +----+      |     |  B  |     |      +-----+-----+-----+-----+
   \      /      \      /      \     +-----+-----+-----+     /     /  A  /  B  /     /
    '----+        +----+        +    |     |     |     |    +-----+-----+-----+-----+
          \      /      \      /     |  A  |     |     |   /     /     /     /     /
           '----'        '----'      '-----+-----+-----'  '-----+-----+-----+-----+


Complicated

+-------------------+                           ^                      .---.
|    A Box          |__.--.__    __.-->         |      .-.             |   |
|                   |        '--'               v     | * |<---        |   |
+-------------------+                                  '-'             |   |
                       Round                                       *---(-. |
  .-----------------.  .-------.    .----------.         .-------.     | | |
 |   Mixed Rounded  | |         |  / Diagonals  \        |   |   |     | | |
 | & Square Corners |  '--. .--'  /              \       |---+---|     '-)-'       .--------.
 '--+------------+-'  .--. |     '-------+--------'      |   |   |       |        / Search /
    |            |   |    | '---.        |               '-------'       |       '-+------'
    |<---------->|   |    |      |       v                Interior                 |     ^
    '           <---'      '----'   .-----------.              ---.     .---       v     |
 .------------------.  Diag line    | .-------. +---.              \   /           .     |
 |   if (a > b)     +---.      .--->| |       | |    | Curved line  \ /           / \    |
 |   obj->fcn()     |    \    /     | '-------' |<--'                +           /   \   |
 '------------------'     '--'      '--+--------'      .--. .--.     |  .-.     +Done?+-'
    .---+-----.                        |   ^           |\ | | /|  .--+ |   |     \   /
    |   |     | Join        \|/        |   | Curved    | \| |/ | |    \    |      \ /
    |   |     +---->  o    --o--        '-'  Vertical  '--' '--'  '--  '--'        +  .---.
 <--+---+-----'       |     /|\                                                    |  | 3 |
                      v                             not:line    'quotes'        .-'   '---'
  .-.             .---+--------.            /            A || B   *bold*       |        ^
 |   |           |   Not a dot  |      <---+---<--    A dash--is not a line    v        |
  '-'             '---------+--'          /           Nor/is this.            ---

More examples are here

The GoAT Library

The core engine of goat is accessible as a Go library package, for inclusion in specialized code of your own. The code implements a subset, and some extensions, of the ASCII diagram generation function of the browser-side Javascript in Markdeep.

A nicely formatted reference may be found at pkg.go.dev.

Installation

    $ go get -u github.com/blampe/goat/

Library Data Flow

The diagram above was derived by ./pre-push.sh from ASCII-art in the Go source file ./goat.go.

Auto-formatted API docs

<!-- XX XX May need a Github Action to do this substitution at "push" time. [![resource non-responsive](https://pkg.go.dev/badge/github.com/blampe/goat)](https://pkg.go.dev/github.com/blampe/goat) --> <!-- The scraping of GitHub by godocs.io (see https://sr.ht) does NOT include README.md; whereas Google's pkg.go.dev does do so, and apparently runs its own variant of GFM processing :-/ [![resource non-responsive](https://godocs.io/github.com/blampe/goat?status.svg)](https://godocs.io/github.com/blampe/goat) -->

Project Tenets

  1. Utility and ease of integration into existing projects are paramount.
  2. Compatibility with MarkDeep desired, but not required.
  3. TXT and SVG intelligibility are co-equal in priority.
  4. Composability of TXT not to be sacrificed -- only width-8 characters allowed.
  5. Per-platform support limited to a single widely-available fixed-pitch TXT font.