mirror of
https://github.com/taigrr/simplecolorpalettes.git
synced 2026-04-01 20:49:11 -07:00
rename luna, refactor material
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
9
main.go
9
main.go
@@ -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")
|
||||||
@@ -31,8 +30,8 @@ func main() {
|
|||||||
close = append(close, "\u001B[49m")
|
close = append(close, "\u001B[49m")
|
||||||
|
|
||||||
// if m.isUnderlined {
|
// if m.isUnderlined {
|
||||||
//open = append(open, "\u001B[4m")
|
// open = append(open, "\u001B[4m")
|
||||||
//close = append(close, "\u001B[24m")
|
// close = append(close, "\u001B[24m")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if m.isDim {
|
// if m.isDim {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user