-
Notifications
You must be signed in to change notification settings - Fork 217
/
Copy pathframes.go
66 lines (59 loc) · 1.52 KB
/
frames.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package frames
import "time"
type FrameType struct {
GetFrame func(int) string
GetLength func() int
GetSleep func() time.Duration
}
// 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))]
}
}
// 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
}
}
// Given frames, create a FrameType with those frames
func DefaultFrameType(frames []string) FrameType {
return FrameType{
GetFrame: DefaultGetFrame(frames),
GetLength: DefaultGetLength(frames),
GetSleep: DefaultGetSleep(),
}
}
var FrameMap = map[string]FrameType{
"batman": Batman,
"batman-running": BNR,
"bnr": BNR,
"can-you-hear-me": Rick,
"clock": Clock,
"coin": Coin,
"donut": Donut,
"dvd": Dvd,
"forrest": Forrest,
"hes": HES,
"knot": TorusKnot,
"nyan": Nyan,
"parrot": Parrot,
"playstation": PlayStation,
"rick": Rick,
"spidyswing": Spidy,
"torus-knot": TorusKnot,
"purdue": Purdue,
"as": AStrend,
"bomb": Bomb,
"maxwell": Maxwell,
"earth": Earth,
"kitty": Kitty,
"india": India,
}