Documentation
¶
Index ¶
- Constants
- func ClampToByte(v float64) int
- func GrayFromRGB(r, g, b uint8) uint8
- func Luminance(r, g, b uint8) float64
- type BlockHandler
- type BlockSample
- type Cell
- type Color
- type Frame
- func EncodeFull(img *PreparedImage, cols, rows int) *Frame
- func EncodeFullColor(img *PreparedImage, cols, rows int) *Frame
- func EncodeFullGray(img *PreparedImage, cols, rows int) *Frame
- func EncodeHalf(img *PreparedImage, cols, rows int) *Frame
- func EncodeHalfColor(img *PreparedImage, cols, rows int) *Frame
- func EncodeHalfGray(img *PreparedImage, cols, rows int) *Frame
- func EncodeOne(img *PreparedImage, cols, rows int) *Frame
- func EncodeOneColor(img *PreparedImage, cols, rows int) *Frame
- func EncodeOneGray(img *PreparedImage, cols, rows int) *Frame
- func EncodeQuarter(img *PreparedImage, cols, rows int) *Frame
- func EncodeQuarterColor(img *PreparedImage, cols, rows int) *Frame
- func EncodeQuarterGray(img *PreparedImage, cols, rows int) *Frame
- func NewFrame(cols, rows int) *Frame
- type GrayBuffer
- type PaletteIndex
- type PreparedImage
Constants ¶
const ( BlockSize2 = 2 BlockSize4 = 4 BlockSize8 = 8 )
Variables ¶
This section is empty.
Functions ¶
func ClampToByte ¶
ClampToByte rounds and clamps a float into 0..255.
func GrayFromRGB ¶
GrayFromRGB converts RGB to an 8-bit grayscale value.
Types ¶
type BlockHandler ¶
type BlockHandler interface {
BeginBlock(col, row int)
AddSample(sample BlockSample)
Result() (glyph rune, fg, bg *Color)
}
BlockHandler consumes samples for each block to produce a glyph and optional colors.
type BlockSample ¶
type BlockSample struct {
Gray uint8
R uint8
G uint8
B uint8
X int // relative column inside the block (0..blockW-1)
Y int // relative row inside the block (0..blockH-1)
}
BlockSample represents a single pixel sampled within a block.
type Cell ¶
type Cell struct {
Glyph rune
FG PaletteIndex
BG PaletteIndex
}
Cell хранит глиф и ссылки на цвета палитры.
type Frame ¶
Frame — двумерная сетка терминальных ячеек с общей палитрой.
func EncodeFull ¶
func EncodeFull(img *PreparedImage, cols, rows int) *Frame
EncodeFull renders full 4×8 monochrome blocks using the extended glyph palette.
func EncodeFullColor ¶
func EncodeFullColor(img *PreparedImage, cols, rows int) *Frame
EncodeFullColor renders the image using ANSI colors and the extended glyph set for 4x8 blocks.
func EncodeFullGray ¶
func EncodeFullGray(img *PreparedImage, cols, rows int) *Frame
EncodeFullGray renders the image using ANSI colors and a glyph set defined for 4x8 blocks.
func EncodeHalf ¶
func EncodeHalf(img *PreparedImage, cols, rows int) *Frame
EncodeHalf renders monochrome output using upper/lower half block glyphs.
func EncodeHalfColor ¶
func EncodeHalfColor(img *PreparedImage, cols, rows int) *Frame
EncodeHalfColor renders the image using ANSI tinted spaces/▀ to represent two stacked color pixels.
func EncodeHalfGray ¶
func EncodeHalfGray(img *PreparedImage, cols, rows int) *Frame
EncodeHalfGray renders the image using ANSI tinted spaces/▀ to represent two stacked grayscale pixels.
func EncodeOne ¶
func EncodeOne(img *PreparedImage, cols, rows int) *Frame
EncodeOne renders two stacked monochrome pixels using solid/blank glyphs.
func EncodeOneColor ¶
func EncodeOneColor(img *PreparedImage, cols, rows int) *Frame
EncodeOneColor renders the image as ANSI tinted spaces representing the original pixel colors.
func EncodeOneGray ¶
func EncodeOneGray(img *PreparedImage, cols, rows int) *Frame
EncodeOneGray renders the image as ANSI tinted spaces representing grayscale pixels.
func EncodeQuarter ¶
func EncodeQuarter(img *PreparedImage, cols, rows int) *Frame
EncodeQuarter renders monochrome quarter blocks (2×2 pixels per terminal cell).
func EncodeQuarterColor ¶
func EncodeQuarterColor(img *PreparedImage, cols, rows int) *Frame
EncodeQuarterColor renders the image using ANSI colors and a limited quarter-block glyph set.
func EncodeQuarterGray ¶
func EncodeQuarterGray(img *PreparedImage, cols, rows int) *Frame
EncodeQuarterGray renders the image using ANSI colors and a limited quarter-block glyph set.
func (*Frame) PaletteColor ¶
func (f *Frame) PaletteColor(idx PaletteIndex) (Color, bool)
PaletteColor ищет цвет по индексу палитры.
type GrayBuffer ¶
type GrayBuffer struct {
Pix []uint8
Width int
Height int
// contains filtered or unexported fields
}
GrayBuffer contains a grayscale copy of an image for quick random access.
func (*GrayBuffer) Index ¶
func (g *GrayBuffer) Index(x, y int) uint8
Index returns the grayscale value at absolute coordinates with bounds checking.
func (*GrayBuffer) Release ¶
func (g *GrayBuffer) Release()
Release returns the underlying memory to the pool.
type PaletteIndex ¶
type PaletteIndex uint16
PaletteIndex identifies цвет в палитре кадра.
const ( // PaletteIndexNone означает отсутствие цвета (фон/передний план). PaletteIndexNone PaletteIndex = 0 )
type PreparedImage ¶
PreparedImage хранит изображение в формате 4 байта на пиксель (NRGBA или RGBA).
func PrepareImage ¶
func PrepareImage(img image.Image, cols, rows int, mode string) *PreparedImage
PrepareImage масштабирует и приводит входное изображение к нужному режиму.