Documentation
¶
Index ¶
- Constants
- Variables
- func ClearTerminal()
- type ANSImage
- func New(h, w int) (*ANSImage, error)
- func NewFromFile(bg color.Color, name string) (*ANSImage, error)
- func NewFromReader(bg color.Color, reader io.Reader) (*ANSImage, error)
- func NewScaledFromFile(y, x int, sm scaleMode, bg color.Color, name string) (*ANSImage, error)
- func NewScaledFromReader(y, x int, sm scaleMode, bg color.Color, reader io.Reader) (*ANSImage, error)
- func (ai *ANSImage) Draw()
- func (ai *ANSImage) GetAt(y, x int) (*ANSIpixel, error)
- func (ai *ANSImage) GetMaxProcs() int
- func (ai *ANSImage) Height() int
- func (ai *ANSImage) Render() string
- func (ai *ANSImage) SetAt(y, x int, r, g, b uint8) error
- func (ai *ANSImage) SetMaxProcs(max int)
- func (ai *ANSImage) Width() int
- type ANSIpixel
Constants ¶
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 ¶
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 NewFromFile ¶
NewFromFile creates a new ANSImage from a file. Background color is used to fill when image has transparency.
func NewFromReader ¶
NewFromReader creates a new ANSImage from an io.Reader. Background color is used to fill when image has transparency.
func NewScaledFromFile ¶
NewScaledFromFile creates a new scaled ANSImage from a file. Background color is used to fill when image has transparency.
func NewScaledFromReader ¶
func NewScaledFromReader(y, x int, sm scaleMode, bg color.Color, reader io.Reader) (*ANSImage, error)
NewScaledFromReader creates a new scaled ANSImage from an io.Reader. Background color is used to fill when image has transparency.
func (*ANSImage) Draw ¶
func (ai *ANSImage) Draw()
Draw writes the ANSImage to standard output (terminal).
func (*ANSImage) GetMaxProcs ¶
GetMaxProcs gets the maximum number of parallels goroutines to render the ANSImage.
func (*ANSImage) Render ¶
Render returns the ANSI-compatible string form of ANSImage. (Nice info for ANSI True Colour - https://gist.github.com/XVilka/8346728)
func (*ANSImage) SetMaxProcs ¶
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).