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"
"strings"
"github.com/taigrr/simplecolorpalettes/palettes/material"
"github.com/taigrr/simplecolorpalettes/palettes/vim/luna"
)
func main() {
colors := material.GetShadesForColorName(material.Red)
colors = luna.GetPalette()
colors := luna.GetPalette()
colors = colors.ToExtendedAnsi()
var open []string
var close []string

View File

@@ -40,4 +40,5 @@ var Ansi = simplecolor.SimplePalette{
0xFFFFFF, 0x080808, 0x121212, 0x1C1C1C, 0x262626, 0x303030, 0x3A3A3A,
0x444444, 0x4E4E4E, 0x585858, 0x626262, 0x6C6C6C, 0x767676, 0x808080,
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,
"A400": 0xd500f9, "A700": 0xaa00ff,
}
deepPurple = simplecolor.NamedPalette{
"50": 0xede7f6, "100": 0xd1c4e9, "200": 0xb39ddb, "300": 0x9575cd,
"400": 0x7e57c2, "500": 0x673ab7, "600": 0x5e35b1, "700": 0x512da8,
"800": 0x4527a0, "900": 0x311b92, "A100": 0xb388ff, "A200": 0x7c4dff,
"A400": 0x651fff, "A700": 0x6200ea,
}
indigo = simplecolor.NamedPalette{
"50": 0xe8eaf6, "100": 0xc5cae9, "200": 0x9fa8da, "300": 0x7986cb,
"400": 0x5c6bc0, "500": 0x3f51b5, "600": 0x3949ab, "700": 0x303f9f,
"800": 0x283593, "900": 0x1a237e, "A100": 0x8c9eff, "A200": 0x536dfe,
"A400": 0x3d5afe, "A700": 0x304ffe,
}
// Removed as not used, leaving in for future use if needed.
// deepPurple = simplecolor.NamedPalette{
// "50": 0xede7f6, "100": 0xd1c4e9, "200": 0xb39ddb, "300": 0x9575cd,
// "400": 0x7e57c2, "500": 0x673ab7, "600": 0x5e35b1, "700": 0x512da8,
// "800": 0x4527a0, "900": 0x311b92, "A100": 0xb388ff, "A200": 0x7c4dff,
// "A400": 0x651fff, "A700": 0x6200ea,
// }
// indigo = simplecolor.NamedPalette{
// "50": 0xe8eaf6, "100": 0xc5cae9, "200": 0x9fa8da, "300": 0x7986cb,
// "400": 0x5c6bc0, "500": 0x3f51b5, "600": 0x3949ab, "700": 0x303f9f,
// "800": 0x283593, "900": 0x1a237e, "A100": 0x8c9eff, "A200": 0x536dfe,
// "A400": 0x3d5afe, "A700": 0x304ffe,
// }
blue = simplecolor.NamedPalette{
"50": 0xe3f2fd, "100": 0xbbdefb, "200": 0x90caf9, "300": 0x64b5f6,
"400": 0x42a5f5, "500": 0x2196f3, "600": 0x1e88e5, "700": 0x1976d2,

View File

@@ -38,4 +38,5 @@ var ansi = SimplePalette{
0xFFFFFF, 0x080808, 0x121212, 0x1C1C1C, 0x262626, 0x303030, 0x3A3A3A,
0x444444, 0x4E4E4E, 0x585858, 0x626262, 0x6C6C6C, 0x767676, 0x808080,
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)
}
func (a SimplePalette) Sort() SimplePalette {
sort.Sort(a)
return a
func (s SimplePalette) Sort() SimplePalette {
sort.Sort(s)
return s
}
func (a SimplePalette) Join(b SimplePalette) SimplePalette {
func (s SimplePalette) Join(b SimplePalette) SimplePalette {
m := make(map[SimpleColor]SimpleColor)
r := SimplePalette{}
for _, c := range a {
for _, c := range s {
m[c] = c
}
for _, c := range b {
@@ -80,32 +80,32 @@ func (c SimpleColor) ToShortHex() string {
return "#" + fmt.Sprintf("%06X", value)
}
func (s SimpleColor) RGBA() (r, g, b, a uint32) {
return uint32(s) >> 16 & 0xFF, uint32(s) >> 8 & 0xFF, uint32(s) & 0xFF, 0xFF
func (c SimpleColor) RGBA() (r, g, b, a uint32) {
return uint32(c) >> 16 & 0xFF, uint32(c) >> 8 & 0xFF, uint32(c) & 0xFF, 0xFF
}
func (input SimpleColor) ToAnsi16() SimpleColor {
color := ansi[0:16].ToPalette().Convert(input)
func (c SimpleColor) ToAnsi16() SimpleColor {
color := ansi[0:16].ToPalette().Convert(c)
r, g, b, _ := color.RGBA()
return SimpleColor(uint32(r)<<16 + uint32(g)<<8 + b)
}
func (input SimpleColor) ToExtendedAnsi() SimpleColor {
color := ansi.ToPalette().Convert(input)
func (c SimpleColor) ToExtendedAnsi() SimpleColor {
color := ansi.ToPalette().Convert(c)
r, g, b, _ := color.RGBA()
return SimpleColor(uint32(r)<<16 + uint32(g)<<8 + b)
}
func (p NamedPalette) ToExtendedAnsi() NamedPalette {
for k, v := range p {
p[k] = v.ToExtendedAnsi()
func (n NamedPalette) ToExtendedAnsi() NamedPalette {
for k, v := range n {
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)
for _, x := range p {
for _, x := range s {
clampedColor := x.ToExtendedAnsi()
if _, found := used[clampedColor]; found {
continue
@@ -118,21 +118,21 @@ func (p SimplePalette) ToExtendedAnsi() (sp SimplePalette) {
return
}
func (e SimplePalette) Len() int {
return len(e)
func (s SimplePalette) Len() int {
return len(s)
}
func (e SimplePalette) Less(i, j int) bool {
return int(e[i]) < int(e[j])
func (s SimplePalette) Less(i, j int) bool {
return int(s[i]) < int(s[j])
}
func (e SimplePalette) Swap(i, j int) {
e[i], e[j] = e[j], e[i]
func (s SimplePalette) Swap(i, j int) {
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)
for _, x := range p {
for _, x := range s {
clampedColor := x.ToAnsi16()
if _, found := used[clampedColor]; found {
continue