2019-11-19 16:51:48 +11:00
|
|
|
package frames
|
|
|
|
|
|
2023-10-08 17:24:39 +11:00
|
|
|
import "time"
|
|
|
|
|
|
2019-11-19 16:51:48 +11:00
|
|
|
type FrameType struct {
|
|
|
|
|
GetFrame func(int) string
|
|
|
|
|
GetLength func() int
|
2023-10-08 17:24:39 +11:00
|
|
|
GetSleep func() time.Duration
|
2019-11-19 16:51:48 +11: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 17:04:21 +11:00
|
|
|
return frames[i%(len(frames))]
|
2019-11-19 16:51:48 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create a function that returns frame length
|
|
|
|
|
func DefaultGetLength(frames []string) func() int {
|
|
|
|
|
return func() int {
|
|
|
|
|
return len(frames)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-08 17:24:39 +11:00
|
|
|
// Sleep time between frames
|
|
|
|
|
func DefaultGetSleep() func() time.Duration {
|
|
|
|
|
return func() time.Duration {
|
|
|
|
|
return time.Millisecond * 70
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-19 16:51:48 +11: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 17:24:39 +11:00
|
|
|
GetSleep: DefaultGetSleep(),
|
2019-11-19 16:51:48 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var FrameMap = map[string]FrameType{
|
2023-03-22 15:09:07 +01:00
|
|
|
"batman": Batman,
|
2023-06-19 06:35:20 +05:30
|
|
|
"batman-running": BNR,
|
|
|
|
|
"bnr": BNR,
|
2023-10-08 17:11:12 +11:00
|
|
|
"can-you-hear-me": Rick,
|
|
|
|
|
"clock": Clock,
|
|
|
|
|
"coin": Coin,
|
|
|
|
|
"donut": Donut,
|
2023-10-08 17:24:49 +11:00
|
|
|
"dvd": Dvd,
|
2023-10-08 17:11:12 +11:00
|
|
|
"forrest": Forrest,
|
2023-10-01 15:34:11 +05:30
|
|
|
"hes": HES,
|
2023-10-08 17:11:12 +11:00
|
|
|
"knot": TorusKnot,
|
|
|
|
|
"nyan": Nyan,
|
|
|
|
|
"parrot": Parrot,
|
|
|
|
|
"playstation": PlayStation,
|
|
|
|
|
"rick": Rick,
|
|
|
|
|
"spidyswing": Spidy,
|
|
|
|
|
"torus-knot": TorusKnot,
|
2025-01-05 05:44:18 +00:00
|
|
|
"purdue": Purdue,
|
2025-01-05 16:01:28 +11:00
|
|
|
"as": AStrend,
|
|
|
|
|
"bomb": Bomb,
|
2024-03-09 13:08:46 +06:00
|
|
|
"maxwell": Maxwell,
|
2023-11-24 22:13:12 -03:00
|
|
|
"earth": Earth,
|
|
|
|
|
"kitty": Kitty,
|
2023-10-24 14:46:02 +05:30
|
|
|
"india": India,
|
2025-03-09 19:45:45 +01:00
|
|
|
"brittany": Brittany,
|
2019-11-19 16:51:48 +11:00
|
|
|
}
|