ascii-live/frames/frames.go

60 lines
1.3 KiB
Go
Raw Normal View History

2019-11-19 06:51:48 +01:00
package frames
import "time"
2019-11-19 06:51:48 +01:00
type FrameType struct {
GetFrame func(int) string
GetLength func() int
GetSleep func() time.Duration
2019-11-19 06:51:48 +01:00
}
// 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))]
2019-11-19 06:51:48 +01:00
}
}
// Create a function that returns frame length
func DefaultGetLength(frames []string) func() int {
return func() int {
return len(frames)
}
}
// Sleep time between frames
func DefaultGetSleep() func() time.Duration {
return func() time.Duration {
return time.Millisecond * 70
}
}
2019-11-19 06:51:48 +01:00
// Given frames, create a FrameType with those frames
func DefaultFrameType(frames []string) FrameType {
return FrameType{
GetFrame: DefaultGetFrame(frames),
GetLength: DefaultGetLength(frames),
GetSleep: DefaultGetSleep(),
2019-11-19 06:51:48 +01:00
}
}
var FrameMap = map[string]FrameType{
"batman": Batman,
"batman-running": BNR,
"bnr": BNR,
2023-10-08 08:11:12 +02:00
"can-you-hear-me": Rick,
"clock": Clock,
"coin": Coin,
"donut": Donut,
2023-10-08 08:24:49 +02:00
"dvd": Dvd,
2023-10-08 08:11:12 +02:00
"forrest": Forrest,
2023-10-01 12:04:11 +02:00
"hes": HES,
2023-10-08 08:11:12 +02:00
"knot": TorusKnot,
"nyan": Nyan,
"parrot": Parrot,
"playstation": PlayStation,
"rick": Rick,
"spidyswing": Spidy,
"torus-knot": TorusKnot,
2019-11-19 06:51:48 +01:00
}