gifview

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

gifview

Go Report Card Go Docs

Animated GIFs for TView-based TUIs (powered by pixelview)

demo

Usage

There are two ways to create a new GifView:

// From an existing gif.GIF object
gifImg := &gif.GIF{}
img, err := gifview.FromImage(gifImg)

// From a file path
gifPath := "images/dancing-baby.gif"
img, err := gifview.FromImagePath(gifPath)

Once you have one or more GifViews, they will animate whenever the application re-draws. You can force that to happen on a regular basis by using the Animate function.

app := tview.NewApplication()
go gifview.Animate(app)

Based on

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Animate

func Animate(app *tview.Application)

Animate triggers the application to redraw every 50ms

Types

type GifView

type GifView struct {
	sync.Mutex
	*tview.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(tview.Application) in a goroutine.

func FromImage

func FromImage(image *gif.GIF) (*GifView, error)

FromImage creates a new GifView from a GIF Image

func FromImagePath

func FromImagePath(imagePath string) (*GifView, error)

FromImagePath 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(image *gif.GIF) (*GifView, error)

SetImage sets the content to a given gif.GIF

func (*GifView) SetImagePath

func (g *GifView) SetImagePath(imagePath 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