Documentation
¶
Overview ¶
Package effects defines deterministic, device-neutral lighting effect types.
Example (CustomEffect) ¶
effect := &examplePulse{
caps: Capabilities{LightType: device.LightTypeMatrix, Width: 2, Height: 1},
color: Color{Hue: 30, Saturation: 100, Brightness: 100, Kelvin: 3500},
}
frames := Render(effect, 100*time.Millisecond, 300*time.Millisecond)
fmt.Println(len(frames))
fmt.Println(frames[0].Frame.Colors[0].Brightness)
Output: 3 25
Index ¶
- Constants
- Variables
- func BoolParam(params map[string]any, key string) (bool, error)
- func ChoiceParam(params map[string]any, key string) (string, error)
- func ClampPercent(value float64) float64
- func DurationParam(params map[string]any, key string) (time.Duration, error)
- func FrameSize(width, height int) int
- func NumberParam(params map[string]any, key string) (float64, error)
- func Register(def EffectDefinition) error
- func RunSequence(ctx context.Context, renderer Renderer, runs ...RunConfig) error
- func SetFrameColor(frame *Frame, x, y int, color Color) bool
- func ValidateFrame(frame Frame) error
- type AdaptOptions
- type Capabilities
- type Color
- type Comet
- type CometConfig
- type ConcentricFrames
- type ConcentricFramesConfig
- type Config
- type DeviceFrame
- type Direction
- type Effect
- type EffectDefinition
- type EffectID
- type Flow
- type FlowAxis
- type FlowBrightnessMode
- type FlowConfig
- type FlowDirection
- type FlowSamplingMode
- type Frame
- type FrameAt
- type Gradient
- type GradientConfig
- type GradientDrift
- type GradientDriftConfig
- type Palette
- type PaletteSweep
- type PaletteSweepConfig
- type ParamChoice
- type ParamDefinition
- type ParamKind
- type PhaseEffect
- type Random
- type ReductionStrategy
- type Renderer
- type Ring
- type RingConfig
- type Rockets
- type RocketsConfig
- type RunConfig
- type Runner
- type Scanner
- type ScannerConfig
- type Snake
- type SnakeConfig
- type Solid
- type SolidConfig
- type Sparkle
- type SparkleConfig
- type Sweep
- type SweepConfig
- type Waterfall
- type WaterfallConfig
- type Wave
- type WaveConfig
- type Worm
- type WormConfig
Examples ¶
Constants ¶
const ( // DefaultRunStep is used by RunSequence when a run does not specify a positive step. DefaultRunStep = 100 * time.Millisecond )
Variables ¶
var ( // ErrEmptyFrame is returned when a frame contains no colors. ErrEmptyFrame = errors.New("empty frame") // ErrInvalidFrame is returned when a frame has invalid dimensions or too few colors. ErrInvalidFrame = errors.New("invalid frame") // ErrInvalidDeviceState is returned when cached device state cannot form a frame. ErrInvalidDeviceState = errors.New("invalid device state") )
var ( // ErrUnknownEffect is returned when an effect ID is not registered. ErrUnknownEffect = errors.New("unknown effect") // ErrDuplicateEffect is returned when registering the same effect ID twice. ErrDuplicateEffect = errors.New("duplicate effect") // ErrInvalidDefinition is returned when an effect definition is invalid. ErrInvalidDefinition = errors.New("invalid effect definition") // ErrUnsupportedDeviceKind is returned when an effect does not support capabilities. ErrUnsupportedDeviceKind = errors.New("unsupported device kind") // ErrInvalidConfig is returned when an effect config is invalid. ErrInvalidConfig = errors.New("invalid effect config") )
var ( // ErrMissingEffect is returned when a Runner has no effect. ErrMissingEffect = errors.New("missing effect") // ErrMissingRenderer is returned when a Runner has no renderer. ErrMissingRenderer = errors.New("missing renderer") // ErrInvalidStep is returned when a Runner has a non-positive step. ErrInvalidStep = errors.New("step must be positive") )
var DefaultColor = Color{Hue: 220, Saturation: 100, Brightness: 100, Kelvin: 3500}
DefaultColor is used when a palette does not define a requested color.
Functions ¶
func ChoiceParam ¶ added in v0.4.4
ChoiceParam returns a validated string choice parameter.
func ClampPercent ¶
ClampPercent clamps value to the valid percentage range used by Color fields.
func DurationParam ¶ added in v0.4.4
DurationParam returns a validated duration parameter.
func FrameSize ¶ added in v0.4.4
FrameSize returns the number of colors needed for a width by height frame.
func NumberParam ¶ added in v0.4.4
NumberParam returns a validated number parameter.
func Register ¶ added in v0.4.2
func Register(def EffectDefinition) error
Register adds def to the global effect registry.
Example ¶
err := Register(EffectDefinition{
ID: EffectID("example_pulse"),
Label: "Example Pulse",
Description: "Pulse the first logical cell.",
DeviceKinds: []device.LightType{device.LightTypeMatrix},
Params: []ParamDefinition{
{
Key: "color",
Label: "Color",
Kind: ParamColor,
Default: Color{Hue: 30, Saturation: 100, Brightness: 100, Kelvin: 3500},
},
},
New: func(config Config, caps Capabilities) (Effect, error) {
color, err := ColorParam(config.Params, "color")
if err != nil {
return nil, err
}
return &examplePulse{caps: caps, color: color}, nil
},
})
if err != nil {
fmt.Println(err)
return
}
effect, err := New(Config{ID: EffectID("example_pulse")}, Capabilities{
LightType: device.LightTypeMatrix,
Width: 2,
Height: 1,
})
if err != nil {
fmt.Println(err)
return
}
frame, ok := effect.Next(time.Second)
fmt.Println(ok)
fmt.Println(frame.Width)
Output: true 2
func RunSequence ¶
RunSequence runs effects in order through renderer.
func SetFrameColor ¶ added in v0.4.4
SetFrameColor sets the color at x,y and reports whether the coordinate is valid.
func ValidateFrame ¶ added in v0.4.4
ValidateFrame validates frame dimensions and color count.
Types ¶
type AdaptOptions ¶ added in v0.4.1
type AdaptOptions struct {
Reduction ReductionStrategy
}
AdaptOptions configures logical frame adaptation to a device surface.
type Capabilities ¶
type Capabilities struct {
LightType device.LightType
Zones int
Width int
Height int
ChainLength int
ChainOrientations []device.Orientation
HasColor bool
TemperatureRange device.TemperatureRange
}
Capabilities describes the logical rendering surface available to effects.
func CapabilitiesFromDevice ¶
func CapabilitiesFromDevice(d device.Device) Capabilities
CapabilitiesFromDevice derives effect capabilities from an existing device.
type Color ¶
Color is the logical HSBK color used by generated frames.
It aliases device.Color so frames can be used with existing lifxlan-go device and message APIs without conversion.
func BlankColor ¶ added in v0.4.4
func BlankColor() Color
BlankColor returns the standard off color used for blank frame cells.
func ColorParam ¶ added in v0.4.4
ColorParam returns a validated color parameter.
func FrameColor ¶ added in v0.4.4
FrameColor returns the color at x,y and whether the coordinate is valid.
func WithBrightness ¶
WithBrightness returns c with brightness clamped to the valid percentage range.
type Comet ¶ added in v0.6.4
type Comet struct {
// contains filtered or unexported fields
}
Comet moves a bright head with a fading tail over a dimmed background.
func NewComet ¶ added in v0.6.4
func NewComet(cfg CometConfig) *Comet
NewComet returns a Comet effect.
func (*Comet) FrameAtPhase ¶ added in v0.6.4
FrameAtPhase returns the frame at an absolute position in the comet cycle. During the first traversal, phase [0,1), the tail does not wrap ahead of the head. Later phases use steady-state wrapping, so a completed loop can trail across the cycle boundary.
type CometConfig ¶ added in v0.6.4
type CometConfig struct {
Capabilities Capabilities
Palette Palette
// Axis is the axis the comet travels along. Empty uses FlowAxisHorizontal.
Axis FlowAxis
// Period is how long one full traversal takes when advanced by Next. Zero uses
// defaultFlowPeriod. Ignored by FrameAtPhase.
Period time.Duration
// HeadSize is the number of logical cells kept at full head brightness. Zero
// uses defaultCometHeadSize.
HeadSize int
// TailSize is the number of logical cells fading behind the head. Zero uses
// defaultCometTailSize.
TailSize int
// BackgroundBrightnessFactor scales the background as a fraction of palette
// brightness. Zero uses defaultCometBackgroundBrightnessFactor.
BackgroundBrightnessFactor float64
// PeakBrightnessFactor scales the comet head as a fraction of palette
// brightness. Values above 1 boost the head and tail, clamped to 100. Zero
// uses defaultCometPeakBrightnessFactor.
PeakBrightnessFactor float64
// TailCurve shapes the tail falloff. Higher values drop the tail toward the
// background faster. Zero uses defaultCometTailCurve.
TailCurve float64
// TailSaturationFactor is the saturation retained at the end of the tail, as a
// fraction of accent saturation. Zero uses defaultCometTailSaturationFactor.
TailSaturationFactor float64
}
CometConfig configures a Comet effect.
type ConcentricFrames ¶
type ConcentricFrames struct {
// contains filtered or unexported fields
}
ConcentricFrames draws matrix borders according to Direction.
func NewConcentricFrames ¶
func NewConcentricFrames(cfg ConcentricFramesConfig) *ConcentricFrames
NewConcentricFrames returns a ConcentricFrames effect.
type ConcentricFramesConfig ¶
type ConcentricFramesConfig struct {
Capabilities Capabilities
Direction Direction
Colors []Color
Cycles int
}
ConcentricFramesConfig configures a ConcentricFrames effect.
type DeviceFrame ¶ added in v0.4.1
type DeviceFrame struct {
ChainIndex int
Colors []Color
SendWidth int
Height int
Orientation device.Orientation
Duration time.Duration
}
DeviceFrame is a packet-independent frame adapted to a device surface.
For matrix devices, ChainIndex identifies the matrix chain, SendWidth/Height describe the physical send layout, and Orientation preserves the chain orientation for later packet rendering. For non-matrix devices, ChainIndex is 0 and Orientation is OrientationRightSideUp.
func AdaptFrameToSurface ¶ added in v0.4.1
func AdaptFrameToSurface(frame Frame, surface device.Surface, opts AdaptOptions) ([]DeviceFrame, error)
AdaptFrameToSurface adapts a target-free logical frame to a device surface.
Matrix adaptation samples colors from the logical frame by surface cell coordinates. Cells outside the logical frame are padded with blank colors, cells outside the surface are cropped, and hidden matrix cells are blanked. Adapted matrix DeviceFrames keep packet/send dimensions and do not apply orientation; Orientation is carried so a later renderer can rotate for the physical device.
type Direction ¶
type Direction int
Direction defines how ConcentricFrames moves between matrix borders.
const ( // DirectionInwards draws borders from the outside in. DirectionInwards Direction = iota // DirectionOutwards draws borders from the inside out. DirectionOutwards // DirectionInOut draws borders from the outside in, then back out. DirectionInOut // DirectionOutIn draws borders from the inside out, then back in. DirectionOutIn )
type EffectDefinition ¶ added in v0.4.2
type EffectDefinition struct {
ID EffectID
Label string
Description string
DeviceKinds []device.LightType
Params []ParamDefinition
New func(Config, Capabilities) (Effect, error)
}
EffectDefinition describes a registered effect and its configurable params.
func Definition ¶ added in v0.4.2
func Definition(id EffectID) (EffectDefinition, bool)
Definition returns the definition for id.
func Definitions ¶ added in v0.4.2
func Definitions() []EffectDefinition
Definitions returns registered definitions in deterministic ID order.
type EffectID ¶ added in v0.4.2
type EffectID string
EffectID identifies a registered effect.
const ( // EffectComet identifies the Comet effect. EffectComet EffectID = "comet" // EffectSparkle identifies the Sparkle effect. EffectSparkle EffectID = "sparkle" // EffectScanner identifies the Scanner effect. EffectScanner EffectID = "scanner" // EffectSolid identifies the Solid effect. EffectSolid EffectID = "solid" // EffectGradient identifies the Gradient effect. EffectGradient EffectID = "gradient" // EffectGradientDrift identifies the GradientDrift effect. EffectGradientDrift EffectID = "gradient_drift" // EffectPaletteSweep identifies the PaletteSweep effect. EffectPaletteSweep EffectID = "palette_sweep" // EffectSweep identifies the Sweep effect. EffectSweep EffectID = "sweep" // EffectWaterfall identifies the Waterfall matrix effect. EffectWaterfall EffectID = "waterfall" // EffectRockets identifies the Rockets matrix effect. EffectRockets EffectID = "rockets" // EffectSnake identifies the Snake matrix effect. EffectSnake EffectID = "snake" // EffectWorm identifies the Worm matrix effect. EffectWorm EffectID = "worm" // EffectWave identifies the Wave matrix effect. EffectWave EffectID = "wave" // EffectConcentricFrames identifies the ConcentricFrames matrix effect. EffectConcentricFrames EffectID = "concentric_frames" // EffectFlow identifies the Flow effect. EffectFlow EffectID = "flow" // EffectRing identifies the Ring matrix effect. EffectRing EffectID = "ring" )
type Flow ¶ added in v0.6.0
type Flow struct {
// contains filtered or unexported fields
}
Flow travels a brightness crest across the surface while palette colors scroll along with it, so every zone or pixel takes part.
Sweep, by contrast, lights a single cell over a flat background. On a long strip that reads as a dot rather than motion, and it leaves most of the surface holding one color.
func (*Flow) FrameAtPhase ¶ added in v0.6.0
FrameAtPhase returns the frame at an absolute position in the cycle, where whole numbers are the same point in the traversal. Phase may run backwards: passing a decreasing sequence reverses the travel, and negative values are valid.
This exists for callers that build a timeline ahead of playback rather than streaming frames. They know the position of every event they are about to emit and need the frame for it, which stepping an effect forward cannot express: two events at the same moment, or events generated out of order, would each advance the effect and drift from the position they were meant to represent.
type FlowAxis ¶ added in v0.6.0
type FlowAxis string
FlowAxis is the axis a crest travels along. It is deliberately not called a direction: Direction already describes inward and outward travel for concentric effects, and this chooses an axis rather than a sense along one.
const ( // FlowAxisHorizontal travels along x, the length of a strip. FlowAxisHorizontal FlowAxis = "horizontal" // FlowAxisVertical travels along y. A single-row surface has no y to travel, so // it behaves as horizontal there. FlowAxisVertical FlowAxis = "vertical" // FlowAxisDiagonal travels along x+y, crossing a matrix corner to corner. FlowAxisDiagonal FlowAxis = "diagonal" )
type FlowBrightnessMode ¶ added in v0.6.2
type FlowBrightnessMode string
FlowBrightnessMode controls whether Flow modulates brightness or only scrolls palette colors.
const ( // FlowBrightnessCrest scrolls colors and applies a moving brightness crest. FlowBrightnessCrest FlowBrightnessMode = "crest" // FlowBrightnessConstant scrolls colors without changing their brightness. FlowBrightnessConstant FlowBrightnessMode = "constant" )
type FlowConfig ¶ added in v0.6.0
type FlowConfig struct {
Capabilities Capabilities
Palette Palette
// Axis is the axis the crest travels along. Empty uses FlowAxisHorizontal.
Axis FlowAxis
// Direction controls the travel direction along Axis. Empty uses
// FlowDirectionForward.
Direction FlowDirection
// Period is how long one full traversal takes when the effect is advanced by
// Next. Zero uses defaultFlowPeriod. Ignored by FrameAtPhase, which is given a
// position directly.
Period time.Duration
// Floor is how lit the trough stays, as a fraction of the crest. Zero uses
// defaultFlowFloor.
Floor float64
// BrightnessMode controls whether brightness moves as a crest or stays at the
// palette color brightness. Empty uses FlowBrightnessCrest.
BrightnessMode FlowBrightnessMode
// Sampling controls whether palette colors step cell-by-cell or interpolate
// between adjacent stops. Empty uses FlowSamplingStep.
Sampling FlowSamplingMode
}
FlowConfig configures a Flow effect.
type FlowDirection ¶ added in v0.6.4
type FlowDirection string
FlowDirection controls the direction a flow travels along its axis.
const ( // FlowDirectionForward moves the visible pattern from lower position indexes // toward higher position indexes. FlowDirectionForward FlowDirection = "forward" // FlowDirectionReverse moves the visible pattern from higher position indexes // toward lower position indexes. FlowDirectionReverse FlowDirection = "reverse" )
type FlowSamplingMode ¶ added in v0.6.4
type FlowSamplingMode string
FlowSamplingMode controls how palette colors are sampled between logical cells.
const ( // FlowSamplingStep uses whole-cell palette steps, preserving existing output. FlowSamplingStep FlowSamplingMode = "step" // FlowSamplingInterpolate blends adjacent palette stops for sub-cell motion. FlowSamplingInterpolate FlowSamplingMode = "interpolate" )
type Frame ¶
Frame is a target-free logical color frame.
func FrameFromDeviceState ¶ added in v0.4.6
FrameFromDeviceState converts cached device color state into a logical Frame.
The function is pure: it does not query the network or mutate d. Matrix devices are converted through device.SurfaceFromDevice so chain layout, hidden cells, send width, and orientation are interpreted consistently with AdaptFrameToSurface.
type FrameAt ¶
FrameAt is a logical frame at a deterministic timeline offset.
func Render ¶
Render produces timestamped frames from effect using a fixed deterministic step.
Example ¶
palette := Palette{
Base: []Color{
{Hue: 0, Saturation: 100, Brightness: 50, Kelvin: 3500},
{Hue: 120, Saturation: 100, Brightness: 50, Kelvin: 3500},
},
}
effect := NewGradient(GradientConfig{
Capabilities: Capabilities{LightType: device.LightTypeMultiZone, Zones: 2},
Palette: palette,
})
frames := Render(effect, time.Second, 2*time.Second)
fmt.Println(len(frames))
fmt.Println(frames[0].At)
fmt.Println(frames[0].Frame.Width)
Output: 2 0s 2
type Gradient ¶
type Gradient struct {
// contains filtered or unexported fields
}
Gradient fills the logical surface with deterministic palette stops.
func NewGradient ¶
func NewGradient(cfg GradientConfig) *Gradient
NewGradient returns a Gradient effect.
type GradientConfig ¶
type GradientConfig struct {
Capabilities Capabilities
Palette Palette
}
GradientConfig configures a Gradient effect.
type GradientDrift ¶ added in v0.6.4
type GradientDrift struct {
// contains filtered or unexported fields
}
GradientDrift scrolls palette colors across a multizone or matrix surface without changing palette brightness.
func NewGradientDrift ¶ added in v0.6.4
func NewGradientDrift(cfg GradientDriftConfig) *GradientDrift
NewGradientDrift returns a GradientDrift effect.
func (*GradientDrift) FrameAtPhase ¶ added in v0.6.4
func (g *GradientDrift) FrameAtPhase(phase float64, duration time.Duration) Frame
FrameAtPhase returns the frame at an absolute position in the drift cycle. Whole phases address the same palette position, and negative phases wrap.
func (*GradientDrift) Next ¶ added in v0.6.4
func (g *GradientDrift) Next(dt time.Duration) (Frame, bool)
Next advances the effect by dt and returns the frame at the new position.
func (*GradientDrift) Reset ¶ added in v0.6.4
func (g *GradientDrift) Reset()
Reset returns the effect to the start of its cycle.
type GradientDriftConfig ¶ added in v0.6.4
type GradientDriftConfig struct {
Capabilities Capabilities
Palette Palette
// Axis is the axis the palette scrolls along. Empty uses FlowAxisHorizontal.
Axis FlowAxis
// Direction controls the travel direction along Axis. Empty uses
// FlowDirectionForward.
Direction FlowDirection
// Period is how long one full drift takes when advanced by Next. Zero uses
// defaultFlowPeriod. Ignored by FrameAtPhase.
Period time.Duration
// Sampling controls whether palette colors step cell-by-cell or interpolate
// between adjacent stops. Empty uses FlowSamplingStep.
Sampling FlowSamplingMode
}
GradientDriftConfig configures a GradientDrift effect.
type Palette ¶
Palette groups colors for deterministic effects.
func PaletteParam ¶ added in v0.4.4
PaletteParam returns a validated palette parameter.
func (Palette) AccentAt ¶
AccentAt returns a deterministic accent for index, falling back to ColorAt.
func (Palette) Background ¶
Background returns the first background color, falling back to Secondary.
func (Palette) ColorAt ¶
ColorAt returns a deterministic color for index from base colors followed by accents.
func (Palette) GradientStops ¶
GradientStops returns count deterministic stops from backgrounds, base colors, then accents.
type PaletteSweep ¶ added in v0.6.4
type PaletteSweep struct {
// contains filtered or unexported fields
}
PaletteSweep moves a multi-color band over a dim drifting gradient background.
func NewPaletteSweep ¶ added in v0.6.4
func NewPaletteSweep(cfg PaletteSweepConfig) *PaletteSweep
NewPaletteSweep returns a PaletteSweep effect.
func (*PaletteSweep) FrameAtPhase ¶ added in v0.6.4
func (p *PaletteSweep) FrameAtPhase(phase float64, duration time.Duration) Frame
FrameAtPhase returns the frame at an absolute position in the sweep cycle. Whole phases address the same point, and negative phases wrap.
func (*PaletteSweep) Next ¶ added in v0.6.4
func (p *PaletteSweep) Next(dt time.Duration) (Frame, bool)
Next advances the effect by dt and returns the frame at the new position.
func (*PaletteSweep) Reset ¶ added in v0.6.4
func (p *PaletteSweep) Reset()
Reset returns the effect to the start of its cycle.
type PaletteSweepConfig ¶ added in v0.6.4
type PaletteSweepConfig struct {
Capabilities Capabilities
Palette Palette
// Axis is the axis the band travels along. Empty uses FlowAxisHorizontal.
Axis FlowAxis
// Direction controls the travel direction along Axis. Empty uses
// FlowDirectionForward.
Direction FlowDirection
// Period is how long one full traversal takes when advanced by Next. Zero uses
// defaultFlowPeriod. Ignored by FrameAtPhase.
Period time.Duration
// BandSize is the moving band width in logical cells. If zero, BandFraction is
// used instead.
BandSize int
// BandFraction is the moving band width as a fraction of the surface span.
// Zero uses defaultPaletteSweepBandFraction.
BandFraction float64
// BackgroundBrightnessFactor scales the drifting background gradient as a
// fraction of palette brightness. Zero uses
// defaultPaletteSweepBackgroundBrightnessFactor.
BackgroundBrightnessFactor float64
// TailBrightnessFactor is the brightness retained at the trailing edge of the
// band. Zero uses defaultPaletteSweepTailBrightnessFactor.
TailBrightnessFactor float64
// Sampling controls whether gradient colors step cell-by-cell or interpolate
// between adjacent stops. Empty uses FlowSamplingStep.
Sampling FlowSamplingMode
}
PaletteSweepConfig configures a PaletteSweep effect.
type ParamChoice ¶ added in v0.4.2
ParamChoice describes one allowed choice value.
type ParamDefinition ¶ added in v0.4.2
type ParamDefinition struct {
Key string
Label string
Kind ParamKind
Default any
Min *float64
Max *float64
Step *float64
Choices []ParamChoice
Required bool
}
ParamDefinition describes one effect configuration parameter.
type ParamKind ¶ added in v0.4.2
type ParamKind string
ParamKind identifies a configurable parameter type.
const ( // ParamNumber is a numeric parameter. ParamNumber ParamKind = "number" // ParamBool is a boolean parameter. ParamBool ParamKind = "bool" // ParamChoiceKind is a string choice parameter. ParamChoiceKind ParamKind = "choice" // ParamColor is a Color parameter. ParamColor ParamKind = "color" // ParamPalette is a Palette parameter. ParamPalette ParamKind = "palette" // ParamDuration is a time.Duration parameter. ParamDuration ParamKind = "duration" )
type PhaseEffect ¶ added in v0.6.0
PhaseEffect can return a deterministic frame for an absolute cycle position.
Whole phases address the same point in the effect cycle, and negative phases wrap. This is useful for offline timeline generation where frames may be requested out of order or more than once for the same timestamp.
type Random ¶ added in v0.4.4
type Random struct {
// contains filtered or unexported fields
}
Random is a deterministic random source for effects.
Effects that need random-looking output should keep their own Random and call Reset from the effect's Reset method.
func NewRandom ¶ added in v0.4.4
NewRandom returns a deterministic random source initialized with seed.
func (*Random) Color ¶ added in v0.4.4
Color returns a deterministic color from colors.
If colors is empty, Color returns DefaultColor.
func (*Random) IntN ¶ added in v0.4.4
IntN returns a deterministic integer in [0, n).
If n <= 0, IntN returns 0.
func (*Random) PaletteColor ¶ added in v0.4.4
PaletteColor returns a deterministic color from palette colors.
Base colors are considered first, followed by accents and backgrounds. If palette does not define any colors, PaletteColor returns DefaultColor.
type ReductionStrategy ¶ added in v0.4.1
type ReductionStrategy int
ReductionStrategy defines how many logical colors collapse into one color.
const ( // ReductionFirst uses the first logical color in the reduced range. ReductionFirst ReductionStrategy = iota // ReductionAverage averages hue circularly and other color fields linearly. ReductionAverage )
type Ring ¶ added in v0.6.0
type Ring struct {
// contains filtered or unexported fields
}
Ring expands a soft ring from the center of a matrix surface.
func (*Ring) FrameAtPhase ¶ added in v0.6.0
FrameAtPhase returns the frame at an absolute position in the cycle, where whole numbers are the same point in the expansion. Phase may be negative and wraps to the equivalent forward position.
type RingConfig ¶ added in v0.6.0
type RingConfig struct {
Capabilities Capabilities
Palette Palette
// Period is how long one full expansion takes when the effect is advanced by
// Next. Zero uses defaultRingPeriod. Ignored by FrameAtPhase, which is given a
// position directly.
Period time.Duration
// Width is the ring thickness in logical cells. Zero uses defaultRingWidth.
Width float64
// Floor is how lit the background stays, as a fraction of the ring brightness.
// Zero uses defaultRingFloor.
Floor float64
}
RingConfig configures a Ring effect.
type Rockets ¶
type Rockets struct {
// contains filtered or unexported fields
}
Rockets moves a single pixel through the matrix in row-major order.
type RocketsConfig ¶
type RocketsConfig struct {
Capabilities Capabilities
Colors []Color
Cycles int
}
RocketsConfig configures a Rockets effect.
type Runner ¶
Runner runs an effect live through a target-bound renderer.
type Scanner ¶ added in v0.6.4
type Scanner struct {
// contains filtered or unexported fields
}
Scanner moves a soft band back and forth across a multizone or matrix surface.
func NewScanner ¶ added in v0.6.4
func NewScanner(cfg ScannerConfig) *Scanner
NewScanner returns a Scanner effect.
func (*Scanner) FrameAtPhase ¶ added in v0.6.4
FrameAtPhase returns the frame at an absolute position in the scanner cycle. Whole phases address the same point, negative phases wrap, and half phases are the opposite end of the bounce.
type ScannerConfig ¶ added in v0.6.4
type ScannerConfig struct {
Capabilities Capabilities
Palette Palette
// Axis is the axis the scanner travels along. Empty uses FlowAxisHorizontal.
Axis FlowAxis
// Period is how long one full bounce cycle takes when advanced by Next. Zero
// uses defaultFlowPeriod. Ignored by FrameAtPhase.
Period time.Duration
// Width is the soft band width in logical cells. Zero uses defaultScannerWidth.
Width float64
// BackgroundBrightnessFactor scales the background as a fraction of palette
// brightness. Zero uses defaultScannerBackgroundBrightnessFactor.
BackgroundBrightnessFactor float64
// PeakBrightnessFactor scales the scan peak as a fraction of palette
// brightness. Values above 1 boost the peak, clamped to 100. Zero uses
// defaultScannerPeakBrightnessFactor.
PeakBrightnessFactor float64
}
ScannerConfig configures a Scanner effect.
type Snake ¶
type Snake struct {
// contains filtered or unexported fields
}
Snake moves a trailing segment through a serpentine matrix path.
type SnakeConfig ¶
type SnakeConfig struct {
Capabilities Capabilities
Size int
Color Color
Cycles int
}
SnakeConfig configures a Snake effect.
type Solid ¶
type Solid struct {
// contains filtered or unexported fields
}
Solid fills every logical zone or pixel with the same color.
type SolidConfig ¶
type SolidConfig struct {
Capabilities Capabilities
Color Color
}
SolidConfig configures a Solid effect.
type Sparkle ¶ added in v0.6.4
type Sparkle struct {
// contains filtered or unexported fields
}
Sparkle lights deterministic, random-looking cells over a dimmed background.
func NewSparkle ¶ added in v0.6.4
func NewSparkle(cfg SparkleConfig) *Sparkle
NewSparkle returns a Sparkle effect.
func (*Sparkle) FrameAtPhase ¶ added in v0.6.4
FrameAtPhase returns the frame at an absolute position in the sparkle cycle. Whole phases address the same point, and negative phases wrap.
type SparkleConfig ¶ added in v0.6.4
type SparkleConfig struct {
Capabilities Capabilities
Palette Palette
// Density is the fraction of a cycle where each cell is lit. Zero uses
// defaultSparkleDensity.
Density float64
// Decay controls how quickly each sparkle fades. Larger values fade faster.
// Zero uses defaultSparkleDecay.
Decay float64
// BackgroundFloor is how lit the background stays as a fraction of palette
// brightness. Zero uses defaultSparkleFloor.
BackgroundFloor float64
// Floor is a compatibility alias for BackgroundFloor.
Floor float64
// PeakBrightnessFactor scales active sparkle brightness. Values above 1 boost
// sparkles above palette brightness, clamped to 100. Zero uses
// defaultSparklePeak.
PeakBrightnessFactor float64
// Seed changes the deterministic sparkle pattern.
Seed uint64
// Period is how long one full sparkle cycle takes when advanced by Next. Zero
// uses defaultSparklePeriod. Ignored by FrameAtPhase.
Period time.Duration
}
SparkleConfig configures a Sparkle effect.
type Sweep ¶
type Sweep struct {
// contains filtered or unexported fields
}
Sweep moves one accent color across a background frame.
type SweepConfig ¶
type SweepConfig struct {
Capabilities Capabilities
Palette Palette
}
SweepConfig configures a Sweep effect.
type Waterfall ¶
type Waterfall struct {
// contains filtered or unexported fields
}
Waterfall fills rows cumulatively with a centered color strip.
func NewWaterfall ¶
func NewWaterfall(cfg WaterfallConfig) *Waterfall
NewWaterfall returns a Waterfall effect.
type WaterfallConfig ¶
type WaterfallConfig struct {
Capabilities Capabilities
Colors []Color
Cycles int
}
WaterfallConfig configures a Waterfall effect.
type Wave ¶ added in v0.4.6
type Wave struct {
// contains filtered or unexported fields
}
Wave displaces matrix columns upward as a wave front moves across the frame.
type WaveConfig ¶ added in v0.4.6
type WaveConfig struct {
Capabilities Capabilities
Initial *Frame
Palette Palette
Amplitude int
Width int
Waves int
Cycles int
}
WaveConfig configures a Wave effect.
type Worm ¶
type Worm struct {
// contains filtered or unexported fields
}
Worm moves short batches of pixels through a serpentine matrix path.
type WormConfig ¶
type WormConfig struct {
Capabilities Capabilities
Size int
Color Color
Cycles int
}
WormConfig configures a Worm effect.