package effects import ( "fmt" "git.aiterp.net/lucifer3/server/device" "time" ) type Pattern struct { States []device.State `json:"states"` AnimationMS int64 `json:"animationMs"` } func (e Pattern) State(index, _, round int) device.State { if len(e.States) == 0 { return device.State{} } return e.States[(index+round)%len(e.States)] } func (e Pattern) Frequency() time.Duration { return time.Duration(e.AnimationMS) * time.Millisecond } func (e Pattern) EffectDescription() string { return fmt.Sprintf("Pattern(states:%s, anim:%dms)", statesDescription(e.States), e.AnimationMS) }