Skip to content

Commit 790e692

Browse files
author
dmullis
committed
Refactor top level of GoAT library; Improve diagrams
1 parent 79a23a4 commit 790e692

File tree

3 files changed

+48
-47
lines changed

3 files changed

+48
-47
lines changed

canvas.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
/*
2-
Package goat formats "ASCII-art" drawings into Github-flavored Markdown.
3-
4-
<goat>
5-
porcelain API · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
6-
7-
BuildAndWriteSVG()
8-
.----------.
9-
ASCII-art | | Markdown
10-
----------------------->| +------------------------->
11-
| |
12-
'----------'
13-
14-
15-
deep API · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
16-
17-
Canvas{}
18-
NewCanvas() .-------------------. WriteSVGBody()
19-
| | .-------.
20-
ASCII-art .--. | data map[x,y]rune | | SVG{} | Markdown
21-
---------->| +--->| text map[x,y]rune +-->| +------->
22-
'--' | | | |
23-
'-------------------' '-------'
24-
</goat>
25-
*/
261
package goat
272

283
import (

goat.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
Package goat formats "ASCII-art" drawings into Github-flavored Markdown.
3+
4+
<goat>
5+
porcelain API
6+
BuildAndWriteSVG()
7+
.----------.
8+
ASCII-art | | Markdown
9+
----------------------->| +------------------------->
10+
| |
11+
'----------'
12+
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
13+
plumbing API
14+
15+
Canvas{}
16+
NewCanvas() .-------------------. WriteSVGBody()
17+
| | .-------.
18+
ASCII-art .--. | data map[x,y]rune | | SVG{} | Markdown
19+
---------->| +--->| text map[x,y]rune +-->| +------->
20+
'--' | | | |
21+
'-------------------' '-------'
22+
</goat>
23+
*/
24+
package goat
25+
26+
import (
27+
"bytes"
28+
"io"
29+
)
30+
31+
// BuildAndWriteSVG reads in a newline-delimited ASCII diagram from src and writes a
32+
// corresponding SVG diagram to dst.
33+
func BuildAndWriteSVG(src io.Reader, dst io.Writer,
34+
svgColorLightScheme, svgColorDarkScheme string) {
35+
svg := buildSVG(src)
36+
writeBytes(dst, svg.String(svgColorLightScheme, svgColorDarkScheme))
37+
}
38+
39+
func buildSVG(src io.Reader) SVG {
40+
var buff bytes.Buffer
41+
canvas := NewCanvas(src)
42+
canvas.WriteSVGBody(&buff)
43+
return SVG{
44+
Body: buff.String(),
45+
Width: canvas.widthScreen(),
46+
Height: canvas.heightScreen(),
47+
}
48+
}

svg.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
package goat
33

44
import (
5-
"bytes"
65
"fmt"
76
"io"
87
)
@@ -37,27 +36,6 @@ svg {
3736
"1.1", s.Height, s.Width, style, s.Body)
3837
}
3938

40-
// BuildSVG reads a newline-delimited ASCII diagram from src and returns an
41-
// initialized SVG struct.
42-
func BuildSVG(src io.Reader) SVG {
43-
var buff bytes.Buffer
44-
canvas := NewCanvas(src)
45-
canvas.WriteSVGBody(&buff)
46-
return SVG{
47-
Body: buff.String(),
48-
Width: canvas.widthScreen(),
49-
Height: canvas.heightScreen(),
50-
}
51-
}
52-
53-
// BuildAndWriteSVG reads in a newline-delimited ASCII diagram from src and writes a
54-
// corresponding SVG diagram to dst.
55-
func BuildAndWriteSVG(src io.Reader, dst io.Writer,
56-
svgColorLightScheme, svgColorDarkScheme string) {
57-
svg := BuildSVG(src)
58-
writeBytes(dst, svg.String(svgColorLightScheme, svgColorDarkScheme))
59-
}
60-
6139
func writeBytes(out io.Writer, format string, args ...interface{}) {
6240
bytesOut := fmt.Sprintf(format, args...)
6341

0 commit comments

Comments
 (0)