ledgrid

package module
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 40 Imported by: 8

README

LedGrid - Controlling NeoPixels with Go

The package ledgrid contains a number of functions and types, which allows you to control a chain of NeoPixels, lets you draw shapes, images and custom patterns and provides you with methods and types to animate most of your stuff. Beside the library itself, this package also contains the following command line tools and examples:

  • cmd/anim: A collection of almost all visual effects, animations, shapes, etc. this package has to offer. The frontend is a fairly simple interactive command line tool.
  • cmd/colorEdit: A ncurses application which lets you play with the NeoPixels interactively. It gives you direct access to the RGB-values of all LEDs and provides you with a small set of functions, like creating a gradient between two given LEDs.
  • cmd/gridController: A daemon process which runs on the remote system the NeoPixels are connected to.
  • cmd/gridEmulator: A GUI tool which lets you develop animations without the need of the NeoPixel hardware.

Documentation

Index

Constants

View Source
const (
	DefDataPort = 5333
	DefRPCPort  = 5332
)
View Source
const (
	RedChain = iota
	YellowChain
	GreenChain
	CyanChain
	BlueChain
	MagentaChain
	WhiteChain
	NumColorModes
)
View Source
const (
	// Fuer Animationen, die endlos wiederholt weren sollen, kann diese Konstante
	// fuer die Anzahl Wiederholungen verwendet werden.
	AnimationRepeatForever = -1
)
View Source
const (
	NumLayers = 5
)

Variables

View Source
var (
	CirclePath    = NewGeomPath(circlePathFunc, 0, 1)
	LinearPath    = NewGeomPath(linearPathFunc, 0, 1)
	RectanglePath = NewGeomPath(rectPathFunc, 0, 1)
)
View Source
var (
	// Die Animationskurven, welche auf quadratischen und kubischen Parabeln
	// basieren, sind bereits vorgefertigt.
	AnimationEaseIn     = NewAnimationCurve(genericIn, 2.0)
	AnimationEaseOut    = NewAnimationCurve(genericOut, 2.0)
	AnimationEaseInOut  = NewAnimationCurve(genericInOut, 2.0)
	AnimationCubicIn    = NewAnimationCurve(genericIn, 3.0)
	AnimationCubicOut   = NewAnimationCurve(genericOut, 3.0)
	AnimationCubicInOut = NewAnimationCurve(genericInOut, 3.0)
)
View Source
var (
	// Alle vorhandenen Paletten sind in diesem Slice aufgefuehrt. Falls
	// applikatorisch weitere Paletten erzeugt werden, ist es Aufgabe der
	// Applikation, diesen Slice nachzufuehren.
	PaletteNames = []string{}
	// Im Gegensatz zu [PaletteList] sind hier die Paletten unter ihrem
	// Namen abgelegt. Siehe auch Kommentar bei [PaletteList] betr.
	// Nachfuehrung.
	PaletteMap = map[string]ColorSource{}

	ColorNames = []string{}
	ColorMap   = map[string]*UniformPalette{}
)
View Source
var Fixed5x7 = &basicfont.Face{
	Advance: 6,
	Width:   5,
	Height:  9,
	Ascent:  7,
	Descent: 0,
	Mask:    maskFixed5x7,
	Ranges:  glyphRangeFull,
}
View Source
var Lightdot6x8 = &basicfont.Face{
	Advance: 7,
	Width:   6,
	Height:  9,
	Ascent:  8,
	Descent: 0,
	Mask:    maskLightdot6x8,
	Ranges: []basicfont.Range{
		{'\u0030', '\u003a', 0},
	},
}
View Source
var Lightdot8x8 = &basicfont.Face{
	Advance: 9,
	Width:   8,
	Height:  9,
	Ascent:  8,
	Descent: 0,
	Mask:    maskLightdot8x8,
	Ranges: []basicfont.Range{
		{'\u0030', '\u003a', 0},
	},
}
View Source
var Pico3x5 = &basicfont.Face{
	Advance: 4,
	Width:   3,
	Height:  8,
	Ascent:  5,
	Descent: 0,
	Mask:    maskPico3x5,
	Ranges:  glyphRangeFull,
}
View Source
var Pico6x10 = &basicfont.Face{
	Advance: 8,
	Width:   6,
	Height:  16,
	Ascent:  10,
	Descent: 0,
	Mask:    maskPico6x10,
	Ranges:  glyphRangeFull,
}
View Source
var Pico9x15 = &basicfont.Face{
	Advance: 12,
	Width:   9,
	Height:  24,
	Ascent:  15,
	Descent: 0,
	Mask:    maskPico9x15,
	Ranges:  glyphRangeFull,
}

Functions

func AnimationLinear added in v1.3.0

func AnimationLinear(t float64) float64

Linearer Verlauf zwischen 0.0 und 1.0.

func ApplyAlpha added in v1.3.0

func ApplyAlpha(c colors.LedColor) colors.LedColor

func Decode added in v1.4.1

func Decode(r io.Reader) (image.Image, error)

func DecodeConfig added in v1.4.1

func DecodeConfig(r io.Reader) (image.Config, error)

func InitGradientPalettes added in v1.4.1

func InitGradientPalettes(fileName string)

func InitUniformPalettes added in v1.4.1

func InitUniformPalettes()

func LoadImage added in v1.4.1

func LoadImage(fileName string) draw.Image

func ScaleFixedFont added in v1.4.1

func ScaleFixedFont(face *basicfont.Face, factor int, newName string)

This function can be used to produce a new fixed font by scaling an existing fixed font. Scaling factors can only be positive integers. The new font is

Types

type Align added in v1.4.1

type Align int

Die folgenden Typen, Structs (embeddable), Konstanten, etc. sind fuer das Ausrichten von Textbloecken in vertikaler und horizontaler Richtung vorgesehen.

const (
	AlignLeft Align = 1 << iota
	AlignCenter
	AlignRight
	AlignBottom
	AlignMiddle
	AlignTop
)

type AlignEmbed added in v1.4.1

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

Jeder Typ, der eine horizontale und vertikale Ausrichtung kennt oder anbieten will, kann den Typ alignEmbed einbetten. Damit erhaelt er zwei Fliesskomma-Variablen (ax und ay), welche ueber die Methode SetAlign gesetzt werden koennen und folgede Bedeutung haben: ax: 0.0: x-Pos des Objektes bezieht sich auf seinen linken Rand

0.5: x-Pos des Objektes bezieht sich auf Mitte (horizontal)
1.0: x-Pos des Objektes bezieht sich auf seinen rechten Rand

ay: 0.0: y-Pos des Objektes bezieht sich auf seinen unteren Rand

0.5: y-Pos des Objektes bezieht sich auf Mitte (vertikal)
1.0: y-Pos des Objektes bezieht sich auf seinen oberen Rand

(ax und ay nehmen also in math. korrekter Richtung zu)

func (*AlignEmbed) SetAlign added in v1.4.1

func (a *AlignEmbed) SetAlign(align Align)

Setzt die Ausrichtung auf den in align kodierten Wert. Sowohl x- als auch y-Ausrichtung koennen damit gesetzt werden. Falls bei einer Ausrichtung mehrere Werte angegeben wurden (bspw. AlignLeft | AlignCenter), so wird fuer diese Ausrichtung keinen neuen Wert gesetzt.

type AngleEmbed added in v1.4.1

type AngleEmbed struct {
	Angle float64
}

func (*AngleEmbed) AnglePtr added in v1.4.1

func (e *AngleEmbed) AnglePtr() *float64

type AnimColors added in v1.4.1

type AnimColors interface {
	colors.LedColor
}

AnimColors enthaelt bloss einen Datentyp fuer animierbare Farben.

type AnimNumbers added in v1.4.1

type AnimNumbers interface {
	~float64 | ~uint8 | ~int
}

Dies sind die animierbaren skalaren Datentypen.

type AnimPoints added in v1.4.1

type AnimPoints interface {
	geom.Point | image.Point | fixed.Point26_6
}

AnimPoints sind die animierbaren 2D-Vektoren von denen es 3 Typen gibt.

type AnimValue added in v1.4.1

type AnimValue interface {
	AnimNumbers | AnimPoints | AnimColors
}

AnimValue schliesslich ist der Zusammenschluss aller animierbaren Typen.

type AnimValueFunc added in v1.4.1

type AnimValueFunc[T AnimValue] func() T

Die eigentliche Arbeit erbringen Funktionen vom Typ AnimValueFunc, welche ohne Parameter aufgerufen werden und als Rueckgabewert einen Wert des Typs AnimValue haben.

func Const added in v1.4.1

func Const[T AnimValue](v T) AnimValueFunc[T]

Nicht alles muss immer animiert werden, soll sich aber dem Interface moeglichst anpassen. Dazu kann mit der Funktion Const eine AnimValueFunc erzeugt werden, die bei jedem Aufruf den selben Wert zurueckliefert.

func RandAlpha added in v1.3.0

func RandAlpha(a, b uint8) AnimValueFunc[uint8]

Liefert eine zufaellig gewaehlte natuerliche Zahl im Interval [a,b).

func RandColor added in v1.4.1

func RandColor(new bool) AnimValueFunc[colors.LedColor]

func RandFloat added in v1.3.0

func RandFloat(a, b float64) AnimValueFunc[float64]

Liefert eine zufaellig gewaehlte Fliesskommazahl im Interval [a,b).

func RandGroupColor added in v1.4.1

func RandGroupColor(group colors.ColorGroup, new bool) AnimValueFunc[colors.LedColor]

func RandPoint added in v1.3.0

func RandPoint(r geom.Rectangle) AnimValueFunc[geom.Point]

Liefert bei jedem Aufruf einen zufaellig gewaehlten Punkt innerhalb des Rechtecks r.

func RandPointTrunc added in v1.3.0

func RandPointTrunc(r geom.Rectangle, t float64) AnimValueFunc[geom.Point]

Wie RandPoint, sorgt jedoch dafuer dass die Koordinaten auf ein Vielfaches von t abgeschnitten werden.

func RandSize added in v1.3.0

func RandSize(s1, s2 geom.Point) AnimValueFunc[geom.Point]

Macht eine Interpolation zwischen den Groessen s1 und s2. Der Interpolations- punkt wird zufaellig gewaehlt.

type Animation added in v1.1.0

type Animation interface {
	Job
	Suspend()
	Continue()
	Update(t time.Time) bool
}

Animationen schliesslich sind Jobs, koennen also gestoppt und gestartet werden, haben jedoch zusaetzlich klare Laufzeiten und werden periodisch durch den AnimationController aufgerufen, damit sie ihren Animations-Kram erledigen koennen. Man kann sie ausserdem Suspendieren und Fortsetzen.

type AnimationController added in v1.3.0

type AnimationController struct {
	AnimList []Animation
	// contains filtered or unexported fields
}

Das Herzstueck der ganzen Animationen ist der AnimationController. Er sorgt dafuer, dass alle 30 ms (siehe Variable refreshRate) die Update-Methoden aller Animationen aufgerufen werden und veranlasst im Anschluss, dass alle darstellbaren Objekte neu gezeichnet werden und sendet das Bild schliesslich dem PixelController (oder dem PixelEmulator).

var (
	// Weil es nur einen (1) Animations-Kontroller geben kann, ist in diesem
	// Package eine globale Variable dafuer vorgesehen.
	AnimCtrl *AnimationController
)

func NewAnimationController added in v1.3.0

func NewAnimationController(syncChan chan bool) *AnimationController

func (*AnimationController) Add added in v1.3.0

func (a *AnimationController) Add(anims ...Animation)

Fuegt weitere Animationen hinzu. Der Zugriff auf den entsprechenden Slice wird synchronisiert, da die Bearbeitung der Animationen durch den Background-Thread ebenfalls relativ haeufig auf den Slice zugreift.

func (*AnimationController) Continue added in v1.3.0

func (a *AnimationController) Continue()

Setzt die Animationen wieder fort. TO DO: Die Fortsetzung sollte fuer eine:n Beobachter:in nahtlos erfolgen. Im Moment tut es das nicht - man muesste sich bei den Methoden und Ideen von AnimationEmbed bedienen.

func (*AnimationController) Del added in v1.3.0

func (a *AnimationController) Del(anim Animation)

Loescht eine einzelne Animation.

func (*AnimationController) DelAt added in v1.4.0

func (a *AnimationController) DelAt(idx int)

func (*AnimationController) IsRunning added in v1.4.1

func (a *AnimationController) IsRunning() bool

func (*AnimationController) Now added in v1.4.0

func (a *AnimationController) Now() time.Time

func (*AnimationController) Purge added in v1.3.0

func (a *AnimationController) Purge()

Loescht alle Animationen.

func (*AnimationController) Stopwatch added in v1.4.2

func (a *AnimationController) Stopwatch() *Stopwatch

func (*AnimationController) Suspend added in v1.4.1

func (a *AnimationController) Suspend()

Mit Suspend koennen die Animationen und die Darstellung auf der Hardware unterbunden werden.

type AnimationCurve added in v1.1.0

type AnimationCurve func(t float64) float64

Mit dem Funktionstyp AnimationCurve kann der Verlauf einer Animation beeinflusst werden. Der Parameter [t] ist ein Wert im Intervall [0,1] und zeigt an, wo sich die Animation gerade befindet (t=0: Animation wurde eben gestartet; t=1: Animation ist zu Ende). Der Rueckgabewert ist ebenfalls ein Wert im Intervall [0,1] und hat die gleiche Bedeutung wie [t].

func NewAnimationCurve added in v1.4.2

func NewAnimationCurve(fnc genericCurve, a float64) AnimationCurve

Mit dieser Methode schliesslich, werden konkrete Animationskurven erstellt. Der erste Parameter bezeichnet eine der generischen Funktionen und mit dem Parameter a wird der gewuenschte Exponent fix hinterlegt. Das Resultat ist eine Funktion des Typs AnimationCurve, der im Feld [Curve] einer Animation hinterlegt werden kann.

type BLM added in v1.4.1

type BLM struct {
	Image     []*image.RGBA
	Delay     []int
	LoopCount int
	Config    image.Config
}

Der Typ BLM und die gleich danach definierten Methoden/Funktionen sind nach Vorbild 'image/gif' implementiert und koennen zum Laden von BlinkenLight-Animationen verwendet werden.

func DecodeAll added in v1.4.1

func DecodeAll(r io.Reader) (*BLM, error)

type BlinkenFile added in v1.1.0

type BlinkenFile struct {
	XMLName  xml.Name       `xml:"blm"`
	Width    int            `xml:"width,attr"`
	Height   int            `xml:"height,attr"`
	Bits     int            `xml:"bits,attr"`
	Channels int            `xml:"channels,attr"`
	Header   BlinkenHeader  `xml:"header"`
	Frames   []BlinkenFrame `xml:"frame"`
}

Fuer die Einbindung von Animationen im BlinkenLight-Format sind hier erst mal die Typen für die Verarbeitung der XML-Dateien.

func ReadBlinkenFile added in v1.1.0

func ReadBlinkenFile(fileName string) *BlinkenFile

Mit folgender Funktion wird eine Datei im BlinkenLight-Format eingelesen. Die Bilddaten werden dabei noch nicht decodiert, d.h. noch nicht in ein 'image'-Format umgewandelt (siehe dazu auch die Methode Decode).

func (*BlinkenFile) Decode added in v1.3.0

func (b *BlinkenFile) Decode(idx int) draw.Image

Hier schliesslich werden die Bilddaten des Frames mit Index idx decodiert und als image.RGBA-Struktur zurückgegeben.

func (*BlinkenFile) Duration added in v1.3.0

func (b *BlinkenFile) Duration(idx int) time.Duration

Retourniert die Anzeigedauer des Frames mit Index idx. Für eine Aufsummierung der Anzeigewerte zur Berechnung der Anzeigedauer der gesamten Bildfolge ist ein aufrufendes Programm verantwortlich.

func (*BlinkenFile) NumFrames added in v1.3.0

func (b *BlinkenFile) NumFrames() int

Retourniert die Anzahl Frames in der BlinkenLight-Animation.

func (*BlinkenFile) SetAllDuration added in v1.4.0

func (b *BlinkenFile) SetAllDuration(durMs int)

type BlinkenFrame added in v1.1.0

type BlinkenFrame struct {
	XMLName  xml.Name  `xml:"frame"`
	Duration int       `xml:"duration,attr"`
	Rows     [][]byte  `xml:"row"`
	Values   [][]uint8 `xml:"-"`
}

type BlinkenHeader added in v1.1.0

type BlinkenHeader struct {
	XMLName  xml.Name `xml:"header"`
	Title    string   `xml:"title"`
	Author   string   `xml:"author"`
	Email    string   `xml:"email"`
	Creator  string   `xml:"creator"`
	Duration int      `xml:"duration,omitempty"`
}

type ByteCount added in v1.4.1

type ByteCount int64

Der Datentyp ByteCount kann zum Zaehlen von Bytes verwendet werden (bspw. bei Netzwerk- oder Datei-IO). Die Ausgabe als Text wird formatiert. So werden 1024 als '1.0 kB' oder 4096 als '4.0 kB' dargestellt.

func (ByteCount) String added in v1.4.1

func (b ByteCount) String() string

type Canvas added in v1.3.0

type Canvas struct {
	ObjList   *list.List
	BackColor colors.LedColor
	Rect      image.Rectangle
	Img       draw.Image
	GC        *gg.Context
	Mask      image.Image
	// contains filtered or unexported fields
}

Ein Canvas ist eine animierbare Zeichenflaeche. Ihr koennen eine beliebige Anzahl von zeichenbaren Objekten (Interface CanvasObject) hinzugefuegt werden.

func NewCanvas added in v1.3.0

func NewCanvas(size image.Point) *Canvas

func (*Canvas) Add added in v1.3.0

func (c *Canvas) Add(objs ...CanvasObject)

Fuegt der Zeichenflaeche weitere Objekte hinzu. Der Zufgriff auf den entsprechenden Slice wird nicht synchronisiert.

func (*Canvas) At added in v1.4.1

func (c *Canvas) At(x, y int) color.Color

func (*Canvas) Bounds added in v1.4.0

func (c *Canvas) Bounds() image.Rectangle

func (*Canvas) Clear added in v1.4.1

func (c *Canvas) Clear(col colors.LedColor)

func (*Canvas) Close added in v1.3.0

func (c *Canvas) Close()

func (*Canvas) ColorModel added in v1.4.1

func (c *Canvas) ColorModel() color.Model

The following methods implement the image.Image (resp. draw.Image) interface. A Canvas object can therefore be used as the destination as well as the source for all kind of drawings.

func (*Canvas) Del added in v1.4.1

func (c *Canvas) Del(obj CanvasObject)

Loescht ein einzelnes Objekt von der Zeichenflaeche.

func (*Canvas) Purge added in v1.3.0

func (c *Canvas) Purge()

Loescht alle Objekte von der Zeichenflaeche.

func (*Canvas) Refresh added in v1.4.1

func (c *Canvas) Refresh()

func (*Canvas) Reset added in v1.4.1

func (c *Canvas) Reset()

Loescht alle Objekte aus der Zeichenflaeche, setzt die Farbe des Canvas auf c.BackColor und setzt die Maske zurueck auf Volltransparent.

func (*Canvas) Set added in v1.4.1

func (c *Canvas) Set(x, y int, col color.Color)

func (*Canvas) Stopwatch added in v1.4.2

func (c *Canvas) Stopwatch() *Stopwatch

type CanvasObject added in v1.3.0

type CanvasObject interface {
	Show()
	Hide()
	IsVisible() bool
	Draw(c *Canvas)
}

Alle Objekte, die durch den Controller auf dem LED-Grid dargestellt werden sollen, muessen das CanvasObject-Interface implementieren. Dieses enthaelt einerseits Methoden zum Ein-/Ausblenden von Objekten und andererseits die Methode Draw, mit welcher das CanvasObject auf einer Zeichenflaeche gezeichnet werden kann.

type CanvasObjectEmbed added in v1.3.0

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

Wie bei den Animationen gibt es für die darstellbaren Objekte (CanvasObject) ein entsprechendes Embedable, welche die für die meisten Objekte brauchbaren Methoden enthält.

func (*CanvasObjectEmbed) Extend added in v1.4.0

func (c *CanvasObjectEmbed) Extend(wrapper CanvasObject)

func (*CanvasObjectEmbed) Hide added in v1.3.0

func (c *CanvasObjectEmbed) Hide()

func (*CanvasObjectEmbed) IsVisible added in v1.4.1

func (c *CanvasObjectEmbed) IsVisible() bool

func (*CanvasObjectEmbed) Show added in v1.3.0

func (c *CanvasObjectEmbed) Show()

type ColorAnimation added in v1.3.0

type ColorAnimation struct {
	GenericAnimation[colors.LedColor]
}

Animation fuer einen Verlauf zwischen zwei Farben.

func NewColorAnim added in v1.4.1

func NewColorAnim(obj Colorable, val2 colors.LedColor, dur time.Duration) *ColorAnimation

func NewFillColorAnim added in v1.4.1

func NewFillColorAnim(obj ColorFillable, val2 colors.LedColor, dur time.Duration) *ColorAnimation

func (*ColorAnimation) Tick added in v1.3.0

func (a *ColorAnimation) Tick(t float64)

type ColorEmbed added in v1.4.1

type ColorEmbed struct {
	Color colors.LedColor
}

func (*ColorEmbed) ColorPtr added in v1.4.1

func (e *ColorEmbed) ColorPtr() *colors.LedColor

type ColorFillable added in v1.4.1

type ColorFillable interface {
	Colorable
	FillColorPtr() *colors.LedColor
}

type ColorFunc added in v1.4.0

type ColorFunc func(colors.LedColor) colors.LedColor

type ColorShaderAnim added in v1.4.1

type ColorShaderAnim struct {
	ValPtr    *colors.LedColor
	X, Y, Z   float64
	Idx, NPix int
	Fnc       ColorShaderFunc
	// contains filtered or unexported fields
}

func NewColorShaderAnim added in v1.4.1

func NewColorShaderAnim(obj Colorable, x, y, z float64, idx, nPix int, fnc ColorShaderFunc) *ColorShaderAnim

func (*ColorShaderAnim) Continue added in v1.4.1

func (a *ColorShaderAnim) Continue()

Setzt die Ausfuehrung der Animation fort.

func (*ColorShaderAnim) Duration added in v1.4.1

func (a *ColorShaderAnim) Duration() time.Duration

func (*ColorShaderAnim) IsRunning added in v1.4.1

func (a *ColorShaderAnim) IsRunning() bool

Liefert den Status der Animation zurueck.

func (*ColorShaderAnim) SetDuration added in v1.4.1

func (a *ColorShaderAnim) SetDuration(d time.Duration)

func (*ColorShaderAnim) Start added in v1.4.1

func (a *ColorShaderAnim) Start()

func (*ColorShaderAnim) StartAt added in v1.4.1

func (a *ColorShaderAnim) StartAt(t time.Time)

Startet die Animation.

func (*ColorShaderAnim) Suspend added in v1.4.1

func (a *ColorShaderAnim) Suspend()

Unterbricht die Ausfuehrung der Animation.

func (*ColorShaderAnim) Update added in v1.4.1

func (a *ColorShaderAnim) Update(t time.Time) bool

type ColorShaderFunc added in v1.4.1

type ColorShaderFunc func(t, x, y, z float64, idx, nPix int) colors.LedColor

type ColorSource added in v1.1.0

type ColorSource interface {
	// Liefert in Abhaengigkeit des Parameters v eine Farbe aus der Palette
	// zurueck. v kann vielfaeltig verwendet, resp. interpretiert werden,
	// bsp. als Parameter im Intervall [0,1], als Index (natuerliche Zahl)
	// einer Farbenliste oder gar nicht, wenn die Farbquelle einfarbig ist.
	Color(v float64) colors.LedColor
	// Da alle Paletten noch einen Namen haben, der bspw. in einem GUI- oder
	// TUI-Element dargestellt werden kann, existiert diese Methode.
	Name() string
}

Alles, was im Sinne einer Farbpalette Farben erzeugen kann, implementiert das ColorSource Interface.

type ColorStop added in v1.1.0

type ColorStop struct {
	Pos   float64
	Color colors.LedColor
}

Dieser (interne) Typ wird verwendet, um einen bestimmten Wert im Interval [0,1] mit einer Farbe zu assoziieren.

type Colorable added in v1.4.1

type Colorable interface {
	ColorPtr() *colors.LedColor
}

type Delay added in v1.4.1

type Delay struct {
	NormAnimationEmbed
}

Ein Delay kann als ganz normale Animation ueberall dort eingefuegt werden, wo ein unmittelbares Fortfahren der Animationen nicht gewuenscht ist und wo der Einsatz der Timeline zu aufwaendig ist.

func NewDelay added in v1.4.1

func NewDelay(d time.Duration) *Delay

func (*Delay) Init added in v1.4.1

func (a *Delay) Init()

func (*Delay) Tick added in v1.4.1

func (a *Delay) Tick(t float64)

type DirectGridClient added in v1.4.2

type DirectGridClient struct {
	Disp Displayer
	// contains filtered or unexported fields
}

func (*DirectGridClient) Close added in v1.4.2

func (c *DirectGridClient) Close()

func (*DirectGridClient) Gamma added in v1.4.2

func (c *DirectGridClient) Gamma() (r, g, b float64)

func (*DirectGridClient) ModuleConfig added in v1.4.2

func (c *DirectGridClient) ModuleConfig() conf.ModuleConfig

func (*DirectGridClient) NumLeds added in v1.4.2

func (c *DirectGridClient) NumLeds() int

func (*DirectGridClient) Send added in v1.4.2

func (c *DirectGridClient) Send(buffer []byte)

func (*DirectGridClient) SetGamma added in v1.4.2

func (c *DirectGridClient) SetGamma(r, g, b float64)

func (*DirectGridClient) Stopwatch added in v1.4.2

func (c *DirectGridClient) Stopwatch() *Stopwatch

type DisplayEmbed added in v1.4.1

type DisplayEmbed struct {
	ModConf conf.ModuleConfig
	// contains filtered or unexported fields
}

Each implementation of a Displayer should embed this embeddable. It provides default implementations for a number of general methods.

func (*DisplayEmbed) Bounds added in v1.4.1

func (d *DisplayEmbed) Bounds() image.Rectangle

See Bounds in interface Displayer.

func (*DisplayEmbed) Display added in v1.4.1

func (d *DisplayEmbed) Display(buffer []byte)

See Display in interface Displayer.

func (*DisplayEmbed) Gamma added in v1.4.1

func (d *DisplayEmbed) Gamma() (r, g, b float64)

See Gamma in interface Displayer.

func (*DisplayEmbed) Init added in v1.4.1

func (d *DisplayEmbed) Init(impl Displayer, numLeds int)

An embedding type needs to call this method once in order to set initial values correctly.

func (*DisplayEmbed) ModuleConfig added in v1.4.1

func (d *DisplayEmbed) ModuleConfig() conf.ModuleConfig

See ModuleConfig in interface Displayer.

func (*DisplayEmbed) NumLeds added in v1.4.1

func (d *DisplayEmbed) NumLeds() int

See NumLeds in interface Displayer.

func (*DisplayEmbed) SetGamma added in v1.4.1

func (d *DisplayEmbed) SetGamma(r, g, b float64)

See SetGamma in interface Displayer.

func (*DisplayEmbed) SetModuleConfig added in v1.4.1

func (d *DisplayEmbed) SetModuleConfig(cnf conf.ModuleConfig)

See SetModuleConfig in interface Displayer.

func (*DisplayEmbed) SetPixelStatus added in v1.4.1

func (d *DisplayEmbed) SetPixelStatus(idx int, stat LedStatusType)

See SetPixelStatus in interface Displayer.

type Displayer added in v1.2.0

type Displayer interface {
	// Returns the number of addressable NeoPixels in this implementation.
	// Will be used by the Server to allocate memory for buffer.
	NumLeds() int
	// Returns a Rectangle enclosing the whole display. Because the
	// configuration of the modules allow empty space within this
	// rectangle, you cannot derive the number of NeoPixels from this value.
	Bounds() image.Rectangle
	// Returns the module configuration of this displayer.
	ModuleConfig() conf.ModuleConfig
	// Sets a new module configuration
	SetModuleConfig(cnf conf.ModuleConfig)
	// Sets the status of NeoPixel with index idx to stat.
	SetPixelStatus(idx int, stat LedStatusType)
	// Returns the gamma values that should be used by default on this
	// displayer.
	DefaultGamma() (r, g, b float64)
	// Returns the currently set values for the gamma correction
	Gamma() (r, g, b float64)
	// Set new values for the gamma correction.
	SetGamma(r, g, b float64)
	// Display is used by a Server to show the image data in buffer. The bytes
	// in buffer must already be in a suitable order for this specific device.
	// The order of RGB has to be in device order as well but the data hasn't
	// to be gamma corrected.
	Display(buffer []byte)
	// Send is called by Display and must not be called from other parts of
	// the software
	Send(buffer []byte)
	// Closes the connection to the displaying hardware and releases any
	// allocated ressources.
	Close()
}

The output device can be realized in several ways. For example a SPI bus with a chain of NeoPixels, driven by WS2801 - this for sure is the default. But think of development: there may be an emulation of this (quite expensive) hardware. Every"thing" which can be used as a display must implement this interface.

type Dot added in v1.4.0

Ein einzelnes Pixel, dessen Bewegungen weicher (smooth) animiert werden koennen, ist der Typ Dot. Da er grosse Aehnlichkeit zum Typ Pixel aufweist, werden auch hier die Koordinaten als Spalten-, resp. Zeilenindex interpretiert.

func NewDot added in v1.4.0

func NewDot(pos geom.Point, col colors.LedColor) *Dot

func (*Dot) Draw added in v1.4.0

func (d *Dot) Draw(c *Canvas)

type DurationEmbed added in v1.3.0

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

Haben Animationen eine Dauer, so koennen sie dieses Embeddable einbinden und erhalten somit die klassischen Methoden fuer das Setzen und Abfragen der Dauer.

func (*DurationEmbed) Duration added in v1.3.0

func (d *DurationEmbed) Duration() time.Duration

func (*DurationEmbed) SetDuration added in v1.3.0

func (d *DurationEmbed) SetDuration(dur time.Duration)

type Ellipse added in v1.3.0

Mit Ellipse sind alle kreisartigen Objekte abgedeckt. Pos bezeichnet die Position des Mittelpunktes und mit Size ist die Breite und Hoehe des gesamten Objektes gemeint. Falls ein Rand gezeichnet werden soll, muss BorderWith einen Wert >0 enthalten und FillColor, resp. BorderColor enthalten die Farben fuer Rand und Flaeche.

func NewEllipse added in v1.3.0

func NewEllipse(pos, size geom.Point, borderColor colors.LedColor) *Ellipse

Erzeugt eine 'klassische' Ellipse mit einer Randbreite von einem Pixel und setzt die Fuellfarbe gleich Randfarbe mit Alpha-Wert von 0.3. Will man die einzelnen Werte flexibler verwenden, empfiehlt sich die Erzeugung mittels &Ellipse{...}.

func (*Ellipse) Draw added in v1.3.0

func (e *Ellipse) Draw(c *Canvas)

type Fadable added in v1.4.1

type Fadable interface {
	AlphaPtr() *uint8
}

type FadeAnimation added in v1.4.1

type FadeAnimation struct {
	GenericAnimation[uint8]
}

func NewFadeAnim added in v1.4.1

func NewFadeAnim(obj Fadable, fade FadeType, dur time.Duration) *FadeAnimation

func (*FadeAnimation) Tick added in v1.4.1

func (a *FadeAnimation) Tick(t float64)

type FadeEmbed added in v1.4.1

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

func (*FadeEmbed) AlphaPtr added in v1.4.1

func (e *FadeEmbed) AlphaPtr() *uint8

func (*FadeEmbed) Init added in v1.4.1

func (e *FadeEmbed) Init(c *colors.LedColor)

type FadeTransition added in v1.4.1

type FadeTransition struct {
	NormAnimationEmbed
	// contains filtered or unexported fields
}

This is the simplest form of a transition: it will mask the whole canvas with the same alpha value. With it you can realize smooth fadings from one canvas to another.

func NewFadeTransition added in v1.4.1

func NewFadeTransition(c *Canvas, a0, a1 uint8, d time.Duration) *FadeTransition

Creates a new fade transition on canvas c, varying the alpha value of that canvas from a0 to a1 within duration d. For a transition to another canvas, you have to use a second fade transition on the other canvas, running from a1 to a0 within the same duration.

func (*FadeTransition) At added in v1.4.1

func (a *FadeTransition) At(x, y int) color.Color

func (*FadeTransition) Bounds added in v1.4.1

func (a *FadeTransition) Bounds() image.Rectangle

func (*FadeTransition) ColorModel added in v1.4.1

func (a *FadeTransition) ColorModel() color.Model

func (*FadeTransition) Init added in v1.4.1

func (a *FadeTransition) Init()

func (*FadeTransition) Tick added in v1.4.1

func (a *FadeTransition) Tick(t float64)

type FadeType added in v1.4.1

type FadeType int
const (
	FadeOut FadeType = 0x00
	FadeIn           = 0xff
)

type FileSaveClient added in v1.4.1

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

Dieser Client-Typ schreibt alle Bilddaten in eine Datei, welche im Anschluss auf ein System mit echter Hardware transferiert und dort wie ein Film abgespielt wird.

func (*FileSaveClient) Close added in v1.4.1

func (p *FileSaveClient) Close()

func (*FileSaveClient) Gamma added in v1.4.1

func (p *FileSaveClient) Gamma() (r, g, b float64)

func (*FileSaveClient) ModuleConfig added in v1.4.1

func (p *FileSaveClient) ModuleConfig() conf.ModuleConfig

func (*FileSaveClient) NumLeds added in v1.4.1

func (p *FileSaveClient) NumLeds() int

func (*FileSaveClient) Send added in v1.4.1

func (p *FileSaveClient) Send(buffer []byte)

func (*FileSaveClient) SetGamma added in v1.4.1

func (p *FileSaveClient) SetGamma(r, g, b float64)

func (*FileSaveClient) Stopwatch added in v1.4.2

func (p *FileSaveClient) Stopwatch() *Stopwatch

type FilledColorEmbed added in v1.4.1

type FilledColorEmbed struct {
	ColorEmbed
	FillColor colors.LedColor
}

func (*FilledColorEmbed) FillColorPtr added in v1.4.1

func (e *FilledColorEmbed) FillColorPtr() *colors.LedColor

type Filter added in v1.4.1

type Filter interface {
	ColorModel() color.Model
	Bounds() image.Rectangle
	At(x, y int) color.Color
	Set(x, y int, c color.Color)
	FF(x, y int) (int, int)
}

type FilterBase added in v1.4.1

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

func (*FilterBase) At added in v1.4.1

func (f *FilterBase) At(x, y int) color.Color

func (*FilterBase) Bounds added in v1.4.1

func (f *FilterBase) Bounds() image.Rectangle

func (*FilterBase) ColorModel added in v1.4.1

func (f *FilterBase) ColorModel() color.Model

func (*FilterBase) Extend added in v1.4.1

func (f *FilterBase) Extend(img draw.Image, flt FilterImpl)

func (*FilterBase) Set added in v1.4.1

func (f *FilterBase) Set(x, y int, col color.Color)

type FilterIdent added in v1.4.1

type FilterIdent struct {
	FilterBase
}

func NewFilterIdent added in v1.4.1

func NewFilterIdent(img draw.Image) *FilterIdent

func (*FilterIdent) FF added in v1.4.1

func (f *FilterIdent) FF(x, y int) (int, int)

type FilterImpl added in v1.4.1

type FilterImpl interface {
	FF(x, y int) (int, int)
}

type Fire added in v1.1.0

type Fire struct {
	CanvasObjectEmbed
	Pos, Size image.Point
	// contains filtered or unexported fields
}

func NewFire added in v1.1.0

func NewFire(pos, size image.Point) *Fire

func (*Fire) Continue added in v1.4.1

func (f *Fire) Continue()

func (*Fire) Draw added in v1.4.1

func (f *Fire) Draw(c *Canvas)

func (*Fire) Duration added in v1.4.1

func (f *Fire) Duration() time.Duration

func (*Fire) IsRunning added in v1.4.1

func (f *Fire) IsRunning() bool

func (*Fire) SetDuration added in v1.4.1

func (f *Fire) SetDuration(dur time.Duration)

func (*Fire) Start added in v1.4.1

func (f *Fire) Start()

func (*Fire) StartAt added in v1.4.1

func (f *Fire) StartAt(t time.Time)

func (*Fire) Stop added in v1.4.1

func (f *Fire) Stop()

func (*Fire) Suspend added in v1.4.1

func (f *Fire) Suspend()

func (*Fire) Update added in v1.1.0

func (f *Fire) Update(pit time.Time) bool

type FixedPosAnimation added in v1.3.0

type FixedPosAnimation struct {
	GenericAnimation[fixed.Point26_6]
}

func NewFixedPosAnim added in v1.4.1

func NewFixedPosAnim(obj FixedPositionable, val2 fixed.Point26_6, dur time.Duration) *FixedPosAnimation

func (*FixedPosAnimation) Tick added in v1.3.0

func (a *FixedPosAnimation) Tick(t float64)

type FixedPosEmbed added in v1.4.1

type FixedPosEmbed struct {
	Pos fixed.Point26_6
}

func (*FixedPosEmbed) PosPtr added in v1.4.1

func (e *FixedPosEmbed) PosPtr() *fixed.Point26_6

type FixedPositionable added in v1.4.1

type FixedPositionable interface {
	PosPtr() *fixed.Point26_6
}

Animation fuer eine Positionsveraenderung anhand des Fixed-Datentyps fixed/Point26_6. Dies wird insbesondere für die Positionierung von Schriften verwendet.

type FixedText added in v1.3.0

type FixedText struct {
	CanvasObjectEmbed
	AlignEmbed
	FixedPosEmbed
	ColorEmbed
	FadeEmbed
	// contains filtered or unexported fields
}

func NewFixedText added in v1.3.0

func NewFixedText(pos fixed.Point26_6, text string, col colors.LedColor) *FixedText

func (*FixedText) Draw added in v1.3.0

func (t *FixedText) Draw(c *Canvas)

func (*FixedText) SetAlign added in v1.4.1

func (t *FixedText) SetAlign(align Align)

func (*FixedText) SetFont added in v1.4.0

func (t *FixedText) SetFont(font font.Face)

func (*FixedText) SetText added in v1.3.0

func (t *FixedText) SetText(text string)

func (*FixedText) Size added in v1.4.2

func (t *FixedText) Size() fixed.Rectangle26_6

func (*FixedText) Text added in v1.3.0

func (t *FixedText) Text() string

type FloatAnimation added in v1.3.0

type FloatAnimation struct {
	GenericAnimation[float64]
}

Animation fuer einen Verlauf zwischen zwei Fliesskommazahlen. Kann fuer verschiedene konkrete Animationen verwendet werden.

func NewAngleAnim added in v1.4.1

func NewAngleAnim(obj Rotateable, val2 float64, dur time.Duration) *FloatAnimation

func NewStrokeWidthAnim added in v1.4.1

func NewStrokeWidthAnim(obj StrokeWidtheable, val2 float64, dur time.Duration) *FloatAnimation

func (*FloatAnimation) Tick added in v1.3.0

func (a *FloatAnimation) Tick(t float64)

type GammaArg added in v1.1.0

type GammaArg struct {
	RedVal, GreenVal, BlueVal float64
}

type GenericAnimation added in v1.4.1

type GenericAnimation[T AnimValue] struct {
	// NormAnimationEmbed wird eingebunden, um Methoden wie Start(), Suspend(),
	// Continue() nur einmal implementieren zu muessen.
	NormAnimationEmbed
	// ValPtr zeigt auf jenes Feld eines Objektes, welches durch diese
	// Animation veraendert werden soll. Die Animation kennt also den
	// Grund-Typ (Rectangle, Circle, Pixel, etc) nicht, sondern nur die zu
	// animierende Eigenschaft.
	ValPtr *T
	// Val1 und Val2 enthalten Funktionen, mit welchen der Start-, resp. End-
	// wert einer Animation zum Startzeitpunkt ermittelt werden. Damit lassen
	// sich die Animationen sehr dynamisch gestalten.
	Val1, Val2 AnimValueFunc[T]
	// Ist Cont (Continue) auf true, dann wird val1 zum Startzeitpunkt mit
	// dem aktuellen Wert hinter ValPtr belegt und nicht mit dem Funktionswert
	// aus Val1.
	Cont bool
	// contains filtered or unexported fields
}

Damit der Code zu den Animationen so knapp und uebersichtlich wie moeglich wird, ist ein Grossteil generisch implementiert. GenericAnimation wird als Grund-Typ von (nahezu) allen Animationen verwendet. Die Instanziierung erfolgt ueber einen der Datenypen, welche in AnimValue zusammengefasst sind.

func (*GenericAnimation[T]) Init added in v1.4.1

func (a *GenericAnimation[T]) Init()

func (*GenericAnimation[T]) InitAnim added in v1.4.1

func (a *GenericAnimation[T]) InitAnim(valPtr *T, val2 T, dur time.Duration)

type GeomPath added in v1.4.1

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

Geometrische Pfade heissen deshalb so, weil ihre Grundlage um Punkte zu bauen irgendwo in der Geometrie zu suchen ist.

func NewGeomPath added in v1.4.1

func NewGeomPath(fnc PathFunctionType, t0, l float64) *GeomPath

Alle geom. Pfade beruhen auf einer Pfad-Funktion (erster Parameter), der beim Erstellen eines Pfades zwingend angegeben werden muss. Mit t0 und l kann der Startpunkt, bzw. die Laenge der Animation im Vergleich zur gesamten Laenge von fnc bestimmt werden.

func (*GeomPath) NewStart added in v1.4.1

func (p *GeomPath) NewStart(t0 float64) *GeomPath

Baut aus dem geom. Pfad p einen neuen, indem der Anfangspunkt auf t0 verlegt wird.

func (*GeomPath) NewStartLen added in v1.4.1

func (p *GeomPath) NewStartLen(t0, l float64) *GeomPath

Baut aus dem geom. Pfad p einen neuen, indem der Anfangspunkt auf t0 und die totale Laenge des Pfades auf l gesetzt wird.

func (*GeomPath) Pos added in v1.4.1

func (p *GeomPath) Pos(t float64) geom.Point

Damit implementiert GeomPath das Interface Path... was die Absicht unseres ganzen Planes ist.

type GradientPalette added in v1.1.0

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

Gradienten-Paletten basieren auf einer Anzahl Farben (Stuetzstellen) zwischen denen eine Farbe interpoliert werden kann. Jede Stuetzstelle besteht aus einer Position (Zahl im Intervall [0,1]) und einer dazu gehoerenden Farbe.

func NewGradientPalette added in v1.1.0

func NewGradientPalette(name string, cl ...ColorStop) *GradientPalette

Erzeugt eine neue Palette unter Verwendung der Stuetzwerte in cl. Die Stuetzwerte muessen nicht sortiert sein. Per Default ist 0.0 mit Schwarz und 1.0 mit Weiss vorbelegt - sofern in cl keine Stuetzwerte fuer 0.0 und 1.0 angegeben sind.

func NewGradientPaletteByList added in v1.1.0

func NewGradientPaletteByList(name string, cycle bool, cl ...colors.LedColor) *GradientPalette

Erzeugt eine neue Gradienten-Palette unter Verwendung der Farben in cl, wobei die Farben aequidistant ueber das Interval [0,1] verteilt werden. Ist cycle true, dann wird die erste Farbe in cl auch als letzte Farbe verwendet.

func (*GradientPalette) Color added in v1.1.0

func (p *GradientPalette) Color(t float64) (c colors.LedColor)

Hier nun spielt die Musik: aufgrund des Wertes t (muss im Intervall [0,1] liegen) wird eine neue Farbe interpoliert.

func (*GradientPalette) ColorStops added in v1.1.0

func (p *GradientPalette) ColorStops() []ColorStop

Retourniert den Slice mit den Stutzwerten (wird wohl eher fuer Debugging verwendet).

func (*GradientPalette) Name added in v1.4.1

func (p *GradientPalette) Name() string

func (*GradientPalette) SetColorStop added in v1.1.0

func (p *GradientPalette) SetColorStop(colStop ColorStop)

Setzt in der Palette einen neuen Stuetzwert. Existiert bereits eine Farbe an dieser Position, wird sie ueberschrieben.

type GridClient added in v1.4.1

type GridClient interface {
	Send(buffer []byte)
	NumLeds() int
	Gamma() (r, g, b float64)
	SetGamma(r, g, b float64)
	ModuleConfig() conf.ModuleConfig
	Stopwatch() *Stopwatch
	Close()
}

Um den clientseitigen Code so generisch wie moeglich zu halten, ist der GridClient als Interface definiert. Aktuell stehen zwei Implementationen am Start:

	NetGridClient  - Verbindet sich via UDP und RPC mit einem externen
	                 gridController.
 FileSaveClient - Schreibt die Bilddaten in ein File, welches dann auf das
                  System mit dem Grid-Controller kopiert und dort direkt
                  abgespielt werden kann.

func NewDirectGridClient added in v1.4.2

func NewDirectGridClient(Disp Displayer) GridClient

func NewFileSaveClient added in v1.4.1

func NewFileSaveClient(fileName string, modConf conf.ModuleConfig) GridClient

func NewNetGridClient added in v1.4.1

func NewNetGridClient(host string, network string, port, rpcPort uint) GridClient

type GridServer added in v1.4.1

type GridServer struct {
	Disp                 Displayer
	RecvBytes, SentBytes ByteCount
	// contains filtered or unexported fields
}

Der GridServer wird auf jenem Geraet gestartet, an dem das LedGrid via SPI angeschlossen ist oder allenfalls der Emulator laeuft.

func NewGridServer added in v1.4.1

func NewGridServer(dataPort, rpcPort uint, disp Displayer) *GridServer

Damit wird eine neue Instanz eines GridServers erzeugt. Mit dataPort wird der Port sowohl fuer die UDP-, als auch fuer die TCP-Verbindung angegeben mit mit rpcPort der Port fuer die RPC-Calls. Mit disp wird dem Server ein konkretes, anzeigefaehiges Geraet (sog. Displayer) mitgegeben.

func (*GridServer) Close added in v1.4.1

func (p *GridServer) Close()

Schliesst die diversen Verbindungen.

func (*GridServer) Gamma added in v1.4.1

func (p *GridServer) Gamma() (r, g, b float64)

Retourniert die Gamma-Werte fuer die drei Farben.

func (*GridServer) HandleEvents added in v1.4.1

func (p *GridServer) HandleEvents()

func (*GridServer) HandleMessage added in v1.4.1

func (p *GridServer) HandleMessage(conn net.Conn)

Dies ist die zentrale Verarbeitungs-Funktion des GridServers. In ihr wird laufend ein Datenpaket via UDP empfangen und die empfangenen Werte auf ein Ausgabegeraet uebertragen (SPI-Bus, Emulation, etc.) Die genaue Konfiguration des LED-Grids (Anordnung der Lichterketten) ist dem GridServer nicht bekannt.

func (*GridServer) HandleTCP added in v1.4.1

func (p *GridServer) HandleTCP(lsnr *net.TCPListener)

Damit werden Meldungen via TCP empfangen und verarbeitet.

func (*GridServer) ModuleConfig added in v1.4.1

func (p *GridServer) ModuleConfig() conf.ModuleConfig

func (*GridServer) RPCGamma added in v1.4.1

func (p *GridServer) RPCGamma(arg int, reply *GammaArg) error

func (*GridServer) RPCModuleConfig added in v1.4.1

func (p *GridServer) RPCModuleConfig(arg int, reply *ModuleConfigArg) error

func (*GridServer) RPCNumLeds added in v1.4.1

func (p *GridServer) RPCNumLeds(arg int, reply *NumLedsArg) error

func (*GridServer) RPCSetGamma added in v1.4.1

func (p *GridServer) RPCSetGamma(arg GammaArg, reply *int) error

func (*GridServer) SetGamma added in v1.4.1

func (p *GridServer) SetGamma(r, g, b float64)

Setzt die Gamma-Werte fuer die Farben und aktualisiert die Mapping-Tabelle.

func (*GridServer) SetPixelStatus added in v1.4.1

func (p *GridServer) SetPixelStatus(idx int, stat LedStatusType)

func (*GridServer) Stopwatch added in v1.4.2

func (p *GridServer) Stopwatch() *Stopwatch

func (*GridServer) ToggleTestPattern added in v1.4.1

func (p *GridServer) ToggleTestPattern() bool

type Group added in v1.3.0

type Group struct {
	DurationEmbed
	// Gibt an, wie oft diese Gruppe wiederholt werden soll.
	RepeatCount int
	// Liste, der durch diese Gruppe gestarteten Tasks.
	Tasks []Task
	// contains filtered or unexported fields
}

Eine Gruppe dient dazu, eine Anzahl von Animationen gleichzeitig zu starten. Die Laufzeit der Gruppe ist gleich der laengsten Laufzeit ihrer Animationen oder einer festen Dauer (je nachdem, welche Dauer groesser ist). Die Animationen, welche ueber eine Gruppe gestartet werden, sollten keine Endlos-Animationen sein, da sonst die Laufzeit der Gruppe ebenfalls endlos wird.

func NewGroup added in v1.3.0

func NewGroup(tasks ...Task) *Group

Erstellt eine neue Gruppe, welche die Animationen in [anims] zusammen startet. Per Default ist die Laufzeit der Gruppe gleich der laengsten Laufzeit der hinzugefuegten Animationen.

func (*Group) Add added in v1.3.0

func (a *Group) Add(tasks ...Task)

Fuegt der Gruppe weitere Animationen hinzu.

func (*Group) Continue added in v1.4.0

func (a *Group) Continue()

Setzt die Ausfuehrung der Gruppe fort.

func (*Group) IsRunning added in v1.4.0

func (a *Group) IsRunning() bool

Liefert den Status der Gruppe zurueck.

func (*Group) Start added in v1.3.0

func (a *Group) Start()

func (*Group) StartAt added in v1.4.1

func (a *Group) StartAt(t time.Time)

Startet die Gruppe.

func (*Group) Suspend added in v1.4.1

func (a *Group) Suspend()

Unterbricht die Ausfuehrung der Gruppe.

func (*Group) Update added in v1.3.0

func (a *Group) Update(t time.Time) bool

type Image added in v1.1.0

Zur Darstellung von beliebigen Bildern (JPEG, PNG, etc). Wie Pos genau interpretiert wird, ist vom Alignment (wie beim Text) abhaengig. Size ist die Zielgroesse des Bildes auf dem LedGrid, ist per Default (0,0), was soviel wie "verwende Img.Bounds()" bedeutet. Andernfalls wird das Bild bei der Ausgabe entsprechend skaliert.

func NewImage added in v1.4.0

func NewImage(pos geom.Point, fileName string) *Image

Erzeugt ein neues Bild aus der Datei fileName und platziert es bei pos. Pos wird per Default als Koordinaten des Mittelpunktes interpretiert.

func (*Image) AlphaPtr added in v1.4.1

func (i *Image) AlphaPtr() *uint8

func (*Image) Draw added in v1.3.0

func (i *Image) Draw(c *Canvas)

func (*Image) Read added in v1.3.0

func (i *Image) Read(fileName string)

type IntAnimation added in v1.4.1

type IntAnimation struct {
	GenericAnimation[int]
}

func NewIntAnimation added in v1.4.1

func NewIntAnimation(valPtr *int, val2 int, dur time.Duration) *IntAnimation

func (*IntAnimation) Tick added in v1.4.1

func (a *IntAnimation) Tick(t float64)

type IntPosEmbed added in v1.4.1

type IntPosEmbed struct {
	Pos image.Point
}

func (*IntPosEmbed) PosPtr added in v1.4.1

func (e *IntPosEmbed) PosPtr() *image.Point

type IntegerPosAnimation added in v1.4.0

type IntegerPosAnimation struct {
	GenericAnimation[image.Point]
}

func NewIntegerPosAnim added in v1.4.1

func NewIntegerPosAnim(obj IntegerPositionable, val2 image.Point, dur time.Duration) *IntegerPosAnimation

func (*IntegerPosAnimation) Tick added in v1.4.0

func (a *IntegerPosAnimation) Tick(t float64)

type IntegerPositionable added in v1.4.1

type IntegerPositionable interface {
	PosPtr() *image.Point
}

type Job added in v1.4.0

type Job interface {
	Task
	IsRunning() bool
}

Ein Job besitzt alle Eigenschaften und Moeglichkeiten eines Tasks, bietet jedoch zusaetzlich die Moeglichkeit, von aussen bewusst gestoppt zu werden.

type JsonPalette added in v1.2.0

type JsonPalette struct {
	ID       int
	Name     string `json:"Title"`
	IsCyclic bool
	IsSlice  bool
	Colors   []colors.LedColor
	Stops    []ColorStop
}

func ReadJsonData added in v1.2.0

func ReadJsonData(fileName string) []JsonPalette

type LedGrid

type LedGrid struct {
	// Groesse des LedGrids. Falls dieses LedGrid Teil eines groesseren
	// Panels sein sollte, dann muss Rect.Min nicht unbedingt {0, 0} sein.
	Rect image.Rectangle
	// Enthaelt die Farbwerte red, green, blue (RGB) fuer jede LED, welche
	// das LedGrid ausmachen. Die Reihenfolge entspricht dabei der
	// Verkabelung!
	Pix    []uint8
	Client GridClient
	// Neu ist das Objekt LedGrid die zentrale steuernde Instanz. Das bedeutet
	// dass sowohl AnimationController als auch Canvas(es) hier vermerkt
	// sein muessen.
	AnimCtrl *AnimationController
	// Es koennen eine ganze Reihe von Canvas'es verwendet werden - so um bspw.
	// mit mehreren Layern oder Ueberblendungen zu arbeiten. Die Canvas'es
	// werden in einer dynamischen Liste verwaltet. Die Darstellung beginnt
	// mit dem hintersten Canvas und stellt zuletzt (d.h. zuvorderst) das
	// Canvas am Anfang der Liste dar.
	CanvasList *list.List
	// contains filtered or unexported fields
}

Entspricht dem Bild, welches auf einem LED-Panel angezeigt werden kann. Implementiert die Interfaces image.Image und draw.Image, also die Methoden ColorModel, Bounds, At und Set.

func NewLedGrid

func NewLedGrid(client GridClient, modConf conf.ModuleConfig) *LedGrid

Erstellt ein neues LedGrid-Objekt, welches als Verkabelung modConf hat.

func NewLedGridBySize added in v1.4.1

func NewLedGridBySize(client GridClient, size image.Point) *LedGrid

Erstellt ein neues LedGrid-Objekt, welches die Groesse size in Anzahl LEDs horizontal, resp. vertikal hat. Die Verkabelung wird vollflaechig und gem. Methode DefaultModuleConfig vorgenommen.

func (*LedGrid) At

func (g *LedGrid) At(x, y int) color.Color

func (*LedGrid) Bounds

func (g *LedGrid) Bounds() image.Rectangle

func (*LedGrid) Canvas added in v1.4.1

func (g *LedGrid) Canvas(layer int) *Canvas

Liefert das Canvas-Objekt zurueck, welches fuer den Layer layer definiert ist. Per Default ist nur Layer 0 vorhanden, die Methode bricht ab, wenn es kein Canvas-Objekt zum gewuenschten Layer gibt.

func (*LedGrid) Clear added in v1.1.0

func (g *LedGrid) Clear(c colors.LedColor)

Mit Clear kann das ganze Grid geloescht, resp. alle LEDs auf die gleiche Farbe gebracht werden. Das Anzeigen, resp. der Refresh des Panel ist Teil dieser Methode.

func (*LedGrid) Close added in v1.4.1

func (g *LedGrid) Close()

func (*LedGrid) ColorModel

func (g *LedGrid) ColorModel() color.Model

The following methods implement the draw.Image interface, LedGrid can therefore be used as the destination for all kind of drawings - especially for a call to draw.Draw() in order to compose the data from Canvas objects before sending the picture to a GridClient.

func (*LedGrid) DelCanvas added in v1.4.1

func (g *LedGrid) DelCanvas(canv *Canvas)

func (*LedGrid) LedColorAt

func (g *LedGrid) LedColorAt(x, y int) colors.LedColor

Dient dem schnelleren Zugriff auf den Farbwert einer bestimmten Zelle, resp. einer bestimmten LED. Analog zu At(), retourniert den Farbwert jedoch als LedColor-Typ.

func (*LedGrid) NewCanvas added in v1.4.1

func (g *LedGrid) NewCanvas() (*Canvas, int)

Erzeugt ein neues Canvas-Objekt und hanegt es an den Schluss der Liste. Beim Zeichnen geht LedGrid von hinten nach vorne

func (*LedGrid) PixOffset

func (g *LedGrid) PixOffset(x, y int) int

Damit wird der Offset eines bestimmten Farbwerts innerhalb des Slices Pix berechnet. Dabei wird beruecksichtigt, dass das die LED's im LedGrid schlangenfoermig angeordnet sind, und der Beginn der LED-Kette frei waehlbar in einer Ecke des Panels liegen kann.

func (*LedGrid) Reset added in v1.4.1

func (g *LedGrid) Reset()

func (*LedGrid) Set

func (g *LedGrid) Set(x, y int, c color.Color)

func (*LedGrid) SetLedColor

func (g *LedGrid) SetLedColor(x, y int, c colors.LedColor)

Analoge Methode zu Set(), jedoch ohne zeitaufwaendige Konvertierung.

func (*LedGrid) Show added in v1.4.1

func (g *LedGrid) Show()

Zeigt den aktuellen Inhalt des Grid auf der beim Erstellen spezifizierten Hardware dar.

func (*LedGrid) StartRefresh added in v1.4.1

func (g *LedGrid) StartRefresh()

type LedStatusType added in v1.4.1

type LedStatusType byte

This type has been introduced in order to mark some NeoPixels on the chain as 'ok' (the default), 'defect' or 'missing' (see constants LedOK, LedDefect or LedMissing for more information).

const (
	// LedOK is the default state of a NeoPixel.
	LedOK LedStatusType = iota
	// NeoPixels with status LedDefect will be blacked out. This means that
	// the sent color data for this pixel will always be (0,0,0), i.e. black.
	// This status can be used if a NeoPixel propagates data as expected
	// but is not able to correctly display its own color.
	LedDefect
	// LedMissing can be used, if a NeoPixel does not even propagate data
	// to NeoPixels further down the chain. Such a pixel has to be cut out
	// of the chain and the wires need to be shortened. For the time till a
	// replacement pixel is organized and soldered in, the pixel must have
	// status LedMissing.
	LedMissing
)

type Line added in v1.3.0

Fuer Geraden resp. Segmente ist dieser Datentyp vorgesehen, der von Pos nach Pos + Size verlaeuft. Damit das funktioniert, duerfen bei diesem Typ die Koordinaten von Size auch negativ sein. Alternative Definition: ein Segment ist nur durch einen Positionspunkt definiert (entspricht den Koordinaten des Mittelpunktes) plus einer Groesse (Size - wobei nur die X-Koordinate beruecksichtigt wird) und einem Winkel entspricht der Drehung des Segments um den Mittelpunkt.

func NewLine added in v1.3.0

func NewLine(pos geom.Point, len float64, col colors.LedColor) *Line

func (*Line) Draw added in v1.3.0

func (l *Line) Draw(c *Canvas)

type ModuleConfigArg added in v1.4.1

type ModuleConfigArg struct {
	ModuleConfig conf.ModuleConfig
}

type MyUniform added in v1.4.1

type MyUniform struct {
	C color.Alpha
}

func NewMyUniform added in v1.4.1

func NewMyUniform(val uint8) *MyUniform

func (*MyUniform) At added in v1.4.1

func (c *MyUniform) At(x, y int) color.Color

func (*MyUniform) Bounds added in v1.4.1

func (c *MyUniform) Bounds() image.Rectangle

func (*MyUniform) ColorModel added in v1.4.1

func (c *MyUniform) ColorModel() color.Model

func (*MyUniform) Convert added in v1.4.1

func (c *MyUniform) Convert(color.Color) color.Color

func (*MyUniform) Opaque added in v1.4.1

func (c *MyUniform) Opaque() bool

func (*MyUniform) RGBA added in v1.4.1

func (c *MyUniform) RGBA() (r, g, b, a uint32)

func (*MyUniform) RGBA64At added in v1.4.1

func (c *MyUniform) RGBA64At(x, y int) color.RGBA64

type NetGridClient added in v1.4.1

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

Mit diesem Typ wird die klassische Verwendung auf zwei Nodes realisiert.

func (*NetGridClient) Close added in v1.4.1

func (p *NetGridClient) Close()

Schliesst die Verbindung zum Controller.

func (*NetGridClient) Gamma added in v1.4.1

func (p *NetGridClient) Gamma() (r, g, b float64)

func (*NetGridClient) ModuleConfig added in v1.4.1

func (p *NetGridClient) ModuleConfig() conf.ModuleConfig

func (*NetGridClient) NumLeds added in v1.4.1

func (p *NetGridClient) NumLeds() int

Die folgenden Methoden verpacken die entsprechenden RPC-Calls zum Grid-Server.

func (*NetGridClient) Send added in v1.4.1

func (p *NetGridClient) Send(buffer []byte)

Sendet die Bilddaten in der LedGrid-Struktur zum Controller.

func (*NetGridClient) SetGamma added in v1.4.1

func (p *NetGridClient) SetGamma(r, g, b float64)

func (*NetGridClient) Stopwatch added in v1.4.2

func (p *NetGridClient) Stopwatch() *Stopwatch

type NormAnimation added in v1.1.0

type NormAnimation interface {
	TimedAnimation
	// Init wird vom Animationsframework aufgerufen, wenn diese Animation
	// gestartet wird. Wichtig: Wiederholungen und Umkehrungen (AutoReverse)
	// zaehlen nicht als Start!
	Init()
	// In Tick schliesslich ist die eigentliche Animationslogik enthalten.
	// Der Parameter t gibt an, wie weit die Animation bereits gelaufen ist.
	// t=0: Animation wurde eben gestartet
	// t=1: Die Animation ist fertig
	Tick(t float64)
}

Jede konkrete Animation (Farben, Positionen, Groessen, etc.) muss das Interface NormAnimation implementieren.

type NormAnimationEmbed added in v1.4.0

type NormAnimationEmbed struct {
	// Falls true, wird die Animation einmal vorwaerts und einmal rueckwerts
	// abgespielt.
	AutoReverse bool
	// Curve bezeichnet eine Interpolationsfunktion, welche einen beliebigen
	// Verlauf der Animation erlaubt (Beschleunigung am Anfang, Abbremsen
	// gegen Schluss, etc).
	Curve AnimationCurve
	// Bezeichnet die Anzahl Wiederholungen dieser Animation.
	RepeatCount int
	// Ueber dieses Embeddable werden Variablen und Methdoden zum Setzen und
	// Abfragen der Laufzeit importiert.
	DurationEmbed
	// Falls die Animation nicht am Anfang starten soll, sondern zu einem
	// beliebigen Punkt, setzt man dieses Feld auf einen Wert zwischen 0 und
	// 1.
	Pos float64
	// contains filtered or unexported fields
}

Dieses Embeddable wird von allen Animationen verwendet, welche eine Animation implementieren, die folgende Kriterien aufweist:

  • sie hat eine begrenzte Laufzeit (ohne Beruecksichtiung von Umkehrungen und Wiederholungen!)

func (*NormAnimationEmbed) Continue added in v1.4.0

func (a *NormAnimationEmbed) Continue()

Setzt eine mit [Stop] angehaltene Animation wieder fort.

func (*NormAnimationEmbed) Duration added in v1.4.0

func (a *NormAnimationEmbed) Duration() time.Duration

Mit Duration wird die gesamte Laufzeit der Animation (als inkl. Umkehrungen und Wiederholungen) ermittelt. Falls die Anzahl Wiederholgungen auf -1 (d.h. Endloswiederholgung) gesetzt ist, liefert Duration die Laufzeit eines Animationszyklus.

func (*NormAnimationEmbed) Extend added in v1.4.0

func (a *NormAnimationEmbed) Extend(wrapper NormAnimation)

Muss beim Erstellen einer Animation aufgerufen werden, welche dieses Embeddable einbindet.

func (*NormAnimationEmbed) IsRunning added in v1.4.0

func (a *NormAnimationEmbed) IsRunning() bool

Liefert true, falls die Animation mittels [Stop] angehalten wurde oder falls die Animation zu Ende ist.

func (*NormAnimationEmbed) Start added in v1.4.0

func (a *NormAnimationEmbed) Start()

func (*NormAnimationEmbed) StartAt added in v1.4.1

func (a *NormAnimationEmbed) StartAt(t time.Time)

Startet die Animation mit jenen Parametern, die zum Startzeitpunkt aktuell sind. Ist die Animaton bereits am Laufen ist diese Methode ein no-op.

func (*NormAnimationEmbed) Suspend added in v1.4.1

func (a *NormAnimationEmbed) Suspend()

Haelt die Animation an, laesst sie jedoch in der Animation-Queue der Applikation. Mit [Continue] kann eine gestoppte Animation wieder fortgesetzt werden.

func (*NormAnimationEmbed) TimeInfo added in v1.4.1

func (a *NormAnimationEmbed) TimeInfo() (start, end time.Time, total float64)

Retourniert einige Werte, welche das Timing der Animation betreffen. Wird wohl eher fuer Debugging verwendet. Ausserdem ist der Zugriff nicht synchronisiert! Passt man nicht auf, kriegt man inkonsistente Angaben.

func (*NormAnimationEmbed) Update added in v1.4.0

func (a *NormAnimationEmbed) Update(t time.Time) bool

Diese Methode ist fuer die korrekte Abwicklung (Beachtung von Reverse und RepeatCount, etc) einer Animation zustaendig. Wenn die Animation zu Ende ist, retourniert Update false. Der Parameter t ist ein fortlaufender "Point in Time", der fuer das gesamte Animationsframework konsistent ermittelt wird. Nur wenn der AnimationController angehalten wird, stoppt auch diese Zeitbasis.

type NormShaderFunc added in v1.4.1

type NormShaderFunc func(t, x, y float64) float64

type NumLedsArg added in v1.4.1

type NumLedsArg int

Die folgenden Methoden koennen via RPC vom Client aufgerufen werden.

type PaletteAnimation added in v1.3.0

type PaletteAnimation struct {
	GenericAnimation[colors.LedColor]
	// contains filtered or unexported fields
}

Animation fuer einen Farbverlauf ueber die Farben einer Palette.

func NewPaletteAnim added in v1.4.1

func NewPaletteAnim(obj Colorable, pal ColorSource, dur time.Duration) *PaletteAnimation

func (*PaletteAnimation) Tick added in v1.3.0

func (a *PaletteAnimation) Tick(t float64)

type PaletteFadeAnimation added in v1.3.0

type PaletteFadeAnimation struct {
	NormAnimationEmbed
	Fader   *PaletteFader
	Val2    ColorSource
	ValFunc PaletteFuncType
}

Dies schliesslich ist eine Animation, bei welcher stufenlos von einer Palette auf eine andere umgestellt wird.

func NewPaletteFadeAnim added in v1.4.3

func NewPaletteFadeAnim(fader *PaletteFader, pal2 ColorSource, dur time.Duration) *PaletteFadeAnimation

func (*PaletteFadeAnimation) Init added in v1.3.0

func (a *PaletteFadeAnimation) Init()

func (*PaletteFadeAnimation) Tick added in v1.3.0

func (a *PaletteFadeAnimation) Tick(t float64)

type PaletteFader added in v1.1.0

type PaletteFader struct {
	Pals [2]ColorSource
	T    float64
	// contains filtered or unexported fields
}

Mit diesem Typ kann ein fliessender Uebergang von einer Palette zu einer anderen realisiert werden.

func NewPaletteFader added in v1.1.0

func NewPaletteFader(pal ColorSource) *PaletteFader

Initialisiert wird der Fader mit der aktuell anzuzeigenden Palette. Der PaletteFader wird anschliessend anstelle der ueblichen Palette verwendet.

func (*PaletteFader) AlphaPtr added in v1.4.3

func (p *PaletteFader) AlphaPtr() *uint8

func (*PaletteFader) Color added in v1.1.0

func (p *PaletteFader) Color(v float64) (c colors.LedColor)

Mit dieser Methode wird der aktuelle Farbwert retourniert. Damit implementiert der Fader das ColorSource-Interface und kann als Farbquelle verwendet werden - genau wie anderen Paletten-, resp. Farbtypen.

func (*PaletteFader) Name added in v1.1.0

func (p *PaletteFader) Name() string

type PaletteFuncType added in v1.3.0

type PaletteFuncType func() ColorSource

Dies ist ein etwas unbeholfener Versuch, die Zielwerte bestimmter Animationen dynamisch berechnen zu lassen. Alle XXXFuncType sind Funktionstypen fuer einen bestimmten Datentyp, der in den Animationen verwendet wird und dessen dynamische Berechnung Sinn macht.

func RandPalette added in v1.3.0

func RandPalette() PaletteFuncType

RandPalette liefert eine Funktion, die bei jedem Aufruf eine zufaellig gewaehlte Palette retourniert.

func SeqPalette added in v1.3.0

func SeqPalette() PaletteFuncType

SeqPalette liefert eine Funktion, die bei jedem Aufruf die naechste Palette als Resultat zurueckgibt.

type Path added in v1.4.1

type Path interface {
	Pos(t float64) geom.Point
}

Ein Pfad ist im Grunde nichts anderes, als eine Funktion der Form

[0,1] -> (x,y)

type PathAnimation added in v1.3.0

type PathAnimation struct {
	GenericAnimation[geom.Point]
	Path Path
}

func NewPathAnim added in v1.4.1

func NewPathAnim(obj Positionable, path *GeomPath, size geom.Point, dur time.Duration) *PathAnimation

func NewPolyPathAnim added in v1.4.1

func NewPolyPathAnim(obj Positionable, path *PolygonPath, dur time.Duration) *PathAnimation

func NewPositionAnim added in v1.4.1

func NewPositionAnim(obj Positionable, val2 geom.Point, dur time.Duration) *PathAnimation

func (*PathAnimation) Tick added in v1.3.0

func (a *PathAnimation) Tick(t float64)

type PathFunctionType added in v1.3.0

type PathFunctionType func(t float64) geom.Point

Im Folgenden sind einige Pfad-generierende Funktionen zusammengestellt, die als Parameter [pathFunc] bei NewPathAnimation verwendet werden können. Eigene Pfad-Funktionen sind ebenfalls möglich, die Bedingungen an eine solche Funktion sind:

  1. Wird mit einer Fliesskommazahl (t) aufgerufen und retourniert einen 2D-Punkt
  2. t ist in [0,1]
  3. f(0) muss (0,0) sein
  4. max(f(t).X) - min(f(t).X) = 1.0 und max(f(t).Y) - min(f(t).Y) = 1.0 d.h. die generierten Punkte duerfen sowohl in X- als auch in Y-Richtung einen maximalen Abstand von 1.0 haben.

type Pixel added in v1.3.0

Will man ein einzelnes Pixel exakt an einer LED-Position zeichnen, so eignet sich dieser Typ. Im Gegensatz zu den obigen Typen sind die Koordinaten eines Pixels ganze Zahlen und das Zeichnen erfolgt direkt in die draw.Image Struktur und nicht in gg.Context. Es ist zu beachten, dass bei diesem Typ die Koordinaten von pos als Spalten-, resp. Zeilenindex des Led-Grids interpretiert werden!

func NewPixel added in v1.3.0

func NewPixel(pos image.Point, col colors.LedColor) *Pixel

func (*Pixel) Draw added in v1.3.0

func (p *Pixel) Draw(c *Canvas)

type PolygonPath added in v1.3.0

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

Neben den vorhandenen Pfaden (Kreise, Halbkreise, Viertelkreise) koennen Positions-Animationen auch entlang komplett frei definierten Pfaden erfolgen. Der Schluessel dazu ist der Typ PolygonPath.

func NewPolygonPath added in v1.3.0

func NewPolygonPath(points ...geom.Point) *PolygonPath

Erstellt ein neues PolygonPath-Objekt und verwendet die Punkte in points als Eckpunkte eines offenen Polygons.

func (*PolygonPath) Pos added in v1.4.1

func (p *PolygonPath) Pos(t float64) geom.Point

Diese Methode ist bei der Erstellung einer Pfad-Animation als Parameter fnc anzugeben.

type PosEmbed added in v1.4.1

type PosEmbed struct {
	Pos geom.Point
}

Embeddables fuer die einfachere Animation diverser Attribute. Diese Records sind jeweils so aufgebaut, dass ihr Name auf den Namen des Attributes verweist (Bsp: PosEmbed hat ein Feld namens Pos und eine Methode PosPtr(), welche einen Pointer auf das Feld Pos liefert).

func (*PosEmbed) PosPtr added in v1.4.1

func (e *PosEmbed) PosPtr() *geom.Point

type Positionable added in v1.4.1

type Positionable interface {
	PosPtr() *geom.Point
}

Animation fuer das Fahren entlang eines Pfades. Mit fnc kann eine konkrete, Pfad-generierende Funktion angegeben werden. Siehe auch [PathFunction]

type Rectangle added in v1.3.0

Rectangle ist fuer alle rechteckigen Objekte vorgesehen. Pos bezeichnet den Mittelpunkt des Objektes und Size die Breite, rsep. Hoehe.

func NewRectangle added in v1.3.0

func NewRectangle(pos, size geom.Point, borderColor colors.LedColor) *Rectangle

func (*Rectangle) Draw added in v1.3.0

func (r *Rectangle) Draw(c *Canvas)

type RegularPolygon added in v1.3.0

Auch gleichmaessige Polygone duerfen nicht fehlen.

func NewRegularPolygon added in v1.3.0

func NewRegularPolygon(n int, pos, size geom.Point, borderColor colors.LedColor) *RegularPolygon

Erzeugt ein neues regelmaessiges Polygon mit n Ecken. Mit pos wird der Mittelpunkt des Polygons bezeichnet und size enthaelt die Groesse (d.h. Breite, bzw. Hoehe) des Polygons. Bem: nur die X-Koordinate von size wird beruecksichtigt!

func (*RegularPolygon) Draw added in v1.3.0

func (p *RegularPolygon) Draw(c *Canvas)

type Rotateable added in v1.4.1

type Rotateable interface {
	AnglePtr() *float64
}

type Sequence added in v1.3.0

type Sequence struct {
	DurationEmbed
	// Gibt an, wie oft diese Sequenz wiederholt werden soll.
	RepeatCount int

	Tasks []Task
	// contains filtered or unexported fields
}

Mit einer Sequence lassen sich eine Reihe von Animationen hintereinander ausfuehren. Dabei wird eine nachfolgende Animation erst dann gestartet, wenn die vorangehende beendet wurde.

func NewSequence added in v1.3.0

func NewSequence(tasks ...Task) *Sequence

Erstellt eine neue Sequenz welche die Animationen in [anims] hintereinander ausfuehrt.

func (*Sequence) Add added in v1.3.0

func (a *Sequence) Add(tasks ...Task)

Fuegt der Sequenz weitere Animationen hinzu.

func (*Sequence) Continue added in v1.4.0

func (a *Sequence) Continue()

Setzt die Ausfuehrung der Sequenz fort.

func (*Sequence) IsRunning added in v1.4.0

func (a *Sequence) IsRunning() bool

Liefert den Status der Sequenz zurueck.

func (*Sequence) Put added in v1.4.1

func (a *Sequence) Put(tasks ...Task)

func (*Sequence) Start added in v1.3.0

func (a *Sequence) Start()

func (*Sequence) StartAt added in v1.4.1

func (a *Sequence) StartAt(t time.Time)

Startet die Sequenz.

func (*Sequence) Suspend added in v1.4.1

func (a *Sequence) Suspend()

Unterbricht die Ausfuehrung der Sequenz.

func (*Sequence) TimeInfo added in v1.4.1

func (a *Sequence) TimeInfo() (start, end time.Time)

func (*Sequence) Update added in v1.3.0

func (a *Sequence) Update(t time.Time) bool

Wird durch den Controller periodisch aufgerufen, prueft ob Animationen dieser Sequenz noch am Laufen sind und startet ggf. die naechste.

type Shader added in v1.1.0

type Shader TimedAnimation

Fuer den klassischen Shader wird pro Pixel folgende Animation gestartet.

type ShaderAnimation added in v1.3.0

type ShaderAnimation struct {
	ValPtr *colors.LedColor
	Pal    ColorSource
	X, Y   float64
	Fnc    NormShaderFunc
	// contains filtered or unexported fields
}

func NewShaderAnim added in v1.4.1

func NewShaderAnim(obj Colorable, pal ColorSource, x, y float64,
	fnc NormShaderFunc) *ShaderAnimation

func (*ShaderAnimation) Continue added in v1.3.0

func (a *ShaderAnimation) Continue()

Setzt die Ausfuehrung der Animation fort.

func (*ShaderAnimation) Duration added in v1.3.0

func (a *ShaderAnimation) Duration() time.Duration

func (*ShaderAnimation) IsRunning added in v1.4.0

func (a *ShaderAnimation) IsRunning() bool

Liefert den Status der Animation zurueck.

func (*ShaderAnimation) SetDuration added in v1.3.0

func (a *ShaderAnimation) SetDuration(d time.Duration)

func (*ShaderAnimation) Start added in v1.3.0

func (a *ShaderAnimation) Start()

func (*ShaderAnimation) StartAt added in v1.4.1

func (a *ShaderAnimation) StartAt(t time.Time)

Startet die Animation.

func (*ShaderAnimation) Suspend added in v1.4.1

func (a *ShaderAnimation) Suspend()

Unterbricht die Ausfuehrung der Animation.

func (*ShaderAnimation) Update added in v1.3.0

func (a *ShaderAnimation) Update(t time.Time) bool

type SimpleTask added in v1.4.1

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

Mit einem Task koennen beliebige Funktionsaufrufe in die Animationsketten aufgenommen werden. Sie koennen beliebig oft gestartet werden. Es empfiehlt sich, nur kurze Aktionen damit zu realisieren (bspw. Setzen von Variablen)

func NewTask added in v1.4.1

func NewTask(fn func()) *SimpleTask

func (*SimpleTask) Start added in v1.4.1

func (a *SimpleTask) Start()

func (*SimpleTask) StartAt added in v1.4.1

func (a *SimpleTask) StartAt(t time.Time)

type SizeAnimation added in v1.4.1

type SizeAnimation struct {
	GenericAnimation[geom.Point]
	Path Path
}

func NewSizeAnim added in v1.4.1

func NewSizeAnim(obj Sizeable, val2 geom.Point, dur time.Duration) *SizeAnimation

func (*SizeAnimation) Tick added in v1.4.1

func (a *SizeAnimation) Tick(t float64)

type SizeEmbed added in v1.4.1

type SizeEmbed struct {
	Size geom.Point
}

func (*SizeEmbed) SizePtr added in v1.4.1

func (e *SizeEmbed) SizePtr() *geom.Point

type Sizeable added in v1.4.1

type Sizeable interface {
	SizePtr() *geom.Point
}

type SlicePalette added in v1.1.0

type SlicePalette struct {
	Colors []colors.LedColor
	// contains filtered or unexported fields
}

Palette mit 256 einzelnen dedizierten Farbwerten - kein Fading oder sonstige Uebergaenge.

func NewSlicePalette added in v1.1.0

func NewSlicePalette(name string, cl ...colors.LedColor) *SlicePalette

func (*SlicePalette) Color added in v1.1.0

func (p *SlicePalette) Color(v float64) colors.LedColor

func (*SlicePalette) Name added in v1.4.1

func (p *SlicePalette) Name() string

func (*SlicePalette) SetColor added in v1.1.0

func (p *SlicePalette) SetColor(idx int, c colors.LedColor)

type Sprite added in v1.4.1

type Sprite struct {
	Image
	NormAnimationEmbed
	// contains filtered or unexported fields
}

Mit ImageList (TO DO: besserer Name waere wohl schon Sprite) lassen sich animierte Bildfolgen darstellen. ImageList ist eine Erweiterung des Typs Image. Die einzelnen Bilder koennen entweder ueber die Methode Add oder aus einer BlinkenLight Animation mit der Methode AddBlinkenLight hinzuge- fuegt werden.

func NewSprite added in v1.4.1

func NewSprite(pos geom.Point) *Sprite

Erzeugt eine (noch) leere ImageList mit pos als Mittelpunkt.

func (*Sprite) Add added in v1.4.1

func (i *Sprite) Add(img draw.Image, dur time.Duration)

Fuegt der Liste von Bilern img hinzu, welches fuer die Dauer von dur angezeigt werden soll. Falls dies das erste Bild ist, welches hinzugefuegt wird, dann wird Img und Size auf dieses Bild und auf die Groesse dieses Bildes gesetzt.

func (*Sprite) AddBlinkenLight added in v1.4.1

func (i *Sprite) AddBlinkenLight(b *BlinkenFile)

func (*Sprite) Init added in v1.4.1

func (i *Sprite) Init()

func (*Sprite) Tick added in v1.4.1

func (i *Sprite) Tick(t float64)

type Stopwatch added in v1.2.0

type Stopwatch struct {
	Num             int
	Total, Max, Min time.Duration
	// contains filtered or unexported fields
}

Simple way to measure the number and duration of events, simply by enclose the code to be measured by Start() and Stop().

func NewStopwatch added in v1.2.0

func NewStopwatch() *Stopwatch

func (*Stopwatch) Avg added in v1.2.0

func (s *Stopwatch) Avg() time.Duration

Berechnet die durchschnittliche Messdauer (also den Quotienten von Total() / Num()).

func (*Stopwatch) Reset added in v1.2.0

func (s *Stopwatch) Reset()

Setzt die gemessene Dauer auf 0 und die Anzahl Messungen ebenfalls.

func (*Stopwatch) Start added in v1.2.0

func (s *Stopwatch) Start()

Starts the stopwatch. If the stopwatch is already running, the previous starting time is cancelled.

func (*Stopwatch) Stop added in v1.2.0

func (s *Stopwatch) Stop()

Stops the stopwatch and updates the internal variables. If the stopwatch is stopped, this method has no effect.

func (*Stopwatch) String added in v1.2.0

func (s *Stopwatch) String() string

type StrokeWidthEmbed added in v1.4.1

type StrokeWidthEmbed struct {
	StrokeWidth float64
}

func (*StrokeWidthEmbed) StrokeWidthPtr added in v1.4.1

func (e *StrokeWidthEmbed) StrokeWidthPtr() *float64

type StrokeWidtheable added in v1.4.1

type StrokeWidtheable interface {
	StrokeWidthPtr() *float64
}

type Task added in v1.4.0

type Task interface {
	Start()
	StartAt(t time.Time)
}

Die folgenden Interfaces geben einen guten Ueberblick ueber die Arten von Hintergrundaktivitaeten.

Ein Task hat nur die Moeglichkeit, gestartet zu werden. Anschl. lauft er asynchron ohne weitere Moeglichkeiten der Einflussnahme. Es ist sinnvoll, wenn der Code hinter einem Task so kurz wie moeglich gehalten wird.

type Text added in v1.1.0

type Text struct {
	CanvasObjectEmbed
	AlignEmbed
	PosEmbed
	AngleEmbed
	ColorEmbed
	FadeEmbed
	Text string
	// contains filtered or unexported fields
}

Zur Darstellung von Text mit TrueType-Schriften

func NewText added in v1.3.0

func NewText(pos geom.Point, text string, col colors.LedColor) *Text

func (*Text) Draw added in v1.3.0

func (t *Text) Draw(c *Canvas)

func (*Text) SetFont added in v1.4.0

func (t *Text) SetFont(font *fonts.Font, size float64)

type TimedAnimation added in v1.4.1

type TimedAnimation interface {
	Animation
	Duration() time.Duration
	SetDuration(dur time.Duration)
}

type Timeline added in v1.3.0

type Timeline struct {
	DurationEmbed
	// Gibt an, wie oft diese Timeline wiederholt werden soll.
	RepeatCount int

	Slots []*TimelineSlot
	// contains filtered or unexported fields
}

Mit einer Timeline koennen einzelne oder mehrere Animationen zu bestimmten Zeiten gestartet werden. Die Zeit ist relativ zur Startzeit der Timeline selber zu verstehen. Nach dem Start werden die Animationen nicht mehr weiter kontrolliert.

func NewTimeline added in v1.3.0

func NewTimeline(d time.Duration) *Timeline

Erstellt eine neue Timeline mit Ausfuehrungsdauer d. Als d kann auch Null angegeben werden, dann ist die Laufzeit der Timeline gleich dem groessten Ausfuehrungszeitpunkt der hinterlegten Animationen.

func (*Timeline) Add added in v1.3.0

func (a *Timeline) Add(pit time.Duration, tasks ...Task)

Fuegt der Timeline die Animation anim hinzu mit Ausfuehrungszeitpunkt dt nach Start der Timeline. Im Moment muessen die Animationen noch in der Reihenfolge ihres Ausfuehrungszeitpunktes hinzugefuegt werden.

func (*Timeline) Continue added in v1.4.0

func (a *Timeline) Continue()

Setzt die Ausfuehrung der Timeline fort.

func (*Timeline) IsRunning added in v1.4.0

func (a *Timeline) IsRunning() bool

Retourniert den Status der Timeline.

func (*Timeline) Start added in v1.3.0

func (a *Timeline) Start()

func (*Timeline) StartAt added in v1.4.1

func (a *Timeline) StartAt(t time.Time)

Startet die Timeline.

func (*Timeline) Suspend added in v1.4.1

func (a *Timeline) Suspend()

Unterbricht die Ausfuehrung der Timeline.

func (*Timeline) Update added in v1.3.0

func (a *Timeline) Update(t time.Time) bool

Wird periodisch durch den Controller aufgerufen und aktualisiert die Timeline.

type TimelineSlot added in v1.4.0

type TimelineSlot struct {
	Duration time.Duration
	Tasks    []Task
}

Interner Typ, mit dem Ausfuehrungszeitpunkt und Animationen festgehalten werden koennen.

type UniformPalette added in v1.1.0

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

Damit auch einzelne Farben wie Paletten verwendet werden koennen, existiert der Typ UniformPalette. Die Ueberlegungen dazu sind analog zum Typ image.Uniform.

func NewUniformPalette added in v1.1.0

func NewUniformPalette(name string, color colors.LedColor) *UniformPalette

Erstellt eine neue einfarbige Farbquelle mit gegebenem namen.

func (*UniformPalette) At added in v1.2.0

func (p *UniformPalette) At(x, y int) color.Color

func (*UniformPalette) Bounds added in v1.2.0

func (p *UniformPalette) Bounds() image.Rectangle

func (*UniformPalette) Color added in v1.1.0

func (p *UniformPalette) Color(v float64) colors.LedColor

Damit wird das ColorSource-Interface implementiert. Der Parameter [v] hat bei dieser Farbquelle keine Bedeutung und wird ignoriert.

func (*UniformPalette) ColorModel added in v1.2.0

func (p *UniformPalette) ColorModel() color.Model

func (*UniformPalette) Name added in v1.4.1

func (p *UniformPalette) Name() string

func (*UniformPalette) Set added in v1.2.0

func (p *UniformPalette) Set(x, y int, c colors.LedColor)

type WS2801 added in v1.4.1

type WS2801 struct {
	DisplayEmbed
	// contains filtered or unexported fields
}

Dies ist die Implementation eines Displayers, welcher eine Lichterkette von NeoPixeln mit WS2801 via SPI-Bus auf einem RaspberryPi ansteuert.

func NewWS2801 added in v1.4.1

func NewWS2801(spiDev string, baud int, modConf conf.ModuleConfig) *WS2801

Erstellt eine neue Instanz. spiDev ist das Device-File des SPI-Buses, baud die Taktrate (in Bit pro Sekunde) und numLeds die Anzahl NeoPixel auf der Lichterkette - ohne die entfernten NeoPixel zu beruecksichtigen.

func (*WS2801) Close added in v1.4.1

func (p *WS2801) Close()

Schliesst den Displayer, in diesem Fall den SPI-Port.

func (*WS2801) DefaultGamma added in v1.4.1

func (p *WS2801) DefaultGamma() (r, g, b float64)

Diese Methode gehoert zum Displayer-Interface und retourniert die empfohlenen Gamma-Werte fuer die drei Farbkanaele Rot, Gruen und Blau.

func (*WS2801) Send added in v1.4.1

func (p *WS2801) Send(buffer []byte)

Sendet die Farbwerte in buffer via SPI-Bus zur NeoPixel Lichterkette. Die Reihenfolge der Pixel muss bereits vorgaengig der effektiven Verkabelung angepasst worden sein, ebenso die Farbwertkorrektur. Diese Methode wird ueblicherweise vom DisplayEmbed und nicht von Benutzercode aufgerufen.

type WipeDirection added in v1.4.1

type WipeDirection int

Wipe transitions offer an effect which is very common in film an tv. It gives the illusion of a cover which is pulled away in any of the four possible ways.

const (
	WipeL2R WipeDirection = iota
	WipeR2L
	WipeT2B
	WipeB2T
)

type WipeTransition added in v1.4.1

type WipeTransition struct {
	NormAnimationEmbed
	// contains filtered or unexported fields
}

func NewWipeTransition added in v1.4.1

func NewWipeTransition(c *Canvas, dir WipeDirection, typ WipeType, d time.Duration) *WipeTransition

func (*WipeTransition) At added in v1.4.1

func (a *WipeTransition) At(x, y int) color.Color

func (*WipeTransition) Bounds added in v1.4.1

func (a *WipeTransition) Bounds() image.Rectangle

func (*WipeTransition) ColorModel added in v1.4.1

func (a *WipeTransition) ColorModel() color.Model

func (*WipeTransition) Init added in v1.4.1

func (a *WipeTransition) Init()

func (*WipeTransition) Tick added in v1.4.1

func (a *WipeTransition) Tick(t float64)

type WipeType added in v1.4.1

type WipeType int
const (
	WipeIn WipeType = iota
	WipeOut
)

Directories

Path Synopsis
cmd
gridEmulator command
gridPlotter command
anim module
colorEdit module
gui module
paletteGui module
pixelemulator module
playground module

Jump to

Keyboard shortcuts

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