viz

package
v0.0.0-...-509ffec Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Colors color.Palette = make([]color.Color, 256)

colors is a palette where the index corresponds to a 8 bit terminal color palette (i.e. 256 colors)

Functions

func Draw

func Draw()

Draw renders all 256 colors to stdout for debugging purposes

func InitColors

func InitColors(num int) bool

InitColors initializes 'Colors' (the terminal emulator color palette) with 'num' colors. Accepted num values are 8, 16, 256. Returns a boolean indicating success or failure. If 'num' is not one of the accepted values, 256 colors are initialized and false is returned.

func PaintCell

func PaintCell(topColor, bottomColor uint8) string

PaintCell returns a lower-half-block character (▄) with the background set to the top color and the foreground set to the bottomColor.

Types

type Canvas

type Canvas interface {
	// Paint renders two pixels at a time - the top (y) and the
	// bottom (y+1) ones.
	Paint(topColor, bottomColor uint8) error
	// NewLine moves the cursor to the next line
	NewLine() error
	// Moves the cursor up one line 'count' times.
	LineUp(count int) error
	// Sleep sleeps for the specified time.
	Sleep(delayMS int) error
	// Close closes the canvas.
	Close() error
}

Canvas is the destination (e.g. stdout vs file) where the image will be rendered.

type FileCanvas

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

FileCanvas exports the image to a shell script that can be executed when required, to render the image.

func NewFileCanvas

func NewFileCanvas(filename string) (*FileCanvas, error)

NewFileCanvas returns a FileCanvas.

func (*FileCanvas) Close

func (fc *FileCanvas) Close() error

func (*FileCanvas) LineUp

func (fc *FileCanvas) LineUp(count int) error

func (*FileCanvas) NewLine

func (fc *FileCanvas) NewLine() error

func (*FileCanvas) Paint

func (fc *FileCanvas) Paint(topColor, bottomColor uint8) error

func (*FileCanvas) Sleep

func (fc *FileCanvas) Sleep(delayMS int) error

type Image

type Image struct {
	// Path to image file.
	Filename string
	// Specify a file name to export the image to a shell script.
	// For instance, this script can be used to display an image for motd.
	ExportFilename string
	// Specify a loop count to animate GIFs more than once or set to 0 to render the first picture only.
	LoopCount int
	//Specify a decimal point multiplier to increase or decrease the speed of the GIF.
	DelayMultiplier float64
	// Use specified width instead of automatically computing it. Height will be calculated according to the aspect ratio.
	// This is useful in SSH sessions where screen resizes are not registered automatically.
	UserWidth int
	// contains filtered or unexported fields
}

Image is a representation of a (multi) picture image.

func (*Image) Draw

func (img *Image) Draw(canvas Canvas) error

Draw renders the image into one of the selected modes (stdout or file)

func (*Image) Init

func (img *Image) Init() (err error)

Init initializes the visualization framework for drawing the image.

type StdoutCanvas

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

StdoutCanvas renders the image to stdout.

func (*StdoutCanvas) Close

func (sc *StdoutCanvas) Close() error

func (*StdoutCanvas) LineUp

func (sc *StdoutCanvas) LineUp(count int) error

func (*StdoutCanvas) NewLine

func (sc *StdoutCanvas) NewLine() error

func (*StdoutCanvas) Paint

func (sc *StdoutCanvas) Paint(topColor, bottomColor uint8) error

func (*StdoutCanvas) Sleep

func (sc *StdoutCanvas) Sleep(delayMS int) error

Jump to

Keyboard shortcuts

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