Documentation ¶
Index ¶
- type Image
- func (i *Image) Draw(screen tcell.Screen)
- func (i *Image) Focus(delegate func(p tview.Primitive))
- func (i *Image) GetFieldHeight() int
- func (i *Image) GetFieldWidth() int
- func (i *Image) GetLabel() string
- func (i *Image) SetDisabled(disabled bool) tview.FormItem
- func (i *Image) SetFinishedFunc(handler func(key tcell.Key)) tview.FormItem
- func (i *Image) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) tview.FormItem
- func (i *Image) SetImage(image image.Image) *Image
- func (i *Image) SetSize(rows, columns int) *Image
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Image ¶
Image implements a widget that displays one image. The original image (specified with Image.SetImage) is resized according to the specified size (see Image.SetSize), using the specified number of colors (see [Image.SetColors]), while applying dithering if necessary (see [Image.SetDithering]).
Images are approximated by graphical characters in the terminal. The resolution is therefore limited by the number and type of characters that can be drawn in the terminal and the colors available in the terminal. The quality of the final image also depends on the terminal's font and spacing settings, none of which are under the control of this package. Results may vary.
func NewImage ¶
func NewImage() *Image
NewImage returns a new image widget with an empty image (use Image.SetImage to specify the image to be displayed). The image will use the widget's entire available space. The dithering algorithm is set to Floyd-Steinberg dithering. The terminal's cell aspect ratio defaults to 0.5.
func (*Image) Draw ¶
func (i *Image) Draw(screen tcell.Screen)
Draw draws this primitive onto the screen.
func (*Image) GetFieldHeight ¶
GetFieldHeight returns this primitive's field height. This is the image's height or 8 if the height is 0 or less.
func (*Image) GetFieldWidth ¶
GetFieldWidth returns this primitive's field width. This is the image's width or, if the width is 0 or less, the proportional width of the image based on its height as returned by Image.GetFieldHeight. If there is no image, 0 is returned.
func (*Image) SetDisabled ¶
SetDisabled sets whether or not the item is disabled / read-only.
func (*Image) SetFinishedFunc ¶
SetFinishedFunc sets a callback invoked when the user leaves this form item.
func (*Image) SetFormAttributes ¶
func (i *Image) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) tview.FormItem
SetFormAttributes sets a number of item attributes at once.
func (*Image) SetSize ¶
SetSize sets the size of the image. Positive values refer to cells in the terminal. Negative values refer to a percentage of the available space (e.g. -50 means 50%). A value of 0 means that the corresponding size is chosen automatically based on the other size while preserving the image's aspect ratio. If both are 0, the image uses as much space as possible while still preserving the aspect ratio.