drawille

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: AGPL-3.0 Imports: 4 Imported by: 1

README

drawille-go

started out as a fork of exrook/drawille-go but has diverged a decent amount from that. a lot of the changes have been adapted from termui's implementation but modified to try to incorporate the x and y axis plus their labels.

this uses golang's image library (specifically the Rectangle and Point types) for the canvas that data is plotted in. each point in the canvas is a rune with its own color that gets returned as a string so that it can be used in terminal applications.

Documentation

Index

Constants

View Source
const (
	BRAILLE_OFFSET = '\u2800'
	LINE_OFFSET    = '\u2500'
	NO_OFFSET      = '\u0000'
)
View Source
const (
	YAXIS        = '\u0024' // ┤
	XAXIS        = '\u0000' // ─
	ORIGIN       = '\u0070' //╰
	XLABELMARKER = '\u002C' // ┬
	LABELSTART   = '\u0014' // └
	LABELEND     = '\u0018' // ┘
)

Variables

View Source
var BRAILLE = [4][2]rune{
	{'\u0001', '\u0008'},
	{'\u0002', '\u0010'},
	{'\u0004', '\u0020'},
	{'\u0040', '\u0080'},
}

Functions

This section is empty.

Types

type Canvas

type Canvas struct {
	// various settings accessible outside this object
	LineColors []Color
	LabelColor Color
	AxisColor  Color
	ShowAxis   bool

	// a list of labels the canvas will print for the x axis
	// horizontal labels must be provided by the caller. too lazy
	// to come up with a good way to print stuff so offloading some
	// of that work to the user. when the horizontal labels arent
	// provided an empty line is printed
	HorizontalLabels []string

	// this value is used to determine the horizontal scale when
	// graphing points in the plot. with braille characters, each
	// cell represents 2 points along the x axis. so if the total
	// graphable area in the canvas is 50 cells then we can plot
	// 100 points of data. if we only want to plot 50 data points
	// then the horizontal scale needs to be 2 in order to utilize
	// the whole graphable area. since image uses ints for points
	// the graphing gets a little weird at times due to rounding.
	NumDataPoints int
	// contains filtered or unexported fields
}

Canvas is the container for a series of plots Vertical labels are shown by default and a starting and ending horizontal label can optionally be shown

func NewCanvas

func NewCanvas(width, height int) Canvas

NewCanvas creates a default canvas

func (*Canvas) Fill added in v0.0.2

func (c *Canvas) Fill(data [][]float64)

Fill adds values to the Canvas

func (*Canvas) Plot

func (c *Canvas) Plot(data [][]float64) string

Plot sets the Canvas and return the string representation of it

func (Canvas) String

func (c Canvas) String() string

String allows the Canvas to implement the Stringer interface

type Cell

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

Cell represents the braille character at some coordinate in the canvas

func NewCell added in v0.0.3

func NewCell(r, offset rune, color Color) Cell

func (Cell) String

func (c Cell) String() string

String returns the cell's rune wrapped in the color escape strings

type Color

type Color int
var (
	Default              Color = -1
	AliceBlue            Color = 255
	AntiqueWhite         Color = 255
	Aqua                 Color = 14
	Aquamarine           Color = 122
	Azure                Color = 15
	Beige                Color = 230
	Bisque               Color = 224
	Black                Color = 0
	BlanchedAlmond       Color = 230
	Blue                 Color = 12
	BlueViolet           Color = 92
	Brown                Color = 88
	BurlyWood            Color = 180
	CadetBlue            Color = 73
	Chartreuse           Color = 118
	Chocolate            Color = 166
	Coral                Color = 209
	CornflowerBlue       Color = 68
	Cornsilk             Color = 230
	Crimson              Color = 161
	Cyan                 Color = 14
	DarkBlue             Color = 18
	DarkCyan             Color = 30
	DarkGoldenrod        Color = 136
	DarkGray             Color = 248
	DarkGreen            Color = 22
	DarkKhaki            Color = 143
	DarkMagenta          Color = 90
	DarkOliveGreen       Color = 59
	DarkOrange           Color = 208
	DarkOrchid           Color = 134
	DarkRed              Color = 88
	DarkSalmon           Color = 173
	DarkSeaGreen         Color = 108
	DarkSlateBlue        Color = 60
	DarkSlateGray        Color = 238
	DarkTurquoise        Color = 44
	DarkViolet           Color = 92
	DeepPink             Color = 198
	DeepSkyBlue          Color = 39
	DimGray              Color = 242
	DodgerBlue           Color = 33
	Firebrick            Color = 124
	FloralWhite          Color = 15
	ForestGreen          Color = 28
	Fuchsia              Color = 13
	Gainsboro            Color = 253
	GhostWhite           Color = 15
	Gold                 Color = 220
	Goldenrod            Color = 178
	Gray                 Color = 8
	Green                Color = 2
	GreenYellow          Color = 155
	Honeydew             Color = 15
	HotPink              Color = 205
	IndianRed            Color = 167
	Indigo               Color = 54
	Ivory                Color = 15
	Khaki                Color = 222
	Lavender             Color = 254
	LavenderBlush        Color = 255
	LawnGreen            Color = 118
	LemonChiffon         Color = 230
	LightBlue            Color = 152
	LightCoral           Color = 210
	LightCyan            Color = 195
	LightGoldenrodYellow Color = 230
	LightGray            Color = 252
	LightGreen           Color = 120
	LightPink            Color = 217
	LightSalmon          Color = 216
	LightSeaGreen        Color = 37
	LightSkyBlue         Color = 117
	LightSlateGray       Color = 103
	LightSteelBlue       Color = 152
	LightYellow          Color = 230
	Lime                 Color = 10
	LimeGreen            Color = 77
	Linen                Color = 255
	Magenta              Color = 13
	Maroon               Color = 1
	MediumAquamarine     Color = 79
	MediumBlue           Color = 20
	MediumOrchid         Color = 134
	MediumPurple         Color = 98
	MediumSeaGreen       Color = 72
	MediumSlateBlue      Color = 99
	MediumSpringGreen    Color = 48
	MediumTurquoise      Color = 80
	MediumVioletRed      Color = 162
	MidnightBlue         Color = 17
	MintCream            Color = 15
	MistyRose            Color = 224
	Moccasin             Color = 223
	NavajoWhite          Color = 223
	Navy                 Color = 4
	OldLace              Color = 230
	Olive                Color = 3
	OliveDrab            Color = 64
	Orange               Color = 214
	OrangeRed            Color = 202
	Orchid               Color = 170
	PaleGoldenrod        Color = 223
	PaleGreen            Color = 120
	PaleTurquoise        Color = 159
	PaleVioletRed        Color = 168
	PapayaWhip           Color = 230
	PeachPuff            Color = 223
	Peru                 Color = 173
	Pink                 Color = 218
	Plum                 Color = 182
	PowderBlue           Color = 152
	Purple               Color = 5
	Red                  Color = 9
	RosyBrown            Color = 138
	RoyalBlue            Color = 63
	SaddleBrown          Color = 94
	Salmon               Color = 210
	SandyBrown           Color = 215
	SeaGreen             Color = 29
	SeaShell             Color = 15
	Sienna               Color = 131
	Silver               Color = 7
	SkyBlue              Color = 117
	SlateBlue            Color = 62
	SlateGray            Color = 66
	Snow                 Color = 15
	SpringGreen          Color = 48
	SteelBlue            Color = 67
	Tan                  Color = 180
	Teal                 Color = 6
	Thistle              Color = 182
	Tomato               Color = 203
	Turquoise            Color = 80
	Violet               Color = 213
	Wheat                Color = 223
	White                Color = 15
	WhiteSmoke           Color = 255
	Yellow               Color = 11
	YellowGreen          Color = 149
)

func (Color) String

func (c Color) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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