Merge pull request #1 from ethanholz/dev-ethan/bugfixes

General bugfixes and style changes for concistency
This commit is contained in:
2022-10-11 13:26:44 -07:00
committed by GitHub
5 changed files with 43 additions and 42 deletions

View File

@@ -4,13 +4,11 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/taigrr/simplecolorpalettes/palettes/material"
"github.com/taigrr/simplecolorpalettes/palettes/vim/luna" "github.com/taigrr/simplecolorpalettes/palettes/vim/luna"
) )
func main() { func main() {
colors := material.GetShadesForColorName(material.Red) colors := luna.GetPalette()
colors = luna.GetPalette()
colors = colors.ToExtendedAnsi() colors = colors.ToExtendedAnsi()
var open []string var open []string
var close []string var close []string

View File

@@ -40,4 +40,5 @@ var Ansi = simplecolor.SimplePalette{
0xFFFFFF, 0x080808, 0x121212, 0x1C1C1C, 0x262626, 0x303030, 0x3A3A3A, 0xFFFFFF, 0x080808, 0x121212, 0x1C1C1C, 0x262626, 0x303030, 0x3A3A3A,
0x444444, 0x4E4E4E, 0x585858, 0x626262, 0x6C6C6C, 0x767676, 0x808080, 0x444444, 0x4E4E4E, 0x585858, 0x626262, 0x6C6C6C, 0x767676, 0x808080,
0x8A8A8A, 0x949494, 0x9E9E9E, 0xA8A8A8, 0xB2B2B2, 0xBCBCBC, 0xC6C6C6, 0x8A8A8A, 0x949494, 0x9E9E9E, 0xA8A8A8, 0xB2B2B2, 0xBCBCBC, 0xC6C6C6,
0xD0D0D0, 0xDADADA, 0xE4E4E4, 0xEEEEEE} 0xD0D0D0, 0xDADADA, 0xE4E4E4, 0xEEEEEE,
}

View File

@@ -28,18 +28,19 @@ var (
"800": 0x6a1b9a, "900": 0x4a148c, "A100": 0xea80fc, "A200": 0xe040fb, "800": 0x6a1b9a, "900": 0x4a148c, "A100": 0xea80fc, "A200": 0xe040fb,
"A400": 0xd500f9, "A700": 0xaa00ff, "A400": 0xd500f9, "A700": 0xaa00ff,
} }
deepPurple = simplecolor.NamedPalette{ // Removed as not used, leaving in for future use if needed.
"50": 0xede7f6, "100": 0xd1c4e9, "200": 0xb39ddb, "300": 0x9575cd, // deepPurple = simplecolor.NamedPalette{
"400": 0x7e57c2, "500": 0x673ab7, "600": 0x5e35b1, "700": 0x512da8, // "50": 0xede7f6, "100": 0xd1c4e9, "200": 0xb39ddb, "300": 0x9575cd,
"800": 0x4527a0, "900": 0x311b92, "A100": 0xb388ff, "A200": 0x7c4dff, // "400": 0x7e57c2, "500": 0x673ab7, "600": 0x5e35b1, "700": 0x512da8,
"A400": 0x651fff, "A700": 0x6200ea, // "800": 0x4527a0, "900": 0x311b92, "A100": 0xb388ff, "A200": 0x7c4dff,
} // "A400": 0x651fff, "A700": 0x6200ea,
indigo = simplecolor.NamedPalette{ // }
"50": 0xe8eaf6, "100": 0xc5cae9, "200": 0x9fa8da, "300": 0x7986cb, // indigo = simplecolor.NamedPalette{
"400": 0x5c6bc0, "500": 0x3f51b5, "600": 0x3949ab, "700": 0x303f9f, // "50": 0xe8eaf6, "100": 0xc5cae9, "200": 0x9fa8da, "300": 0x7986cb,
"800": 0x283593, "900": 0x1a237e, "A100": 0x8c9eff, "A200": 0x536dfe, // "400": 0x5c6bc0, "500": 0x3f51b5, "600": 0x3949ab, "700": 0x303f9f,
"A400": 0x3d5afe, "A700": 0x304ffe, // "800": 0x283593, "900": 0x1a237e, "A100": 0x8c9eff, "A200": 0x536dfe,
} // "A400": 0x3d5afe, "A700": 0x304ffe,
// }
blue = simplecolor.NamedPalette{ blue = simplecolor.NamedPalette{
"50": 0xe3f2fd, "100": 0xbbdefb, "200": 0x90caf9, "300": 0x64b5f6, "50": 0xe3f2fd, "100": 0xbbdefb, "200": 0x90caf9, "300": 0x64b5f6,
"400": 0x42a5f5, "500": 0x2196f3, "600": 0x1e88e5, "700": 0x1976d2, "400": 0x42a5f5, "500": 0x2196f3, "600": 0x1e88e5, "700": 0x1976d2,

View File

@@ -38,4 +38,5 @@ var ansi = SimplePalette{
0xFFFFFF, 0x080808, 0x121212, 0x1C1C1C, 0x262626, 0x303030, 0x3A3A3A, 0xFFFFFF, 0x080808, 0x121212, 0x1C1C1C, 0x262626, 0x303030, 0x3A3A3A,
0x444444, 0x4E4E4E, 0x585858, 0x626262, 0x6C6C6C, 0x767676, 0x808080, 0x444444, 0x4E4E4E, 0x585858, 0x626262, 0x6C6C6C, 0x767676, 0x808080,
0x8A8A8A, 0x949494, 0x9E9E9E, 0xA8A8A8, 0xB2B2B2, 0xBCBCBC, 0xC6C6C6, 0x8A8A8A, 0x949494, 0x9E9E9E, 0xA8A8A8, 0xB2B2B2, 0xBCBCBC, 0xC6C6C6,
0xD0D0D0, 0xDADADA, 0xE4E4E4, 0xEEEEEE} 0xD0D0D0, 0xDADADA, 0xE4E4E4, 0xEEEEEE,
}

View File

@@ -33,15 +33,15 @@ func (n NamedPalette) ToPalette() color.Palette {
return color.Palette(x) return color.Palette(x)
} }
func (a SimplePalette) Sort() SimplePalette { func (s SimplePalette) Sort() SimplePalette {
sort.Sort(a) sort.Sort(s)
return a return s
} }
func (a SimplePalette) Join(b SimplePalette) SimplePalette { func (s SimplePalette) Join(b SimplePalette) SimplePalette {
m := make(map[SimpleColor]SimpleColor) m := make(map[SimpleColor]SimpleColor)
r := SimplePalette{} r := SimplePalette{}
for _, c := range a { for _, c := range s {
m[c] = c m[c] = c
} }
for _, c := range b { for _, c := range b {
@@ -80,32 +80,32 @@ func (c SimpleColor) ToShortHex() string {
return "#" + fmt.Sprintf("%06X", value) return "#" + fmt.Sprintf("%06X", value)
} }
func (s SimpleColor) RGBA() (r, g, b, a uint32) { func (c SimpleColor) RGBA() (r, g, b, a uint32) {
return uint32(s) >> 16 & 0xFF, uint32(s) >> 8 & 0xFF, uint32(s) & 0xFF, 0xFF return uint32(c) >> 16 & 0xFF, uint32(c) >> 8 & 0xFF, uint32(c) & 0xFF, 0xFF
} }
func (input SimpleColor) ToAnsi16() SimpleColor { func (c SimpleColor) ToAnsi16() SimpleColor {
color := ansi[0:16].ToPalette().Convert(input) color := ansi[0:16].ToPalette().Convert(c)
r, g, b, _ := color.RGBA() r, g, b, _ := color.RGBA()
return SimpleColor(uint32(r)<<16 + uint32(g)<<8 + b) return SimpleColor(uint32(r)<<16 + uint32(g)<<8 + b)
} }
func (input SimpleColor) ToExtendedAnsi() SimpleColor { func (c SimpleColor) ToExtendedAnsi() SimpleColor {
color := ansi.ToPalette().Convert(input) color := ansi.ToPalette().Convert(c)
r, g, b, _ := color.RGBA() r, g, b, _ := color.RGBA()
return SimpleColor(uint32(r)<<16 + uint32(g)<<8 + b) return SimpleColor(uint32(r)<<16 + uint32(g)<<8 + b)
} }
func (p NamedPalette) ToExtendedAnsi() NamedPalette { func (n NamedPalette) ToExtendedAnsi() NamedPalette {
for k, v := range p { for k, v := range n {
p[k] = v.ToExtendedAnsi() n[k] = v.ToExtendedAnsi()
} }
return p return n
} }
func (p SimplePalette) ToExtendedAnsi() (sp SimplePalette) { func (s SimplePalette) ToExtendedAnsi() (sp SimplePalette) {
used := make(map[SimpleColor]bool) used := make(map[SimpleColor]bool)
for _, x := range p { for _, x := range s {
clampedColor := x.ToExtendedAnsi() clampedColor := x.ToExtendedAnsi()
if _, found := used[clampedColor]; found { if _, found := used[clampedColor]; found {
continue continue
@@ -118,21 +118,21 @@ func (p SimplePalette) ToExtendedAnsi() (sp SimplePalette) {
return return
} }
func (e SimplePalette) Len() int { func (s SimplePalette) Len() int {
return len(e) return len(s)
} }
func (e SimplePalette) Less(i, j int) bool { func (s SimplePalette) Less(i, j int) bool {
return int(e[i]) < int(e[j]) return int(s[i]) < int(s[j])
} }
func (e SimplePalette) Swap(i, j int) { func (s SimplePalette) Swap(i, j int) {
e[i], e[j] = e[j], e[i] s[i], s[j] = s[j], s[i]
} }
func (p SimplePalette) ToAnsi16() (sp SimplePalette) { func (s SimplePalette) ToAnsi16() (sp SimplePalette) {
used := make(map[SimpleColor]bool) used := make(map[SimpleColor]bool)
for _, x := range p { for _, x := range s {
clampedColor := x.ToAnsi16() clampedColor := x.ToAnsi16()
if _, found := used[clampedColor]; found { if _, found := used[clampedColor]; found {
continue continue