canvas

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const CELL_SIZE float64 = 20

Variables

This section is empty.

Functions

func DrawDiagram

func DrawDiagram(content string, output string, fontpath string) error

Generate diagram into the output file

func X

func X(x float64) float64

func Y

func Y(y float64) float64

Types

type Canvas

type Canvas struct {
	*gg.Context
	// contains filtered or unexported fields
}

func NewCanvas

func NewCanvas(ctx *gg.Context, font string, lineWidth float64) *Canvas

Canvas constructor

type Diagram

type Diagram struct{}

Empty struct

func (*Diagram) ParseASCIIArt

func (d *Diagram) ParseASCIIArt(str string) []*Figures

Parses given ASCII art string into a list of figures.

type Drawer

type Drawer interface {
	Draw(*Canvas)
}

Drawer interface. Struct needs to implement the Draw method.

type Figures

type Figures struct {
	Line
	Text
}

Compounded struct with Line & Text

type Line

type Line struct {
	// contains filtered or unexported fields
}

Line struct defines the line x & y coordinates, the starting and ending type and the color.

func NewLine

func NewLine(x0, y0 int, start string, x1, y1 int, end string, color string) *Line

Line from (x0, y0) to (x1, y1) with the given color at the start and end.

func (*Line) Draw

func (line *Line) Draw(ctx *Canvas)

Draw line at (x0, y0) with the given color.

type Point

type Point struct {
	// contains filtered or unexported fields
}

Auxiliary Point struct used during parsing.

func NewPoint

func NewPoint(x, y int) *Point

Create a new Point struct

type Text

type Text struct {
	// contains filtered or unexported fields
}

Text struct that contains the x & y coordinates and color.

func NewText

func NewText(x0, y0 int, text, color string) *Text

Text annotation at (x0, y0) with the given color.

func (*Text) Draw

func (text *Text) Draw(ctx *Canvas)

Draw text annotation at (x0, y0) with the given color.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL