Documentation ¶
Overview ¶
Package goat formats "ASCII-art" drawings into Github-flavored Markdown.
<goat> porcelain API BuildAndWriteSVG() .----------. ASCII-art | | Markdown ----------------------->| +-------------------------> | | '----------' · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · plumbing API Canvas{} NewCanvas() .-------------------. WriteSVGBody() | | .-------. ASCII-art .--. | data map[x,y]rune | | SVG{} | Markdown ---------->| +--->| text map[x,y]rune +-->| +-------> '--' | | | | '-------------------' '-------' </goat>
All output is buffered into the object SVG, then written to the output stream.
Index ¶
- func BuildAndWriteSVG(src io.Reader, dst io.Writer, svgColorLightScheme, svgColorDarkScheme string)
- type Bridge
- type Canvas
- func (c *Canvas) Bridges() (bridges []Drawable)
- func (c *Canvas) Circles() (circles []Circle)
- func (c *Canvas) HalfSteps() (lines []Line)
- func (c *Canvas) Lines() (lines []Line)
- func (c *Canvas) MoveToText()
- func (c *Canvas) RoundedCorners() (corners []RoundedCorner)
- func (c *Canvas) Text() (text []Text)
- func (c *Canvas) Triangles() (triangles []Drawable)
- func (c *Canvas) WriteSVGBody(dst io.Writer)
- type Circle
- type Drawable
- type Index
- type Line
- type Orientation
- type RoundedCorner
- type SVG
- type Text
- type Triangle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge corresponds to combinations of "-)-" or "-(-" and is displayed as the vertical line "hopping over" the horizontal.
type Canvas ¶
type Canvas struct {
// units of cells
Width, Height int
// contains filtered or unexported fields
}
Canvas represents a 2D ASCII rectangle.
func NewCanvas ¶
NewCanvas creates a fully-populated Canvas according to GoAT-formatted text read from an io.Reader, consuming all bytes available.
func (*Canvas) Bridges ¶
Bridges returns a slice of all bridges, "-)-" or "-(-", composed as a sequence of either type Bridge or type Line.
func (*Canvas) Lines ¶
Lines returns a slice of all Line drawables that we can detect -- in all possible orientations.
func (*Canvas) MoveToText ¶
func (c *Canvas) MoveToText()
Move contents of every cell that appears, according to a tricky set of rules, to be "text", into a separate map: from data[] to text[]. So data[] and text[] are an exact partitioning of the incoming grid-aligned runes.
func (*Canvas) RoundedCorners ¶
func (c *Canvas) RoundedCorners() (corners []RoundedCorner)
RoundedCorners returns a slice of all curvy corners in the diagram.
func (*Canvas) Text ¶
Text returns a slice of all text characters not belonging to part of the diagram. Must be stably sorted, to satisfy regression tests.
func (*Canvas) Triangles ¶
Triangles detects intended triangles -- typically at the end of an intended line -- and returns a representational slice composed of types Triangle and Line.
func (*Canvas) WriteSVGBody ¶
WriteSVGBody writes the entire content of a Canvas out to a stream in SVG format.
type Circle ¶
type Circle struct {
// contains filtered or unexported fields
}
Circle corresponds to "o" or "*" runes in the absence of surrounding alphanumerics.
type Drawable ¶
type Drawable interface {
// contains filtered or unexported methods
}
Drawable represents anything that can Draw itself.
type Index ¶
type Index struct {
// units of cells
X, Y int
}
Index represents a position within an ASCII diagram.
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line represents a straight segment between two points 'start' and 'stop', where 'start' is either lesser in X (north-east, east, south-east), or equal in X and lesser in Y (south).
type Orientation ¶
type Orientation int
Orientation represents the primary direction that a Drawable is facing.
const ( NONE Orientation = iota // No orientation; no structure present. N // North NE // Northeast NW // Northwest S // South SE // Southeast SW // Southwest E // East W // West )
type RoundedCorner ¶
type RoundedCorner struct {
// contains filtered or unexported fields
}
RoundedCorner corresponds to combinations of "-." or "-'".
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
tmpl-expand
See `tmpl-expand -help` for abstract.
|
See `tmpl-expand -help` for abstract. |