widget

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultProgressOptions = ProgressOptions{
	Font:       fontutil.RobotoBold,
	FontSize:   24,
	Fill:       color.White,
	Color:      color.NRGBA{R: 0x7f, G: 0x7f, B: 0xff, A: 0xff},
	Background: image.Transparent,
}

Functions

This section is empty.

Types

type Base

type Base struct {
	ConnectedTo DrawablePeripheral
	Effects     Effects
	// contains filtered or unexported fields
}

Base widget

func MakeBase

func MakeBase(peripheral DrawablePeripheral, effects ...Effect) Base

func (*Base) Drawable

func (w *Base) Drawable() benjamin.Drawable

func (*Base) Frame

func (w *Base) Frame(i *image.NRGBA, t time.Time) *image.NRGBA

func (*Base) IsUpdated

func (w *Base) IsUpdated(t time.Time) bool

func (*Base) Peripheral

func (w *Base) Peripheral() benjamin.Peripheral

type DrawablePeripheral

type DrawablePeripheral interface {
	benjamin.Drawable
	benjamin.Peripheral
}

type Effect

type Effect interface {
	UpdateChecker

	Apply(*image.NRGBA, time.Time) *image.NRGBA
}

Effect on a Widget.

type Effects

type Effects []Effect

Effects are zero or more Effects.

func (Effects) Apply

func (fxs Effects) Apply(i *image.NRGBA, t time.Time) *image.NRGBA

func (Effects) IsUpdated

func (fxs Effects) IsUpdated(t time.Time) bool

type Image

type Image struct {
	Base
	Image *image.NRGBA
}

Image widget, can be used for keys or displays.

func ButtonIcon

func ButtonIcon(key benjamin.Button, i image.Image, effects ...Effect) *Image

func (*Image) Frame

func (w *Image) Frame(t time.Time) *image.NRGBA

func (*Image) IsUpdated

func (w *Image) IsUpdated(t time.Time) bool

func (*Image) Set

func (w *Image) Set(i image.Image)

type Progress

type Progress struct {
	Base
	Value float64
	// contains filtered or unexported fields
}

func NewProgress

func NewProgress(p DrawablePeripheral, opts *ProgressOptions, effects ...Effect) *Progress

func (*Progress) Frame

func (w *Progress) Frame(t time.Time) *image.NRGBA

func (*Progress) IsUpdated

func (w *Progress) IsUpdated(t time.Time) bool

func (*Progress) Set

func (w *Progress) Set(value float64)

func (*Progress) SetBackground

func (w *Progress) SetBackground(i image.Image)

func (*Progress) SetColor

func (w *Progress) SetColor(c color.Color)

func (*Progress) SetFill

func (w *Progress) SetFill(c color.Color)

type ProgressOptions

type ProgressOptions struct {
	Label      string
	Font       *truetype.Font
	FontSize   float64
	Fill       color.Color
	Color      color.Color
	Background image.Image
	Icon       image.Image
}

func (*ProgressOptions) Defaults

func (o *ProgressOptions) Defaults()

type Rotate

type Rotate struct {
	// Speed in degrees per second
	Speed      float64
	Background color.Color
	// contains filtered or unexported fields
}

func (*Rotate) Apply

func (fx *Rotate) Apply(i *image.NRGBA, t time.Time) *image.NRGBA

func (*Rotate) IsUpdated

func (fx *Rotate) IsUpdated(t time.Time) bool

type UpdateChecker

type UpdateChecker interface {
	IsUpdated(t time.Time) bool
}

type Widget

type Widget interface {
	UpdateChecker

	// Drawable returns the underlying Peripheral.
	Drawable() benjamin.Drawable

	// Frame is the Widget image at time.
	Frame(time.Time) *image.NRGBA
}

Jump to

Keyboard shortcuts

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