video

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 8 Imported by: ? 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 video draws streaming images (video, camera, remote screens) with Video, from a paint.Stream (in giokit's Gio fork).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fit

type Fit uint8

Fit is how a video frame fills its area.

const (
	FitContain Fit = iota // whole frame, aspect kept, bars where it does not fill
	FitCover              // fill the area, aspect kept, edges cropped
	FitFill               // fill the area, aspect ignored
	FitNone               // 1:1 pixels, centered, cropped if larger
)

type State

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

State records where the last layout put the frame, for mapping pointer positions and overlays. The zero value maps nothing until the first layout with a frame. It holds no resources and may be copied.

func (*State) Content

func (st *State) Content() image.Rectangle

Content is where the frame was drawn, in the widget's pixel coordinates. It extends past the widget for FitCover and an oversized FitNone.

func (*State) Frame

func (st *State) Frame() image.Point

Frame is the frame size at the last layout; zero before the first frame.

func (*State) FromFrame

func (st *State) FromFrame(q f32.Point) f32.Point

FromFrame converts frame pixels to widget pixels: where to draw an overlay that should sit on a spot in the video.

func (*State) ToFrame

func (st *State) ToFrame(p f32.Point) (f32.Point, bool)

ToFrame converts a point in the widget (pixels, as pointer events report it) to frame pixels. ok is false outside the visible frame, such as in FitContain's bars.

type Video

type Video struct {
	ID     string        // the image area's id
	Stream *paint.Stream // the frames; nil draws nothing
	Fit    Fit           // how a frame fills the area; FitContain is the zero value
	Label  string        // what the video shows, for screen readers; default th.Strings.Video
}

Video draws a paint.Stream: video, a camera, a remote screen. It fills its constraints and draws the newest frame scaled by Fit; it handles no input. Wrap it to add some, and use the state's mapping to convert between window and frame coordinates.

video.Video{ID: "screen", Stream: s, Label: "Tablet screen"}.Layout(gtx, th, &v.screen)

Before the first frame it draws nothing. To redraw on new frames, set the stream's OnFrame to invalidate the window (kit.App.Invalidate).

Video only reads the stream; its producer owns it. When the source ends, the producer calls Stream.Close, which releases the retained frame and refuses later ones; Video then draws nothing. Close does not call OnFrame, so invalidate the window yourself if the video is on screen.

func (Video) Layout

func (v Video) Layout(gtx layout.Context, th *kit.Theme, st *State) layout.Dimensions

Layout draws the stream's current frame, filling the constraints, and records its placement in st. A nil Stream draws nothing.

Jump to

Keyboard shortcuts

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