common

package
v0.0.0-...-5a58481 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegisteredComponents = map[string]func() Component{}
)

Functions

func RegisterComponent

func RegisterComponent(name string, comp func() Component)

Types

type Axis

type Axis struct {
	Length       int
	Max          int
	TemplateSize int
	Position     int
	Space        int
}

type BaseComponent

type BaseComponent struct {
	SizeX         string `xml:"size-x,attr"`
	SizeY         string `xml:"size-y,attr"`
	ComputedSizeX int
	ComputedSizeY int
	ParentWidth   int
	ParentHeight  int
	PosX          int `xml:"pos-x,attr"`
	PosY          int `xml:"pos-y,attr"`

	Ctx *gg.Context

	Ticker *time.Ticker
	Rr     int // render rate in milliseconds
	// contains filtered or unexported fields
}

func (*BaseComponent) Height

func (bc *BaseComponent) Height() int

func (*BaseComponent) Init

func (bc *BaseComponent) Init()

func (*BaseComponent) PrevImg

func (bc *BaseComponent) PrevImg() image.Image

func (*BaseComponent) SetParentSize

func (bc *BaseComponent) SetParentSize(width int, height int)

func (*BaseComponent) SetPrevImg

func (bc *BaseComponent) SetPrevImg(img image.Image)

func (*BaseComponent) Size

func (bc *BaseComponent) Size() image.Point

func (*BaseComponent) Stop

func (bc *BaseComponent) Stop()

func (*BaseComponent) TickerChan

func (bc *BaseComponent) TickerChan() <-chan time.Time

func (*BaseComponent) Width

func (bc *BaseComponent) Width() int

type Component

type Component interface {
	Init()                               // Ran before componenet is rendered
	Render() image.Image                 // Render the component to an image.Image representation
	Width() int                          // Return the width of the component. Used to help position components on the display
	Height() int                         // Return the height of the compoent. Used to help position components on the display
	PrevImg() image.Image                // return the previously rendered image
	SetPrevImg(img image.Image)          // the the previously rendered iamge
	TickerChan() <-chan time.Time        // return the channel for the ticker
	Stop()                               // Stop the ticker
	SetParentSize(width int, height int) // set the parent's size to use in calculations
}

type ComponentContext

type ComponentContext struct {
	CacheDir string
}

type Template

type Template struct {
	BaseComponent

	XMLName xml.Name `xml:"template"`

	Align      string      `xml:"align,attr"`
	Justify    string      `xml:"justify,attr"`
	Direction  string      `xml:"dir,attr"`
	BgColor    string      `xml:"bg-color,attr"`
	Components []Component `xml:",any"`
}

func (*Template) Init

func (t *Template) Init()

func (*Template) Ready

func (t *Template) Ready() bool

func (*Template) Render

func (t *Template) Render() image.Image

func (*Template) Stop

func (t *Template) Stop()

func (*Template) UnmarshalXML

func (tmpl *Template) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

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