art

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package art downloads cover images and turns them into terminal text. It supports two ways to draw an image:

  • Kitty graphics with Unicode placeholders. The image is sent to the terminal once, and the screen shows it through special placeholder characters. This gives a sharp image in kitty, Ghostty, and terminals that copy their protocol.
  • Half blocks. Each cell shows two pixels with the "▀" character, colored with the top pixel in front and the bottom pixel behind. This works in any terminal with true color.

Index

Constants

View Source
const QueryID = 31

QueryID is the image id of the support query.

Variables

This section is empty.

Functions

func Blocks

func Blocks(img image.Image, cols, rows int) string

Blocks draws img in a cols×rows cell box with half blocks. The image keeps its aspect ratio, and the unused part of the box stays empty.

func Fetch

func Fetch(ctx context.Context, client *http.Client, url string) (image.Image, error)

Fetch downloads and decodes the image at url.

func KittyDelete

func KittyDelete(id int) string

KittyDelete returns the escape sequence that frees image id in the terminal.

func KittyPlaceholder

func KittyPlaceholder(id, cols, rows int) string

KittyPlaceholder returns the text that shows image id in a cols×rows cell box. The foreground color carries the image id, and two diacritics on each cell carry its row and column. id must be from 16 to 255.

func KittyQuery

func KittyQuery() string

KittyQuery returns a sequence that asks the terminal whether it supports kitty graphics. A terminal with support answers with image id QueryID and the payload "OK". Other terminals ignore it.

func KittyTransmit

func KittyTransmit(img image.Image, id, cols, rows int) (string, error)

KittyTransmit returns the escape sequence that sends img to the terminal as image id, with a virtual placement of cols×rows cells. Show the image with KittyPlaceholder.

func PlaceholdersUnsupported

func PlaceholdersUnsupported() bool

PlaceholdersUnsupported reports whether the environment shows a terminal that answers the kitty query but cannot show Unicode placeholders.

Types

type Mode

type Mode int

Mode is how images are drawn.

const (
	ModeOff Mode = iota
	ModeBlocks
	ModeKitty
)

func (Mode) String

func (m Mode) String() string

Jump to

Keyboard shortcuts

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