2 changed files with 54 additions and 4 deletions
@ -0,0 +1,24 @@ |
|||
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) |
|||
} |
Reference in new issue
xxxxxxxxxx