ansimage

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: AGPL-3.0, MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package ansimage is a simplified version of the ansimage package in https://github.com/eliukblau/pixterm focused in rendering images to a tcell-based TUI app.

   ___  _____  ____
  / _ \/  _/ |/_/ /____ ______ _
 / ___// /_>  </ __/ -_) __/  ' \
/_/  /___/_/|_|\__/\__/_/ /_/_/_/

This package is licensed under the Mozilla Public License v2.0.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHeightNonMoT happens when ANSImage height is not a Multiple of Two value.
	ErrHeightNonMoT = errors.New("ANSImage: height must be a Multiple of Two value")

	// ErrInvalidBoundsMoT happens when ANSImage height or width are invalid values (Multiple of Two).
	ErrInvalidBoundsMoT = 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

This section is empty.

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, bg color.Color) (*ANSImage, error)

New creates a new empty ANSImage ready to draw on it.

func NewFromFile

func NewFromFile(name string, bg color.Color) (*ANSImage, error)

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 NewFromReader

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

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 NewScaledFromFile

func NewScaledFromFile(name string, y, x int, bg color.Color) (*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 NewScaledFromReader

func NewScaledFromReader(reader io.Reader, y, x int, bg color.Color) (*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 (*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) Pixmap

func (ai *ANSImage) Pixmap() [][]*ANSIpixel

func (*ANSImage) Render

func (ai *ANSImage) Render() []tstring.TString

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, brightness uint8) error

SetAt sets ANSI-pixel color (RBG) and brightness 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 {
	Brightness uint8
	R, G, B    uint8
	// contains filtered or unexported fields
}

ANSIpixel represents a pixel of an ANSImage.

Jump to

Keyboard shortcuts

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