2019-11-19 05:51:48 +00:00
|
|
|
package frames
|
|
|
|
|
2023-10-08 06:24:39 +00:00
|
|
|
import "time"
|
|
|
|
|
2019-11-19 05:51:48 +00:00
|
|
|
type FrameType struct {
|
|
|
|
GetFrame func(int) string
|
|
|
|
GetLength func() int
|
2023-10-08 06:24:39 +00:00
|
|
|
GetSleep func() time.Duration
|
2019-11-19 05:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create a function that returns the next frame, based on length
|
|
|
|
func DefaultGetFrame(frames []string) func(int) string {
|
|
|
|
return func(i int) string {
|
2023-10-08 06:04:21 +00:00
|
|
|
return frames[i%(len(frames))]
|
2019-11-19 05:51:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a function that returns frame length
|
|
|
|
func DefaultGetLength(frames []string) func() int {
|
|
|
|
return func() int {
|
|
|
|
return len(frames)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-08 06:24:39 +00:00
|
|
|
// Sleep time between frames
|
|
|
|
func DefaultGetSleep() func() time.Duration {
|
|
|
|
return func() time.Duration {
|
|
|
|
return time.Millisecond * 70
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-19 05:51:48 +00:00
|
|
|
// Given frames, create a FrameType with those frames
|
|
|
|
func DefaultFrameType(frames []string) FrameType {
|
|
|
|
return FrameType{
|
|
|
|
GetFrame: DefaultGetFrame(frames),
|
|
|
|
GetLength: DefaultGetLength(frames),
|
2023-10-08 06:24:39 +00:00
|
|
|
GetSleep: DefaultGetSleep(),
|
2019-11-19 05:51:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var FrameMap = map[string]FrameType{
|
2023-03-22 14:09:07 +00:00
|
|
|
"batman": Batman,
|
2023-06-19 01:05:20 +00:00
|
|
|
"batman-running": BNR,
|
|
|
|
"bnr": BNR,
|
2023-10-08 06:11:12 +00:00
|
|
|
"can-you-hear-me": Rick,
|
|
|
|
"clock": Clock,
|
|
|
|
"coin": Coin,
|
|
|
|
"donut": Donut,
|
2023-10-08 06:24:49 +00:00
|
|
|
"dvd": Dvd,
|
2023-10-08 06:11:12 +00:00
|
|
|
"forrest": Forrest,
|
2023-10-01 10:04:11 +00:00
|
|
|
"hes": HES,
|
2023-10-08 06:11:12 +00:00
|
|
|
"knot": TorusKnot,
|
|
|
|
"nyan": Nyan,
|
|
|
|
"parrot": Parrot,
|
|
|
|
"playstation": PlayStation,
|
|
|
|
"rick": Rick,
|
|
|
|
"spidyswing": Spidy,
|
|
|
|
"torus-knot": TorusKnot,
|
2024-11-06 03:52:42 +00:00
|
|
|
"purdue": Purdue,
|
2019-11-19 05:51:48 +00:00
|
|
|
}
|