cameraview

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cameraview puts a live camera inside your screen, with your own buttons over it. For a photo with no design of your own, the camera plugin is simpler: it opens the system's camera and needs no permission.

nimbus native plugin add camera-view

if ok, _ := cameraview.Request(ctx); ok {
	setShow(true)
}

cameraview.View{Style: ui.Style{Grow: 1}, OnReady: ready}

photo, err := cameraview.Take(ctx, cameraview.Options{MaxSize: 1600})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Request

func Request(ctx context.Context) (bool, error)

Request asks to use the camera, once.

Types

type Options

type Options struct {
	MaxSize int     `json:"maxSize"` // its longer side, in pixels; 0 keeps it full size
	Quality float32 `json:"quality"` // JPEG, 0 to 1; 0 means 0.85
}

Options say how to take a photo.

type Photo

type Photo struct {
	Data   []byte `json:"data"`   // the JPEG
	Width  int    `json:"width"`  // in pixels
	Height int    `json:"height"` // in pixels
}

Photo is a JPEG, turned the right way up.

func Take

func Take(ctx context.Context, o Options) (Photo, error)

Take takes a photo with the View on screen. With no View, or before OnReady, it fails with plugin.Unavailable.

type View

type View struct {
	Front   bool              // the camera on the screen's side
	Torch   bool              // the light; back camera only
	OnReady func()            // the picture has started
	OnError func(code string) // plugin.Denied or plugin.Unavailable: no permission, or no camera
	Style   ui.Style          // its size and place on the screen
}

View is the live picture. Show one at a time.

func (View) Render

func (v View) Render(c *ui.Ctx) ui.Component

Render shows the camera.

Jump to

Keyboard shortcuts

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