-
Notifications
You must be signed in to change notification settings - Fork 0
/
colors.go
68 lines (57 loc) · 1.61 KB
/
colors.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
67
68
package main
import (
"strconv"
"github.com/gdamore/tcell/v2"
)
var (
styleDefault = tcell.StyleDefault
styleGreen = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorGreen)
styleGreenBold = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorGreen).Bold(true)
styleWhiteBold = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorWhite).Bold(true)
styleBrown = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.Color94)
styleBrownBold = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.Color94).Bold(true)
styleGray = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorGray)
)
// TODO: check supported number of colors
// TODO: color schemes? (8-col, original cbonsai, monochrome)
// based on type of tree, determine what color a branch should be
func chooseColor(kind branch) tcell.Style {
switch kind {
case dying:
if rand.Int()%10 == 0 {
return styleGreenBold
} else {
return styleGreen
}
case dead:
if rand.Int()%3 == 0 {
return styleGreenBold
} else {
return styleGreen
}
// trunk | shootLeft | shootRight
default:
if rand.Int()%2 == 0 {
return styleBrownBold
} else {
return styleBrown
}
}
}
func listColors(sc *screen) {
// num := sc.Colors()
sc.x = 0
sc.y = 0
c := 0
for col := tcell.ColorValid; col < tcell.ColorYellowGreen; col++ {
style := tcell.StyleDefault.Background(tcell.ColorReset).Foreground(col).Bold(true)
sc.draw(strconv.FormatUint(uint64(col), 10), style)
sc.x++
c++
if c%8 == 0 {
sc.x = 0
sc.y++
}
}
evDrawn(sc)
}