ansimage

package
v0.0.0-...-b7d4782 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScaleModeResize = scaleMode(iota)
	ScaleModeFill
	ScaleModeFit
)

ANSImage scale modes: resize (full scaled to area), fill (resize and crop the image with a center anchor point to fill area), fit (resize the image to fit area, preserving the aspect ratio)

Variables

View Source
var (
	// ErrOddHeight happens when ANSImage height is not even value
	ErrOddHeight = errors.New("ANSImage: height must be even value")

	// ErrInvalidBounds happens when ANSImage height or width are invalid values
	ErrInvalidBounds = errors.New("ANSImage: height or width must be >=2")

	// ErrOutOfBounds happens when ANSI-pixel coordinates are out of ANSImage bounds
	ErrOutOfBounds = errors.New("ANSImage: out of bounds")
)

Functions

func ClearTerminal

func ClearTerminal()

ClearTerminal clears current terminal buffer using ANSI escape code. (Nice info for ANSI escape codes - http://unix.stackexchange.com/questions/124762/how-does-clear-command-work)

Types

type ANSImage

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

ANSImage represents an image encoded in ANSI escape codes

func New

func New(h, w int) (*ANSImage, error)

New creates a new empty ANSImage ready to draw on it

func NewFromFile

func NewFromFile(name string) (*ANSImage, error)

NewFromFile creates a new ANSImage from a file

func NewFromReader

func NewFromReader(reader io.Reader) (*ANSImage, error)

NewFromReader creates a new ANSImage from an io.Reader

func NewScaledFromFile

func NewScaledFromFile(y, x int, sm scaleMode, name string) (*ANSImage, error)

NewScaledFromFile creates a new scaled ANSImage from a file

func NewScaledFromReader

func NewScaledFromReader(y, x int, sm scaleMode, reader io.Reader) (*ANSImage, error)

NewScaledFromReader creates a new scaled ANSImage from an io.Reader

func (*ANSImage) Draw

func (ai *ANSImage) Draw()

Draw writes the ANSImage to standard output (terminal)

func (*ANSImage) GetAt

func (ai *ANSImage) GetAt(y, x int) (*ANSIpixel, error)

GetAt gets ANSI-pixel in coordinates (y,x)

func (*ANSImage) GetMaxProcs

func (ai *ANSImage) GetMaxProcs() int

GetMaxProcs gets the maximum number of parallels goroutines to render the ANSImage

func (*ANSImage) Height

func (ai *ANSImage) Height() int

Height gets total rows of ANSImage

func (*ANSImage) Render

func (ai *ANSImage) Render() string

Render returns the ANSI-compatible string form of ANSImage. (Nice info for ANSI True Colour - https://gist.github.com/XVilka/8346728)

func (*ANSImage) SetAt

func (ai *ANSImage) SetAt(y, x int, r, g, b uint32) error

SetAt sets ANSI-pixel color (RBG) in coordinates (y,x)

func (*ANSImage) SetMaxProcs

func (ai *ANSImage) SetMaxProcs(max int)

SetMaxProcs sets the maximum number of parallel goroutines to render the ANSImage (user should manually sets `runtime.GOMAXPROCS(max)` before to this change takes effect)

func (*ANSImage) Width

func (ai *ANSImage) Width() int

Width gets total columns of ANSImage

type ANSIpixel

type ANSIpixel struct {
	R, G, B uint32
	// contains filtered or unexported fields
}

ANSIpixel represents a pixel of an ANSImage

func (*ANSIpixel) Render

func (ap *ANSIpixel) Render() string

Render returns the ANSI-compatible string form of ANSI-pixel

Jump to

Keyboard shortcuts

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