forked from jmhobbs/terminal-parrot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw.go
35 lines (28 loc) · 725 Bytes
/
draw.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
package main
import "github.com/nsf/termbox-go"
import "strings"
var frame_index = 0
func reverse(lines []string) []string {
newLines := make([]string, len(lines))
for i, j := 0, len(lines)-1; i < j; i, j = i+1, j-1 {
newLines[i], newLines[j] = lines[j], lines[i]
}
return newLines
}
func draw(orientation string) {
termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
lines := strings.Split(frames[frame_index], "\n")
if orientation == "aussie" {
lines = reverse(lines)
}
for x, line := range lines {
for y, cell := range line {
termbox.SetCell(y, x, cell, colors[frame_index], termbox.ColorDefault)
}
}
termbox.Flush()
frame_index++
if frame_index == num_frames {
frame_index = 0
}
}