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.
24 lines
548 B
24 lines
548 B
package effects
|
|
|
|
import (
|
|
"fmt"
|
|
"git.aiterp.net/lucifer3/server/device"
|
|
"time"
|
|
)
|
|
|
|
type Pattern struct {
|
|
States []device.State `json:"states,omitempty"`
|
|
ShiftMS int64 `json:"shiftMs,omitempty"`
|
|
}
|
|
|
|
func (p Pattern) State(index, round, _ int) device.State {
|
|
return p.States[(index+round)%len(p.States)]
|
|
}
|
|
|
|
func (p Pattern) Frequency() time.Duration {
|
|
return time.Duration(p.ShiftMS) * time.Millisecond
|
|
}
|
|
|
|
func (p Pattern) EffectDescription() string {
|
|
return fmt.Sprintf("Pattern(len:%d, animation:%dms)", len(p.States), p.ShiftMS)
|
|
}
|