render

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 15 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ITermImageSupported

func ITermImageSupported() bool

ITermImageSupported ...

func KittySupported added in v1.1.0

func KittySupported() bool

KittySupported checks if the terminal supports Kitty Graphics Protocol. Supported terminals: Kitty, WezTerm, Ghostty

func SixelSupported

func SixelSupported() bool

SixelSupported ...

Types

type CellGrid

type CellGrid struct {

	// Border is a border printer.
	Border border.Border
	// Colorpicker is an algorithm to pickup colors.
	Colorpicker color.Picker

	// Row of cell grid, the terminal height by default if the image is portrait.
	Row uint16
	// Col of cell grid, the terminal width by default if the image is landscape.
	Col uint16

	// Placeholder is a text printed in the cell, " " by default,
	// ignored in debug mode because color number will be printed instead.
	Placeholder string

	// Debug given, print available color tables
	// and print calculated color number inside the cell.
	// Debug is exclusive property, any other properties might be ignored.
	Debug bool

	// HalfBlock enables half-block character mode for 2x vertical resolution.
	// Uses "▀" character with foreground (top) and background (bottom) colors.
	HalfBlock bool

	// TrueColor enables 24-bit RGB colors instead of 256-color palette.
	TrueColor bool
}

CellGrid ...

func (*CellGrid) Fprint

func (grid *CellGrid) Fprint(w io.Writer, code int)

Fprint prints a cell with 256-color palette background.

func (*CellGrid) FprintHalfBlock added in v1.1.0

func (grid *CellGrid) FprintHalfBlock(w io.Writer, topR, topG, topB, botR, botG, botB uint32)

FprintHalfBlock prints a half-block character with top (foreground) and bottom (background) colors. This effectively renders 2 vertical pixels per terminal cell.

func (*CellGrid) FprintTrueColor added in v1.1.0

func (grid *CellGrid) FprintTrueColor(w io.Writer, r, g, b uint32)

FprintTrueColor prints a cell with 24-bit RGB background.

func (*CellGrid) Render

func (grid *CellGrid) Render(w io.Writer, img image.Image) error

Render renders specified image by using cell.

func (*CellGrid) SetScale

func (grid *CellGrid) SetScale(scale float64) error

SetScale ...

type ITerm

type ITerm struct {
	// Scale size
	Scale float64
}

ITerm renderer to support image printing on iTerm. See https://www.iterm2.com/documentation-images.html

func (*ITerm) Render

func (iterm *ITerm) Render(w io.Writer, img image.Image) error

Render renders specified image to iTerm stdout.

func (*ITerm) SetScale

func (iterm *ITerm) SetScale(scale float64) error

SetScale ...

type Kitty added in v1.1.0

type Kitty struct {
	// Scale size
	Scale float64
}

Kitty renderer to support image printing using Kitty Graphics Protocol. See https://sw.kovidgoyal.net/kitty/graphics-protocol/

func (*Kitty) Render added in v1.1.0

func (k *Kitty) Render(w io.Writer, img image.Image) error

Render renders specified image using Kitty Graphics Protocol.

func (*Kitty) SetScale added in v1.1.0

func (k *Kitty) SetScale(scale float64) error

SetScale sets the scale for the renderer.

type Renderer

type Renderer interface {
	Render(io.Writer, image.Image) error
	SetScale(float64) error
}

Renderer interface.

func GetDefaultRenderer

func GetDefaultRenderer() Renderer

GetDefaultRenderer provides an applicable renderer for current platform.

type Sixel

type Sixel struct {
	Scale float64
}

Sixel ... See https://github.com/saitoha/libsixel

func (*Sixel) Render

func (sxl *Sixel) Render(w io.Writer, img image.Image) error

Render renders specified image to iTerm stdout.

func (*Sixel) SetScale

func (sxl *Sixel) SetScale(scale float64) error

SetScale ...

Jump to

Keyboard shortcuts

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