-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
81 lines (74 loc) · 1.33 KB
/
main.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
69
70
71
72
73
74
75
76
77
78
79
80
81
//go:generate whiskers go.tera
//go:generate go fmt ./...
package catppuccingo
import (
"image/color"
"strings"
)
// Flavor is an interface implemented by all Catppuccin variations.
type Flavor interface {
Rosewater() Color
Flamingo() Color
Pink() Color
Mauve() Color
Red() Color
Maroon() Color
Peach() Color
Yellow() Color
Green() Color
Teal() Color
Sky() Color
Sapphire() Color
Blue() Color
Lavender() Color
Text() Color
Subtext1() Color
Subtext0() Color
Overlay2() Color
Overlay1() Color
Overlay0() Color
Surface2() Color
Surface1() Color
Surface0() Color
Crust() Color
Mantle() Color
Base() Color
Name() string
}
// Theme and Flavour are type aliases of Flavor to keep compatibility with previous versions.
type (
Theme = Flavour
Flavour = Flavor
)
// Color is a color in Hex, RGB, and HSL.
type Color struct {
Hex string
RGB [3]uint8
HSL [3]float32
}
// RGBA implements color.Color
func (c Color) RGBA() (r, g, b, a uint32) {
r = uint32(c.RGB[0])
r |= r << 8
g = uint32(c.RGB[1])
g |= g << 8
b = uint32(c.RGB[2])
b |= b << 8
a = 0xffff
return
}
var _ color.Color = Color{}
// Variant returns the Theme variant by name.
func Variant(flavor string) Theme {
for _, t := range []Theme{
Mocha,
Frappe,
Macchiato,
Latte,
} {
if strings.EqualFold(t.Name(), flavor) {
return t
}
}
return nil
}