mirror of
https://github.com/hugomd/ascii-live
synced 2025-03-30 04:49:06 +02:00
39 lines
868 B
Go
39 lines
868 B
Go
package frames
|
|
|
|
type FrameType struct {
|
|
GetFrame func(int) string
|
|
GetLength func() int
|
|
}
|
|
|
|
// Create a function that returns the next frame, based on length
|
|
func DefaultGetFrame(frames []string) func(int) string {
|
|
return func(i int) string {
|
|
return frames[i%(len(frames)-1)]
|
|
}
|
|
}
|
|
|
|
// Create a function that returns frame length
|
|
func DefaultGetLength(frames []string) func() int {
|
|
return func() int {
|
|
return len(frames)
|
|
}
|
|
}
|
|
|
|
// Given frames, create a FrameType with those frames
|
|
func DefaultFrameType(frames []string) FrameType {
|
|
return FrameType{
|
|
GetFrame: DefaultGetFrame(frames),
|
|
GetLength: DefaultGetLength(frames),
|
|
}
|
|
}
|
|
|
|
var FrameMap = map[string]FrameType{
|
|
"forrest": Forrest,
|
|
"parrot": Parrot,
|
|
"clock": Clock,
|
|
"nyan": Nyan,
|
|
"rick": Rick,
|
|
"can-you-hear-me": Rick,
|
|
"donut": Donut,
|
|
}
|