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 ¶
- Variables
- func ImageID(img image.Image) string
- type Config
- type ImageWriter
- type Stats
- type Stream
- func (s *Stream) Clear(w io.Writer) error
- func (s *Stream) Draw(w io.Writer, img image.Image) error
- func (s *Stream) Err() error
- func (s *Stream) Frames() <-chan image.Image
- func (s *Stream) LastFrame() time.Time
- func (s *Stream) SetCellSize(cols, rows int)
- func (s *Stream) SetViewportSize(width, height int)
- func (s *Stream) Stats() Stats
- func (s *Stream) Still(ctx context.Context) (image.Image, error)
- func (s *Stream) Stop()
Constants ¶
This section is empty.
Variables ¶
var ErrNoGraphics = errors.New("terminal has no graphics support")
ErrNoGraphics means the terminal has no Kitty/iTerm2/Sixel encoder.
Functions ¶
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)
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 (*Stream) Clear ¶ added in v0.2.0
Clear removes only this browser's Kitty image, for mode changes and exit. Normal frame updates must never call Clear.
func (*Stream) Draw ¶
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) Frames ¶
Frames returns latest-frame notifications. It is never closed; stop by cancelling the context and calling Stop.
func (*Stream) LastFrame ¶
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
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
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.