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
- func Blocks(img image.Image, cols, rows int) string
- func Fetch(ctx context.Context, client *http.Client, url string) (image.Image, error)
- func KittyDelete(id int) string
- func KittyPlaceholder(id, cols, rows int) string
- func KittyQuery() string
- func KittyTransmit(img image.Image, id, cols, rows int) (string, error)
- func PlaceholdersUnsupported() bool
- type Mode
Constants ¶
const QueryID = 31
QueryID is the image id of the support query.
Variables ¶
This section is empty.
Functions ¶
func Blocks ¶
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 KittyDelete ¶
KittyDelete returns the escape sequence that frees image id in the terminal.
func KittyPlaceholder ¶
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 ¶
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.