forked from hugomd/ascii-live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frames.go
38 lines (33 loc) · 868 Bytes
/
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
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,
}