You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
633 B
28 lines
633 B
package effects
|
|
|
|
import (
|
|
"fmt"
|
|
"git.aiterp.net/lucifer3/server/device"
|
|
"time"
|
|
)
|
|
|
|
type Pattern struct {
|
|
States []device.State `json:"states,omitempty"`
|
|
AnimationMS int64 `json:"animationMs,omitempty"`
|
|
}
|
|
|
|
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)
|
|
}
|