-
Notifications
You must be signed in to change notification settings - Fork 2
/
anim.go
39 lines (32 loc) · 901 Bytes
/
anim.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
package image
import (
"fmt"
"github.com/dimaglushkov/contriseg/internal"
"github.com/dimaglushkov/contriseg/internal/image/animation"
"strings"
)
type AnimationFunc func(cal internal.Calendar) []internal.Calendar
var animationsMap = map[string]AnimationFunc{
"bfs": animation.DrawBFS,
"move": animation.MoveColLeft,
"cbc": animation.DrawColByColLeft,
}
func GetAvailableAnimations() []string {
anims := make([]string, 0, len(animationsMap))
for k := range animationsMap {
anims = append(anims, k)
}
return anims
}
func GetAnimationIterator(animAlias string) (AnimationFunc, error) {
var anim AnimationFunc
var ok bool
if anim, ok = animationsMap[strings.ToLower(animAlias)]; !ok {
return nil, fmt.Errorf(
"unknown animation: %s, available animations are: %s (case insesnsetive)",
animAlias,
strings.Join(GetAvailableAnimations(), ", "),
)
}
return anim, nil
}