-
Notifications
You must be signed in to change notification settings - Fork 0
/
palette.go
49 lines (40 loc) · 1.01 KB
/
palette.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
package main
import (
"math/rand"
"strings"
"time"
)
type palette string
var r = rand.New(rand.NewSource(time.Now().UnixNano()))
// https://www.nordtheme.com/docs/colors-and-palettes
const (
PolarNight palette = "#2E3440 #3B4252 #434C5E #4C566A"
SnowStorm palette = "#D8DEE9 #E5E9F0 #ECEFF4"
Frost palette = "#8FBCBB #88C0D0 #81A1C1 #5E81AC"
Aurora palette = "#BF616A #D08770 #EBCB8B #A3BE8C #B48EAD"
)
func (p palette) colors() []string {
return strings.Split(string(p), " ")
}
func (p palette) randomColor() string {
colors := p.colors()
i := r.Intn(len(colors))
return colors[i]
}
func randomPalette() palette {
all := []palette{PolarNight, SnowStorm, Frost, Aurora}
i := r.Intn(len(all))
return all[i]
}
func allColors() []string {
var all []string
all = PolarNight.colors()
all = append(all, SnowStorm.colors()...)
all = append(all, Frost.colors()...)
return append(all, Aurora.colors()...)
}
func randomColor() string {
colors := allColors()
i := r.Intn(len(colors))
return colors[i]
}