rename luna, refactor material

This commit is contained in:
2022-09-28 17:57:11 -07:00
parent 73ef90d0c6
commit 78ee975aa1
4 changed files with 54 additions and 25 deletions

View File

@@ -149,6 +149,10 @@ var colors = simplecolor.NamedPalette{
"yellowgreen": 0x9ACD32, "yellowgreen": 0x9ACD32,
} }
func GetNamedPalette() (np simplecolor.NamedPalette) {
return colors
}
func GetPalette() (sp simplecolor.SimplePalette) { func GetPalette() (sp simplecolor.SimplePalette) {
for _, x := range colors { for _, x := range colors {
sp = append(sp, x) sp = append(sp, x)

View File

@@ -4,12 +4,12 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/taigrr/go-colorpalettes/luna"
"github.com/taigrr/go-colorpalettes/material" "github.com/taigrr/go-colorpalettes/material"
"github.com/taigrr/go-colorpalettes/vim/luna"
) )
func main() { func main() {
colors := material.GetShadesForColorName("Red") colors := material.GetShadesForColorName(material.Red)
colors = luna.GetPalette() colors = luna.GetPalette()
colors = colors.ToExtendedAnsi() colors = colors.ToExtendedAnsi()
var open []string var open []string
@@ -22,7 +22,6 @@ func main() {
if (float32(red)*0.299 + float32(green)*0.587 + float32(blue)*0.114) > 150.0 { if (float32(red)*0.299 + float32(green)*0.587 + float32(blue)*0.114) > 150.0 {
open = append(open, fmt.Sprintf("\u001B[38;2;%d;%d;%dm", 0, 0, 0)) open = append(open, fmt.Sprintf("\u001B[38;2;%d;%d;%dm", 0, 0, 0))
} else { } else {
open = append(open, fmt.Sprintf("\u001B[38;2;%d;%d;%dm", 255, 255, 255)) open = append(open, fmt.Sprintf("\u001B[38;2;%d;%d;%dm", 255, 255, 255))
} }
close = append(close, "\u001B[39m") close = append(close, "\u001B[39m")

View File

@@ -119,26 +119,52 @@ var (
"800": 0x37474f, "900": 0x263238, "800": 0x37474f, "900": 0x263238,
} }
) )
var spectrum = map[string]simplecolor.NamedPalette{
"red": red, type ColorName int
"pink": pink,
"purple": purple, const (
Red ColorName = iota
Pink
Purple
DeepPurple
Blue
LightBlue
Cyan
Teal
Green
LightGreen
Lime
Yellow
Amber
Orange
DeepOrange
Brown
Grey
BlueGrey
Gray = Grey
BlueGray = BlueGrey
)
var spectrum = map[ColorName]simplecolor.NamedPalette{
Red: red,
Pink: pink,
Purple: purple,
// These colors render too similarly to Purple for most use cases // These colors render too similarly to Purple for most use cases
// "DeepPurple": DeepPurple, // "DeepPurple": DeepPurple,
"blue": blue, Blue: blue,
"lightBlue": lightBlue, LightBlue: lightBlue,
"cyan": cyan, Cyan: cyan,
"teal": teal, Teal: teal,
"green": green, Green: green,
"lightGreen": lightGreen, LightGreen: lightGreen,
"lime": lime, Lime: lime,
"yellow": yellow, Yellow: yellow,
"amber": amber, Amber: amber,
"orange": orange, Orange: orange,
"deepOrange": deepOrange, DeepOrange: deepOrange,
"brown": brown, Brown: brown,
"grey": grey, Grey: grey,
"blueGrey": blueGrey, BlueGrey: blueGrey,
} }
func GetPalette() (colors simplecolor.SimplePalette) { func GetPalette() (colors simplecolor.SimplePalette) {
@@ -149,7 +175,6 @@ func GetPalette() (colors simplecolor.SimplePalette) {
} }
sort.Sort(colors) sort.Sort(colors)
return return
} }
func GetColorsForShade(shade string) (colors simplecolor.SimplePalette) { func GetColorsForShade(shade string) (colors simplecolor.SimplePalette) {
@@ -162,7 +187,8 @@ func GetColorsForShade(shade string) (colors simplecolor.SimplePalette) {
return return
} }
func GetShadesForColorName(color string) (colors simplecolor.SimplePalette) { // Parameter must be one of the following:
func GetShadesForColorName(color ColorName) (colors simplecolor.SimplePalette) {
if c, ok := spectrum[color]; ok { if c, ok := spectrum[color]; ok {
for _, cp := range c { for _, cp := range c {
colors = append(colors, cp) colors = append(colors, cp)