Documentation
¶
Overview ¶
Package matrix contains legacy helpers for editing matrix frames and running blocking matrix effects.
Deprecated: use pkg/effects for deterministic frame generation and pkg/effects/adapters for live LAN rendering. The matrix package remains for compatibility with existing callers.
Index ¶
- Constants
- Variables
- func ConcentricFrames(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, ...) errordeprecated
- func NewColorSlice(length int, palette ...packets.LightHsbk) []packets.LightHsbk
- func Rockets(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, ...) errordeprecated
- func Snake(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, ...) errordeprecated
- func Waterfall(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, ...) errordeprecated
- func Worm(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, ...) errordeprecated
- type AnimationDirection
- type ChainMode
- type Matrix
- func (m *Matrix) Clear(pixels ...Pixel)
- func (m *Matrix) CopyRow(dstY, srcY int)
- func (m *Matrix) DrawSquare(x, y, length int, palette ...packets.LightHsbk)
- func (m *Matrix) Flatten() []packets.LightHsbk
- func (m *Matrix) FlattenColors() [64]packets.LightHsbk
- func (m *Matrix) MaxPadding() int
- func (m *Matrix) MaxX() int
- func (m *Matrix) MaxY() int
- func (m *Matrix) ParseColors(colors [64]packets.LightHsbk)
- func (m *Matrix) SetBorder(padding int, colors ...packets.LightHsbk)
- func (m *Matrix) SetColors(x, y int, cs ...packets.LightHsbk)
- func (m *Matrix) SetCorners(palette ...packets.LightHsbk)
- func (m *Matrix) SetHorizontalSegment(x, y, length int, palette ...packets.LightHsbk)
- func (m *Matrix) SetPixel(x, y int, c packets.LightHsbk)
- func (m *Matrix) SetVerticalSegment(x, y, length int, palette ...packets.LightHsbk)
- func (m *Matrix) SetXForAlignment(a alignment, length int) int
- type Pixel
- type PixelCache
- type SendFunc
Constants ¶
const ( AlignLeft alignment = iota AlignCenter AlignRight )
Variables ¶
var ErrMissingColors = errors.New("missing colors")
var ErrStopped = fmt.Errorf("manual stop")
ErrStopped is the error returned when manually stopping an effect.
Functions ¶
func ConcentricFrames
deprecated
added in
v0.2.5
func ConcentricFrames(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, direction AnimationDirection, colors ...packets.LightHsbk) error
ConcentricFrames iterates according to the given direction drawing frams of variadic sizes. If an optional set of colors is supplied, it is used as the frame colors, otherwise the frame color will randomly change at each iteration. It repeats for n cycles, if cycles is set to 0 it repeats indefinitely.
Deprecated: use effects.NewConcentricFrames with effects.Render for offline frames, or effects/adapters.RunEffects for live rendering.
func NewColorSlice ¶ added in v0.2.5
NewColorSlice returns a []packets.LightHsbk of the specific length according to the palette. It the palette is shorter than the length then it rotates through it to fill up the slice.
func Rockets
deprecated
func Rockets(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, colors ...packets.LightHsbk) error
Rockets sequentially applies a color to a single pixel row by row wrapping at the end. It waits for the given interval before setting the next pixel. If multiple colors are provided colors are rotated on each row. It repeats for n cycles, if cycles is set to 0 it repeats indefinitely.
Deprecated: use effects.NewRockets with effects.Render for offline frames, or effects/adapters.RunEffects for live rendering.
func Snake
deprecated
func Snake(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, size int, color packets.LightHsbk) error
Snake moves n pixels along the matrix wrapping and reversing at every row. It repeats for n cycles, if cycles is set to 0 it repeats indefinitely.
Deprecated: use effects.NewSnake with effects.Render for offline frames, or effects/adapters.RunEffects for live rendering.
func Waterfall
deprecated
func Waterfall(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, colors ...packets.LightHsbk) error
Waterfall applies the given colors sequentially on each row centering them, if possible. It waits for the given interval before setting the next row. It repeats for n cycles, if cycles is set to 0 it repeats indefinitely.
Deprecated: use effects.NewWaterfall with effects.Render for offline frames, or effects/adapters.RunEffects for live rendering.
func Worm
deprecated
func Worm(m *Matrix, send SendFunc, sendIntervalMs int64, cycles int, mode ChainMode, size int, color packets.LightHsbk) error
Worm moves n pixels along the matrix wrapping and reversing at every row with a wave-like movement. It repeats for n cycles, if cycles is set to 0 it repeats indefinitely.
Deprecated: use effects.NewWorm with effects.Render for offline frames, or effects/adapters.RunEffects for live rendering.
Types ¶
type AnimationDirection ¶ added in v0.3.0
type AnimationDirection int
const ( AnimationDirectionInwards AnimationDirection = iota AnimationDirectionOutwards AnimationDirectionInOut AnimationDirectionOutIn )
func ParseAnimationDirection ¶ added in v0.2.6
func ParseAnimationDirection(m int) AnimationDirection
ParseAnimationDirection converts an int to AnimationDirection. If invalid it return AnimationDirectionInwards.
type ChainMode ¶ added in v0.3.0
type ChainMode int
func ParseChainMode ¶ added in v0.2.3
ParseChainMode converts an int to chainmode. If invalid it return ChainModeNone.
type Matrix ¶
Matrix represents a LIFX device with matrix capability.
func (*Matrix) Clear ¶
Clear sets pixels colors to their default value. If no pixels are given, it clears the whole matrix.
func (*Matrix) CopyRow ¶ added in v0.2.5
CopyRow applies the colors of a src row to the dst row. If dstY or srcY are invalid it does nothing.
func (*Matrix) DrawSquare ¶ added in v0.2.5
func (*Matrix) Flatten ¶ added in v0.3.0
Flatten flattens the matrix into a slice of LightHsbk colors.
func (*Matrix) FlattenColors ¶
FlattenColors converts the Colors' matrix into a 64-byte array that can be used with the LIFX protocol. DEPRECATED Use Flatten instead.
func (*Matrix) MaxPadding ¶ added in v0.2.5
func (*Matrix) ParseColors ¶ added in v0.2.10
func (*Matrix) SetColors ¶
SetColors sets the given colors starting at the given position and, if necessary, wrapping to the next row.
func (*Matrix) SetCorners ¶
SetCorners sets the corners of a matrix to the given palette. It accepts up to 4 colors and if fewer are provided it rotates through them.
func (*Matrix) SetHorizontalSegment ¶ added in v0.2.5
SetHorizontalSegment sets a section of row y to the given palette starting at column x.
func (*Matrix) SetVerticalSegment ¶ added in v0.2.5
SetVerticalSegment sets a section of a column x to the given palette starting at row y.
func (*Matrix) SetXForAlignment ¶ added in v0.2.5
SetXForAlignment sets x according to the given alignment.
type PixelCache ¶
type PixelCache struct {
// contains filtered or unexported fields
}
PixelCache is a convenience structure to cache pixels.
func NewPixelCache ¶
func NewPixelCache(size int) *PixelCache
NewPixelCache initialises a PixelCache.
func (*PixelCache) GetPixel ¶
func (c *PixelCache) GetPixel(i int) *Pixel
GetPixel returns the Pixel pointer at the given index It panics if the given index is not between 0 and size.
func (*PixelCache) IsSet ¶
func (c *PixelCache) IsSet(i int) bool
IsSet returns true if a pixel at the given index is set.
func (*PixelCache) Pixels ¶
func (c *PixelCache) Pixels() []Pixel
Pixels returns a slice of Pixel values as set in the cache. Any nil value is returned as a Pixel with default values.
func (*PixelCache) SetPixel ¶
func (c *PixelCache) SetPixel(i, x, y int)
SetPixel sets the Pixel at the given index. It panics if the given index is not between 0 and size.