Source File
graphics.go
Belonging Package
github.com/charmbracelet/x/ansi
package ansiimport ()// SixelGraphics returns a sequence that encodes the given sixel image payload to// a DCS sixel sequence.//// DCS p1; p2; p3; q [sixel payload] ST//// p1 = pixel aspect ratio, deprecated and replaced by pixel metrics in the payload//// p2 = This is supposed to be 0 for transparency, but terminals don't seem to// to use it properly. Value 0 leaves an unsightly black bar on all terminals// I've tried and looks correct with value 1.//// p3 = Horizontal grid size parameter. Everyone ignores this and uses a fixed grid// size, as far as I can tell.//// See https://shuford.invisible-island.net/all_about_sixels.txtfunc (, , int, []byte) string {var bytes.Buffer.WriteString("\x1bP")if >= 0 {.WriteString(strconv.Itoa())}.WriteByte(';')if >= 0 {.WriteString(strconv.Itoa())}if > 0 {.WriteByte(';').WriteString(strconv.Itoa())}.WriteByte('q').Write().WriteString("\x1b\\")return .String()}// KittyGraphics returns a sequence that encodes the given image in the Kitty// graphics protocol.//// APC G [comma separated options] ; [base64 encoded payload] ST//// See https://sw.kovidgoyal.net/kitty/graphics-protocol/func ( []byte, ...string) string {var bytes.Buffer.WriteString("\x1b_G").WriteString(strings.Join(, ","))if len() > 0 {.WriteString(";").Write()}.WriteString("\x1b\\")return .String()}
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64)