Documentation ¶
Index ¶
- Constants
- Variables
- func ClearTerminal()
- type ANSImage
- func New(h, w int, bg color.Color, dm DitheringMode) (*ANSImage, error)
- func NewFromFile(name string, bg color.Color, dm DitheringMode) (*ANSImage, error)
- func NewFromImage(image image.Image, bg color.Color, dm DitheringMode) (*ANSImage, error)
- func NewFromReader(reader io.Reader, bg color.Color, dm DitheringMode) (*ANSImage, error)
- func NewFromURL(url string, bg color.Color, dm DitheringMode) (*ANSImage, error)
- func NewScaledFromFile(name string, y, x int, bg color.Color, sm ScaleMode, dm DitheringMode) (*ANSImage, error)
- func NewScaledFromImage(image image.Image, y, x int, bg color.Color, sm ScaleMode, dm DitheringMode) (*ANSImage, error)
- func NewScaledFromReader(reader io.Reader, y, x int, bg color.Color, sm ScaleMode, dm DitheringMode) (*ANSImage, error)
- func NewScaledFromURL(url string, y, x int, bg color.Color, sm ScaleMode, dm DitheringMode) (*ANSImage, error)
- func (ai *ANSImage) DitheringMode() DitheringMode
- func (ai *ANSImage) Draw()
- func (ai *ANSImage) DrawExt(renderGoCode, disableBgColor bool)
- 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) RenderExt(renderGoCode, disableBgColor bool) string
- func (ai *ANSImage) SetAt(y, x int, r, g, b, brightness uint8) error
- func (ai *ANSImage) SetMaxProcs(max int)
- func (ai *ANSImage) Width() int
- type ANSIpixel
- type DitheringMode
- type ScaleMode
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).
const ( NoDithering = DitheringMode(iota) DitheringWithBlocks DitheringWithChars )
ANSImage dithering modes: no dithering (classic mode: half block based), chars (use characters to represent brightness), blocks (use character blocks to represent brightness).
const ( BlockSizeY = 8 BlockSizeX = 4 )
ANSImage block size in pixels (dithering mode)
Variables ¶
var ( // ErrImageDownloadFailed occurs in the attempt to download an image and the status code of the response is not "200 OK". ErrImageDownloadFailed = errors.New("ANSImage: image download failed") // ErrHeightNonMoT occurs when ANSImage height is not a Multiple of Two value. ErrHeightNonMoT = errors.New("ANSImage: height must be a Multiple of Two value") // ErrInvalidBoundsMoT occurs when ANSImage height or width are invalid values (Multiple of Two). ErrInvalidBoundsMoT = errors.New("ANSImage: height or width must be >=2") // ErrOutOfBounds occurs 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 - https://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 or dithering mode is enabled. Dithering mode is used to specify the way that ANSImage render ANSI-pixels (char/block elements).
func NewFromImage ¶
NewFromImage creates a new ANSImage from an image.Image. Background color is used to fill when image has transparency or dithering mode is enabled. Dithering mode is used to specify the way that ANSImage render ANSI-pixels (char/block elements).
func NewFromReader ¶
NewFromReader creates a new ANSImage from an io.Reader. Background color is used to fill when image has transparency or dithering mode is enabled. Dithering mode is used to specify the way that ANSImage render ANSI-pixels (char/block elements).
func NewFromURL ¶
NewFromURL creates a new ANSImage from an image URL. Background color is used to fill when image has transparency or dithering mode is enabled. Dithering mode is used to specify the way that ANSImage render ANSI-pixels (char/block elements).
func NewScaledFromFile ¶
func NewScaledFromFile(name string, y, x int, bg color.Color, sm ScaleMode, dm DitheringMode) (*ANSImage, error)
NewScaledFromFile creates a new scaled ANSImage from a file. Background color is used to fill when image has transparency or dithering mode is enabled. Dithering mode is used to specify the way that ANSImage render ANSI-pixels (char/block elements).
func NewScaledFromImage ¶
func NewScaledFromImage(image image.Image, y, x int, bg color.Color, sm ScaleMode, dm DitheringMode) (*ANSImage, error)
NewScaledFromImage creates a new scaled ANSImage from an image.Image. Background color is used to fill when image has transparency or dithering mode is enabled. Dithering mode is used to specify the way that ANSImage render ANSI-pixels (char/block elements).
func NewScaledFromReader ¶
func NewScaledFromReader(reader io.Reader, y, x int, bg color.Color, sm ScaleMode, dm DitheringMode) (*ANSImage, error)
NewScaledFromReader creates a new scaled ANSImage from an io.Reader. Background color is used to fill when image has transparency or dithering mode is enabled. Dithering mode is used to specify the way that ANSImage render ANSI-pixels (char/block elements).
func NewScaledFromURL ¶
func NewScaledFromURL(url string, y, x int, bg color.Color, sm ScaleMode, dm DitheringMode) (*ANSImage, error)
NewScaledFromURL creates a new scaled ANSImage from an image URL. Background color is used to fill when image has transparency or dithering mode is enabled. Dithering mode is used to specify the way that ANSImage render ANSI-pixels (char/block elements).
func (*ANSImage) DitheringMode ¶
func (ai *ANSImage) DitheringMode() DitheringMode
DitheringMode gets the dithering mode of ANSImage.
func (*ANSImage) Draw ¶
func (ai *ANSImage) Draw()
Draw writes the ANSImage to standard output (terminal).
func (*ANSImage) DrawExt ¶
DrawExt writes the ANSImage to standard output (terminal). Can specify if it prints in form of Go code 'fmt.Printf()'. Can specify if background color will be disabled in dithering mode.
func (*ANSImage) GetMaxProcs ¶
GetMaxProcs gets the maximum number of parallels goroutines to render the ANSImage.
func (*ANSImage) RenderExt ¶
RenderExt returns the ANSI-compatible string form of ANSImage. Can specify if it renders in form of Go code 'fmt.Printf()'. Can specify if background color will be disabled in dithering mode. (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).
type ANSIpixel ¶
ANSIpixel represents a pixel of an ANSImage.
type DitheringMode ¶
type DitheringMode uint8
DitheringMode type is used for image scale dithering mode constants.