image

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Animate

func Animate(app *view.Application)

Animate triggers the application to redraw every 50ms

func FromFile

func FromFile(filename string) (encoded string, err error)

FromFile is a convenience function that converts a file on disk to a formatted string. See FromImage() for more details.

func FromImage

func FromImage(img image.Image) (encoded string, err error)

FromImage is the primary function of this package, It takes an image.Image and converts it to a string formatted for view. The unicode half-block character (▀) with a fg & bg colour set will represent pixels in the returned string. Because each character represents two pixels, it is not possible to convert an image if its height is uneven. Attempts to do so will return an error.

func FromReader

func FromReader(reader io.Reader) (encoded string, err error)

FromReader is a convenience function that converts an io.Reader to a formatted string. See FromImage() for more details.

Types

type GifView

type GifView struct {
	sync.Mutex
	*view.Box
	// contains filtered or unexported fields
}

GifView is a box which displays animated gifs via Omnikron13's pixelview dynamic color rendering. It automatically draws the right frame based on time elapsed since creation. You can trigger re-drawing by executing Animate(view.Application) in a goroutine.

func GifFromImage

func GifFromImage(img *gif.GIF) (*GifView, error)

GifFromImage creates a new GifView from a GIF Image

func GifFromImagePath

func GifFromImagePath(imgPath string) (*GifView, error)

GifFromImagePath creates a new GifView from a file on disk

func NewGifView

func NewGifView() *GifView

NewGifView returns a new GifView.

func (*GifView) Draw

func (g *GifView) Draw(screen tcell.Screen)

Draw renders the current frame of the GIF

func (*GifView) GetCurrentFrame

func (g *GifView) GetCurrentFrame() int

GetCurrentFrame returns the current frame the GIF is on

func (*GifView) SetImage

func (g *GifView) SetImage(img *gif.GIF) (*GifView, error)

SetImage sets the content to a given gif.GIF

func (*GifView) SetImagePath

func (g *GifView) SetImagePath(imgPath string) (*GifView, error)

SetImagePath sets the image to a given GIF path

Jump to

Keyboard shortcuts

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