Documentation ¶
Index ¶
- Constants
- func AsciiToPng(canvas Canvas, out io.Writer) error
- func AsciiToSvg(canvas Canvas, out io.Writer) error
- func RenderAscii(canvas Canvas, gc draw2d.GraphicContext)
- type Bridge
- type Canvas
- type Circle
- type Drawable
- type FixDraw2DEscapeXml
- type Index
- type Line
- type Orientation
- type Pixel
- type RoundedCorner
- type Text
- type Triangle
Constants ¶
const (
// FIXME what is the right scale?
PngScale = 2
)
Variables ¶
This section is empty.
Functions ¶
func RenderAscii ¶
func RenderAscii(canvas Canvas, gc draw2d.GraphicContext)
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge correspondes to combinations of "-)-" or "-(-" and is displayed as the vertical line "hopping over" the horizontal.
func (Bridge) Draw ¶
func (b Bridge) Draw(gc draw2d.GraphicContext)
Draw a bridge as an SVG elliptical arc element.
type Canvas ¶
Canvas represents a 2D ASCII rectangle.
func NewCanvas ¶
NewCanvas creates a new canvas with contents read from the given io.Reader. Content should be newline delimited.
func (*Canvas) Lines ¶
Lines returns a slice of all Line drawables that we can detect -- in all possible orientations.
func (*Canvas) RoundedCorners ¶
func (c *Canvas) RoundedCorners() []RoundedCorner
RoundedCorners returns a slice of all curvy corners in the diagram.
type Circle ¶
type Circle struct {
// contains filtered or unexported fields
}
Circle corresponds to "o" or "*" runes in the absence of surrounding alphanumerics.
func (*Circle) Draw ¶
func (c *Circle) Draw(gc draw2d.GraphicContext)
Draw a solid circle as an SVG circle element.
type Drawable ¶
type Drawable interface {
Draw(gc draw2d.GraphicContext)
}
Drawable represents anything that can Draw itself.
type FixDraw2DEscapeXml ¶
type FixDraw2DEscapeXml struct {
draw2d.GraphicContext
}
FIXME this probably needs to be fixed in draw2d when drawing text, XML is not escaped and generated SVG is invalid if contains < > & We wrap the GC only for the SVG case to escape the text here
func (*FixDraw2DEscapeXml) FillStringAt ¶
func (gc *FixDraw2DEscapeXml) FillStringAt(text string, x, y float64) (width float64)
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
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.
func (Line) Draw ¶
func (l Line) Draw(gc draw2d.GraphicContext)
Draw a straight line as an SVG path.
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 "-'".
func (*RoundedCorner) Draw ¶
func (c *RoundedCorner) Draw(gc draw2d.GraphicContext)
Draw a rounded corner as an SVG elliptical arc element.