render

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package render turns a Chromium screencast into terminal image frames. It is intentionally smaller than termcast: the image occupies rows 2..N so the address bar can stay on row 1.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoGraphics = errors.New("terminal has no graphics support")

ErrNoGraphics means the terminal has no Kitty/iTerm2/Sixel encoder.

Functions

func ImageID

func ImageID(img image.Image) string

ImageID is a stable hex id for diagnostics (not used in the wire protocol yet). Keeping it here makes frame logs deterministic when debugging.

Types

type Config

type Config struct {
	FPS     float64
	Quality int
	Width   int
	Height  int
	Cols    int
	Rows    int
	Encoder rasterm.Encoder
	// KittyGraphics says the pane's terminal answered the kitty graphics
	// probe. The kitty encoder is then used even when the environment does
	// not name a kitty-capable terminal.
	KittyGraphics bool
}

Config controls the screencast.

type ImageWriter added in v0.2.11

type ImageWriter struct {
	// contains filtered or unexported fields
}

ImageWriter shares the pane encoders with a remote session surface without launching Chromium or retaining a CDP connection.

func NewImageWriter added in v0.2.11

func NewImageWriter(cols, rows int, kitty bool) (*ImageWriter, error)

func (*ImageWriter) Draw added in v0.2.11

func (w *ImageWriter) Draw(out io.Writer, img image.Image) error

type Stats added in v0.2.0

type Stats struct {
	Received    uint64
	Acked       uint64
	Decoded     uint64
	Dropped     uint64
	Published   uint64
	DecodeTotal time.Duration
	DecodeLast  time.Duration
	Drawn       uint64
	WireBytes   uint64
	DrawTotal   time.Duration
	DrawLast    time.Duration
}

Stats is a snapshot of the screencast pipeline counters. Dropped includes raw frames superseded before decoding, filtered frames, and decoded frames superseded before the consumer received them.

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream is a running CDP screencast. Frames contains the latest decoded viewport; the consumer can drop frames it cannot draw yet.

func Start

func Start(ctx context.Context, cfg Config) (*Stream, error)

Start begins a screencast and starts Chromium if the context has none.

func (*Stream) Clear added in v0.2.0

func (s *Stream) Clear(w io.Writer) error

Clear removes only this browser's Kitty image, for mode changes and exit. Normal frame updates must never call Clear.

func (*Stream) Draw

func (s *Stream) Draw(w io.Writer, img image.Image) error

Draw replaces the page image in place. Do not delete the old placement first: the host must keep displaying it while the next frame is being transmitted.

func (*Stream) Err

func (s *Stream) Err() error

Err returns the first transport/decode error.

func (*Stream) Frames

func (s *Stream) Frames() <-chan image.Image

Frames returns latest-frame notifications. It is never closed; stop by cancelling the context and calling Stop.

func (*Stream) LastFrame

func (s *Stream) LastFrame() time.Time

LastFrame reports when the last changed screencast frame arrived. Repeated frames caused by screenshot capture do not count as fresh page activity.

func (*Stream) SetCellSize added in v0.2.0

func (s *Stream) SetCellSize(cols, rows int)

SetCellSize updates the terminal-cell extent of the image placement. It is independent of the raster dimensions, so custom-size screenshots still fill the pane exactly. Custom encoders and non-Kitty fallbacks are unaffected.

func (*Stream) SetViewportSize added in v0.2.0

func (s *Stream) SetViewportSize(width, height int)

SetViewportSize updates the expected pane viewport after a resize. Chromium can emit intermediate surfaces during resize and full-page screenshots; those must never temporarily replace the visible pane with a scaled sliver.

func (*Stream) Stats added in v0.2.0

func (s *Stream) Stats() Stats

Stats returns a race-free snapshot of pipeline activity.

func (*Stream) Still

func (s *Stream) Still(ctx context.Context) (image.Image, error)

Still captures a lossless PNG of the current viewport. It is used after the page has been idle, where JPEG ringing makes small text look soft.

func (*Stream) Stop

func (s *Stream) Stop()

Stop stops the screencast. It is safe to call more than once.

Jump to

Keyboard shortcuts

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