commit cfd2c97ba0eb20561af0be857e0fd85e1533afe4
parent 6e42db9152442db6247ff2d8da652ce07277649a
Author: Thomas Frössman <thomasf@jossystem.se>
Date: Wed, 20 Nov 2019 18:09:16 +0100
colorlab: refactor rename solarized package to sol
Diffstat:
13 files changed, 376 insertions(+), 376 deletions(-)
diff --git a/colorlab/main.go b/colorlab/main.go
@@ -15,7 +15,7 @@ import (
"github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
"github.com/bbatsov/solarized-emacs/colorlab/pkg/colors"
"github.com/bbatsov/solarized-emacs/colorlab/pkg/generator"
- sol "github.com/bbatsov/solarized-emacs/colorlab/pkg/solarized"
+ "github.com/bbatsov/solarized-emacs/colorlab/pkg/sol"
)
// Options are command line flags .
diff --git a/colorlab/pkg/generator/accentpair.go b/colorlab/pkg/generator/accentpair.go
@@ -5,7 +5,7 @@ import (
"math"
"github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
- "github.com/bbatsov/solarized-emacs/colorlab/pkg/solarized"
+ "github.com/bbatsov/solarized-emacs/colorlab/pkg/sol"
"github.com/lucasb-eyer/go-colorful"
)
@@ -21,10 +21,10 @@ type AccentPairGenerator struct {
ForegroundBlendFinder colorlab.ColorFinder
}
-func (g *AccentPairGenerator) Generate(sol solarized.Solarized) (backgrounds, foregrounds solarized.Accents) {
+func (g *AccentPairGenerator) Generate(solarized sol.Solarized) (backgrounds, foregrounds sol.Accents) {
lightnessReport := false
- sol = sol.Clone()
- cs := sol.Accents.Colors()
+ solarized = solarized.Clone()
+ cs := solarized.Accents.Colors()
light := func(c colorful.Color) float64 {
l, _, _ := c.Lab()
@@ -36,19 +36,19 @@ func (g *AccentPairGenerator) Generate(sol solarized.Solarized) (backgrounds, fo
fmt.Println(" ")
}
- blendBgColor := g.BackgroundBlendFinder(sol.Base.NamedColors())
- blendFgColor := g.ForegroundBlendFinder(sol.Base.NamedColors())
+ blendBgColor := g.BackgroundBlendFinder(solarized.Base.NamedColors())
+ blendFgColor := g.ForegroundBlendFinder(solarized.Base.NamedColors())
bg := v.BlendLab(blendBgColor, g.BlendBackgroundAmout)
fg := v.BlendLab(blendFgColor, g.BlendForegroundAmout)
if lightnessReport {
{
l, _, _ := blendBgColor.Lab()
- fmt.Printf(" | b1 %.2f %s", l, sol.Base03)
+ fmt.Printf(" | b1 %.2f %s", l, solarized.Base03)
}
{
l, _, _ := blendFgColor.Lab()
- fmt.Printf(" f1 %.2f %s", l, sol.Base0)
+ fmt.Printf(" f1 %.2f %s", l, solarized.Base0)
}
}
@@ -113,5 +113,5 @@ func (g *AccentPairGenerator) Generate(sol solarized.Solarized) (backgrounds, fo
if lightnessReport {
fmt.Println("\n\n")
}
- return solarized.NewAccents(bgs), solarized.NewAccents(fgs)
+ return sol.NewAccents(bgs), sol.NewAccents(fgs)
}
diff --git a/colorlab/pkg/generator/palette.go b/colorlab/pkg/generator/palette.go
@@ -2,14 +2,14 @@ package generator
import (
"github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
- "github.com/bbatsov/solarized-emacs/colorlab/pkg/solarized"
+ "github.com/bbatsov/solarized-emacs/colorlab/pkg/sol"
)
// Palette .
type Palette struct {
Name string
Inverse bool
- Solarized solarized.Solarized
+ Solarized sol.Solarized
Accent1Pair AccentPairGenerator
Accent2Pair AccentPairGenerator
diff --git a/colorlab/pkg/sol/accents.go b/colorlab/pkg/sol/accents.go
@@ -0,0 +1,141 @@
+package sol
+
+import (
+ "github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
+ "github.com/lucasb-eyer/go-colorful"
+)
+
+// Accents .
+type Accents struct {
+ Yellow colorlab.HexColor
+ Orange colorlab.HexColor
+ Red colorlab.HexColor
+ Magenta colorlab.HexColor
+ Violet colorlab.HexColor
+ Blue colorlab.HexColor
+ Cyan colorlab.HexColor
+ Green colorlab.HexColor
+}
+
+type AccentColors [8]colorful.Color
+
+func NewAccents(cc [8]colorful.Color) Accents {
+ return Accents{
+ Yellow: colorlab.HexColor(cc[0].Clamped().Hex()),
+ Orange: colorlab.HexColor(cc[1].Clamped().Hex()),
+ Red: colorlab.HexColor(cc[2].Clamped().Hex()),
+ Magenta: colorlab.HexColor(cc[3].Clamped().Hex()),
+ Violet: colorlab.HexColor(cc[4].Clamped().Hex()),
+ Blue: colorlab.HexColor(cc[5].Clamped().Hex()),
+ Cyan: colorlab.HexColor(cc[6].Clamped().Hex()),
+ Green: colorlab.HexColor(cc[7].Clamped().Hex()),
+ }
+}
+func (s Accents) Clone() Accents {
+ return Accents{
+ Yellow: s.Yellow,
+ Orange: s.Orange,
+ Red: s.Red,
+ Magenta: s.Magenta,
+ Violet: s.Violet,
+ Blue: s.Blue,
+ Cyan: s.Cyan,
+ Green: s.Green,
+ }
+}
+
+func (s Accents) Colors() AccentColors {
+ a := s.colorArray()
+ return [8]colorful.Color{
+ a[0].Color(),
+ a[1].Color(),
+ a[2].Color(),
+ a[3].Color(),
+ a[4].Color(),
+ a[5].Color(),
+ a[6].Color(),
+ a[7].Color(),
+ }
+}
+func (a Accents) ChangeLightness(amount float64) Accents {
+ cc := a.Colors()
+ lightness := func(c colorful.Color, v float64) colorful.Color {
+ l, a, b := c.Lab()
+ l = l + v
+ return colorful.Lab(l, a, b)
+ }
+ cc[0] = lightness(cc[0], amount)
+ cc[1] = lightness(cc[1], amount)
+ cc[2] = lightness(cc[2], amount)
+ cc[3] = lightness(cc[3], amount)
+ cc[4] = lightness(cc[4], amount)
+ cc[5] = lightness(cc[5], amount)
+ cc[6] = lightness(cc[6], amount)
+ cc[7] = lightness(cc[7], amount)
+ return NewAccents(cc)
+}
+func (a Accents) ChangeSaturation(amount float64) Accents {
+ cc := a.Colors()
+ saturation := func(c colorful.Color, v float64) colorful.Color {
+ h, s, l := c.Hsl()
+ // s = math.Min(math.Max(s+v, 0), 1)
+ s = s + v
+ return colorful.Hsl(h, s, l)
+ }
+ cc[0] = saturation(cc[0], amount)
+ cc[1] = saturation(cc[1], amount)
+ cc[2] = saturation(cc[2], amount)
+ cc[3] = saturation(cc[3], amount)
+ cc[4] = saturation(cc[4], amount)
+ cc[5] = saturation(cc[5], amount)
+ cc[6] = saturation(cc[6], amount)
+ cc[7] = saturation(cc[7], amount)
+ return NewAccents(cc)
+}
+
+func (a Accents) Blend(hc colorlab.HexColor, amount float64) Accents {
+ c := hc.Color()
+ cc := a.Colors()
+ cc[0] = cc[0].BlendLab(c, amount)
+ cc[1] = cc[1].BlendLab(c, amount)
+ cc[2] = cc[2].BlendLab(c, amount)
+ cc[3] = cc[3].BlendLab(c, amount)
+ cc[4] = cc[4].BlendLab(c, amount)
+ cc[5] = cc[5].BlendLab(c, amount)
+ cc[6] = cc[6].BlendLab(c, amount)
+ cc[7] = cc[7].BlendLab(c, amount)
+ return NewAccents(cc)
+}
+
+func (ac Accents) NamedColors() colorlab.NamedColors {
+ nc := make(colorlab.NamedColors, 8)
+ arr := ac.colorArray()
+ for idx, hex := range arr {
+ nc[accentNames[idx]] = hex
+ }
+ return nc
+}
+
+func (s Accents) colorArray() [8]colorlab.HexColor {
+ return [8]colorlab.HexColor{
+ s.Yellow,
+ s.Orange,
+ s.Red,
+ s.Magenta,
+ s.Violet,
+ s.Blue,
+ s.Cyan,
+ s.Green,
+ }
+}
+
+var accentNames = [8]string{
+ 0: "yellow",
+ 1: "orange",
+ 2: "red",
+ 3: "magenta",
+ 4: "violet",
+ 5: "blue",
+ 6: "cyan",
+ 7: "green",
+}
diff --git a/colorlab/pkg/sol/base.go b/colorlab/pkg/sol/base.go
@@ -0,0 +1,125 @@
+package sol
+
+import (
+ "github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
+ "github.com/lucasb-eyer/go-colorful"
+)
+
+type Base struct {
+ Base03 colorlab.HexColor
+ Base02 colorlab.HexColor
+ Base01 colorlab.HexColor
+ Base00 colorlab.HexColor
+ Base0 colorlab.HexColor
+ Base1 colorlab.HexColor
+ Base2 colorlab.HexColor
+ Base3 colorlab.HexColor
+}
+
+type BaseColors [8]colorful.Color
+
+func NewBase(bc [8]colorful.Color) Base {
+ return Base{
+ Base03: colorlab.HexColor(bc[0].Clamped().Hex()),
+ Base02: colorlab.HexColor(bc[1].Clamped().Hex()),
+ Base01: colorlab.HexColor(bc[2].Clamped().Hex()),
+ Base00: colorlab.HexColor(bc[3].Clamped().Hex()),
+ Base0: colorlab.HexColor(bc[4].Clamped().Hex()),
+ Base1: colorlab.HexColor(bc[5].Clamped().Hex()),
+ Base2: colorlab.HexColor(bc[6].Clamped().Hex()),
+ Base3: colorlab.HexColor(bc[7].Clamped().Hex()),
+ }
+}
+func (s Base) Clone() Base {
+ return Base{
+ Base03: s.Base03,
+ Base02: s.Base02,
+ Base01: s.Base01,
+ Base00: s.Base00,
+ Base0: s.Base0,
+ Base1: s.Base1,
+ Base2: s.Base2,
+ Base3: s.Base3,
+ }
+}
+func (s Base) NamedColors() colorlab.NamedColors {
+ nc := make(colorlab.NamedColors, 8)
+ arr := s.colorArray()
+ for idx, hex := range arr {
+ nc[baseNames[idx]] = hex
+ }
+ return nc
+}
+
+func (s Base) Colors() BaseColors {
+ a := s.colorArray()
+ return [8]colorful.Color{
+ a[0].Color(),
+ a[1].Color(),
+ a[2].Color(),
+ a[3].Color(),
+ a[4].Color(),
+ a[5].Color(),
+ a[6].Color(),
+ a[7].Color(),
+ }
+}
+
+func (s Base) colorArray() [8]colorlab.HexColor {
+ return [8]colorlab.HexColor{
+ s.Base03,
+ s.Base02,
+ s.Base01,
+ s.Base00,
+ s.Base0,
+ s.Base1,
+ s.Base2,
+ s.Base3,
+ }
+}
+
+// Returns true if the LAB lightness of base0 is larger than base03.
+func (b Base) IsDarkOnBright() bool {
+ return b.NamedColors().IsDarkOnBright("base03", "base0")
+}
+
+var baseNames = [8]string{
+ 0: "base03",
+ 1: "base02",
+ 2: "base01",
+ 3: "base00",
+ 4: "base0",
+ 5: "base1",
+ 6: "base2",
+ 7: "base3",
+}
+
+func (s Base) Inverse() Base {
+ return Base{
+ Base03: s.Base3,
+ Base02: s.Base2,
+ Base01: s.Base1,
+ Base00: s.Base0,
+ Base0: s.Base00,
+ Base1: s.Base01,
+ Base2: s.Base02,
+ Base3: s.Base03,
+ }
+}
+func (b Base) ChangeLightness(amountFgs, amountBgs float64) Base {
+ cc := b.Colors()
+ lightness := func(c colorful.Color, v float64) colorful.Color {
+ l, a, b := c.Lab()
+ l = l + v
+ return colorful.Lab(l, a, b)
+ }
+ cc[0] = lightness(cc[0], amountBgs)
+ cc[1] = lightness(cc[1], amountBgs)
+ cc[2] = lightness(cc[2], amountFgs)
+ cc[3] = lightness(cc[3], amountBgs)
+ cc[4] = lightness(cc[4], amountFgs)
+ cc[5] = lightness(cc[5], amountFgs)
+ cc[6] = lightness(cc[6], amountFgs)
+ cc[7] = lightness(cc[7], amountFgs)
+ return NewBase(cc)
+}
diff --git a/colorlab/pkg/sol/package.go b/colorlab/pkg/sol/package.go
@@ -0,0 +1,2 @@
+// Package solarized contains functionality specific to the structure of a solarize palette
+package sol
diff --git a/colorlab/pkg/sol/solarized.go b/colorlab/pkg/sol/solarized.go
@@ -0,0 +1,26 @@
+package sol
+
+import "github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
+
+type Solarized struct {
+ Base
+ Accents
+}
+
+func (s Solarized) Clone() Solarized {
+ return Solarized{
+ Base: s.Base.Clone(),
+ Accents: s.Accents.Clone(),
+ }
+}
+
+func (s Solarized) Inverse() Solarized {
+ return Solarized{
+ Base: s.Base.Inverse(),
+ Accents: s.Accents.Clone(),
+ }
+}
+
+func (s Solarized) NamedColors() colorlab.NamedColors {
+ return colorlab.Merge(s.Base.NamedColors(), s.Accents.NamedColors())
+}
diff --git a/colorlab/pkg/sol/sort.go b/colorlab/pkg/sol/sort.go
@@ -0,0 +1,70 @@
+package sol
+
+import (
+ "sort"
+ "strings"
+
+ "github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
+)
+
+// Orderedkeys returns the keys in a order that is like how solarized names should be ordered.
+//
+// primary orer is:
+//
+// 1. base names
+// 2. accent colors
+// 3. names that contain base names
+// 4. names that contain accent color names
+// 5. the rest
+//
+// secondary sort order is by string comparison.
+//
+func OrderedKeys(n colorlab.NamedColors) []string {
+ var names []string
+ for k, _ := range n {
+ names = append(names, k)
+ }
+ sort.Sort(sort.StringSlice(names))
+
+ var allNames []string
+ for _, n := range baseNames {
+ allNames = append(allNames, n)
+ }
+ for _, n := range accentNames {
+ allNames = append(allNames, n)
+ }
+ score := func(idx int, exact bool) int {
+ s := (len(allNames) - idx) + 1
+ if exact {
+ s = s + len(allNames)
+ }
+ return s
+ }
+ sort.SliceStable(names, func(i int, j int) bool {
+ var is, js int // scores
+ in := names[i]
+ jn := names[j]
+ scoring:
+ for sortIdx, sortName := range allNames {
+ if is == 0 {
+ // log.Println(in, sortName)
+ if strings.Contains(in, sortName) {
+ is = score(sortIdx, in == sortName)
+ // fmt.Println("score in", in, sortName, is)
+ }
+ }
+ if js == 0 {
+ if strings.Contains(jn, sortName) {
+ js = score(sortIdx, jn == sortName)
+ // fmt.Println("score j", jn, sortName, js)
+ }
+ }
+ if is != 0 && js != 0 {
+ break scoring
+ }
+ }
+ // log.Println(is, js, in,jn)
+ return is > js
+ })
+ return names
+}
diff --git a/colorlab/pkg/solarized/accents.go b/colorlab/pkg/solarized/accents.go
@@ -1,141 +0,0 @@
-package solarized
-
-import (
- "github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
- "github.com/lucasb-eyer/go-colorful"
-)
-
-// Accents .
-type Accents struct {
- Yellow colorlab.HexColor
- Orange colorlab.HexColor
- Red colorlab.HexColor
- Magenta colorlab.HexColor
- Violet colorlab.HexColor
- Blue colorlab.HexColor
- Cyan colorlab.HexColor
- Green colorlab.HexColor
-}
-
-type AccentColors [8]colorful.Color
-
-func NewAccents(cc [8]colorful.Color) Accents {
- return Accents{
- Yellow: colorlab.HexColor(cc[0].Clamped().Hex()),
- Orange: colorlab.HexColor(cc[1].Clamped().Hex()),
- Red: colorlab.HexColor(cc[2].Clamped().Hex()),
- Magenta: colorlab.HexColor(cc[3].Clamped().Hex()),
- Violet: colorlab.HexColor(cc[4].Clamped().Hex()),
- Blue: colorlab.HexColor(cc[5].Clamped().Hex()),
- Cyan: colorlab.HexColor(cc[6].Clamped().Hex()),
- Green: colorlab.HexColor(cc[7].Clamped().Hex()),
- }
-}
-func (s Accents) Clone() Accents {
- return Accents{
- Yellow: s.Yellow,
- Orange: s.Orange,
- Red: s.Red,
- Magenta: s.Magenta,
- Violet: s.Violet,
- Blue: s.Blue,
- Cyan: s.Cyan,
- Green: s.Green,
- }
-}
-
-func (s Accents) Colors() AccentColors {
- a := s.colorArray()
- return [8]colorful.Color{
- a[0].Color(),
- a[1].Color(),
- a[2].Color(),
- a[3].Color(),
- a[4].Color(),
- a[5].Color(),
- a[6].Color(),
- a[7].Color(),
- }
-}
-func (a Accents) ChangeLightness(amount float64) Accents {
- cc := a.Colors()
- lightness := func(c colorful.Color, v float64) colorful.Color {
- l, a, b := c.Lab()
- l = l + v
- return colorful.Lab(l, a, b)
- }
- cc[0] = lightness(cc[0], amount)
- cc[1] = lightness(cc[1], amount)
- cc[2] = lightness(cc[2], amount)
- cc[3] = lightness(cc[3], amount)
- cc[4] = lightness(cc[4], amount)
- cc[5] = lightness(cc[5], amount)
- cc[6] = lightness(cc[6], amount)
- cc[7] = lightness(cc[7], amount)
- return NewAccents(cc)
-}
-func (a Accents) ChangeSaturation(amount float64) Accents {
- cc := a.Colors()
- saturation := func(c colorful.Color, v float64) colorful.Color {
- h, s, l := c.Hsl()
- // s = math.Min(math.Max(s+v, 0), 1)
- s = s + v
- return colorful.Hsl(h, s, l)
- }
- cc[0] = saturation(cc[0], amount)
- cc[1] = saturation(cc[1], amount)
- cc[2] = saturation(cc[2], amount)
- cc[3] = saturation(cc[3], amount)
- cc[4] = saturation(cc[4], amount)
- cc[5] = saturation(cc[5], amount)
- cc[6] = saturation(cc[6], amount)
- cc[7] = saturation(cc[7], amount)
- return NewAccents(cc)
-}
-
-func (a Accents) Blend(hc colorlab.HexColor, amount float64) Accents {
- c := hc.Color()
- cc := a.Colors()
- cc[0] = cc[0].BlendLab(c, amount)
- cc[1] = cc[1].BlendLab(c, amount)
- cc[2] = cc[2].BlendLab(c, amount)
- cc[3] = cc[3].BlendLab(c, amount)
- cc[4] = cc[4].BlendLab(c, amount)
- cc[5] = cc[5].BlendLab(c, amount)
- cc[6] = cc[6].BlendLab(c, amount)
- cc[7] = cc[7].BlendLab(c, amount)
- return NewAccents(cc)
-}
-
-func (ac Accents) NamedColors() colorlab.NamedColors {
- nc := make(colorlab.NamedColors, 8)
- arr := ac.colorArray()
- for idx, hex := range arr {
- nc[accentNames[idx]] = hex
- }
- return nc
-}
-
-func (s Accents) colorArray() [8]colorlab.HexColor {
- return [8]colorlab.HexColor{
- s.Yellow,
- s.Orange,
- s.Red,
- s.Magenta,
- s.Violet,
- s.Blue,
- s.Cyan,
- s.Green,
- }
-}
-
-var accentNames = [8]string{
- 0: "yellow",
- 1: "orange",
- 2: "red",
- 3: "magenta",
- 4: "violet",
- 5: "blue",
- 6: "cyan",
- 7: "green",
-}
diff --git a/colorlab/pkg/solarized/base.go b/colorlab/pkg/solarized/base.go
@@ -1,125 +0,0 @@
-package solarized
-
-import (
- "github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
- "github.com/lucasb-eyer/go-colorful"
-)
-
-type Base struct {
- Base03 colorlab.HexColor
- Base02 colorlab.HexColor
- Base01 colorlab.HexColor
- Base00 colorlab.HexColor
- Base0 colorlab.HexColor
- Base1 colorlab.HexColor
- Base2 colorlab.HexColor
- Base3 colorlab.HexColor
-}
-
-type BaseColors [8]colorful.Color
-
-func NewBase(bc [8]colorful.Color) Base {
- return Base{
- Base03: colorlab.HexColor(bc[0].Clamped().Hex()),
- Base02: colorlab.HexColor(bc[1].Clamped().Hex()),
- Base01: colorlab.HexColor(bc[2].Clamped().Hex()),
- Base00: colorlab.HexColor(bc[3].Clamped().Hex()),
- Base0: colorlab.HexColor(bc[4].Clamped().Hex()),
- Base1: colorlab.HexColor(bc[5].Clamped().Hex()),
- Base2: colorlab.HexColor(bc[6].Clamped().Hex()),
- Base3: colorlab.HexColor(bc[7].Clamped().Hex()),
- }
-}
-func (s Base) Clone() Base {
- return Base{
- Base03: s.Base03,
- Base02: s.Base02,
- Base01: s.Base01,
- Base00: s.Base00,
- Base0: s.Base0,
- Base1: s.Base1,
- Base2: s.Base2,
- Base3: s.Base3,
- }
-}
-func (s Base) NamedColors() colorlab.NamedColors {
- nc := make(colorlab.NamedColors, 8)
- arr := s.colorArray()
- for idx, hex := range arr {
- nc[baseNames[idx]] = hex
- }
- return nc
-}
-
-func (s Base) Colors() BaseColors {
- a := s.colorArray()
- return [8]colorful.Color{
- a[0].Color(),
- a[1].Color(),
- a[2].Color(),
- a[3].Color(),
- a[4].Color(),
- a[5].Color(),
- a[6].Color(),
- a[7].Color(),
- }
-}
-
-func (s Base) colorArray() [8]colorlab.HexColor {
- return [8]colorlab.HexColor{
- s.Base03,
- s.Base02,
- s.Base01,
- s.Base00,
- s.Base0,
- s.Base1,
- s.Base2,
- s.Base3,
- }
-}
-
-// Returns true if the LAB lightness of base0 is larger than base03.
-func (b Base) IsDarkOnBright() bool {
- return b.NamedColors().IsDarkOnBright("base03", "base0")
-}
-
-var baseNames = [8]string{
- 0: "base03",
- 1: "base02",
- 2: "base01",
- 3: "base00",
- 4: "base0",
- 5: "base1",
- 6: "base2",
- 7: "base3",
-}
-
-func (s Base) Inverse() Base {
- return Base{
- Base03: s.Base3,
- Base02: s.Base2,
- Base01: s.Base1,
- Base00: s.Base0,
- Base0: s.Base00,
- Base1: s.Base01,
- Base2: s.Base02,
- Base3: s.Base03,
- }
-}
-func (b Base) ChangeLightness(amountFgs, amountBgs float64) Base {
- cc := b.Colors()
- lightness := func(c colorful.Color, v float64) colorful.Color {
- l, a, b := c.Lab()
- l = l + v
- return colorful.Lab(l, a, b)
- }
- cc[0] = lightness(cc[0], amountBgs)
- cc[1] = lightness(cc[1], amountBgs)
- cc[2] = lightness(cc[2], amountFgs)
- cc[3] = lightness(cc[3], amountBgs)
- cc[4] = lightness(cc[4], amountFgs)
- cc[5] = lightness(cc[5], amountFgs)
- cc[6] = lightness(cc[6], amountFgs)
- cc[7] = lightness(cc[7], amountFgs)
- return NewBase(cc)
-}
diff --git a/colorlab/pkg/solarized/package.go b/colorlab/pkg/solarized/package.go
@@ -1,2 +0,0 @@
-// Package solarized contains functionality specific to the structure of a solarize palette
-package solarized
diff --git a/colorlab/pkg/solarized/solarized.go b/colorlab/pkg/solarized/solarized.go
@@ -1,26 +0,0 @@
-package solarized
-
-import "github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
-
-type Solarized struct {
- Base
- Accents
-}
-
-func (s Solarized) Clone() Solarized {
- return Solarized{
- Base: s.Base.Clone(),
- Accents: s.Accents.Clone(),
- }
-}
-
-func (s Solarized) Inverse() Solarized {
- return Solarized{
- Base: s.Base.Inverse(),
- Accents: s.Accents.Clone(),
- }
-}
-
-func (s Solarized) NamedColors() colorlab.NamedColors {
- return colorlab.Merge(s.Base.NamedColors(), s.Accents.NamedColors())
-}
diff --git a/colorlab/pkg/solarized/sort.go b/colorlab/pkg/solarized/sort.go
@@ -1,70 +0,0 @@
-package solarized
-
-import (
- "sort"
- "strings"
-
- "github.com/bbatsov/solarized-emacs/colorlab/pkg/colorlab"
-)
-
-// Orderedkeys returns the keys in a order that is like how solarized names should be ordered.
-//
-// primary orer is:
-//
-// 1. base names
-// 2. accent colors
-// 3. names that contain base names
-// 4. names that contain accent color names
-// 5. the rest
-//
-// secondary sort order is by string comparison.
-//
-func OrderedKeys(n colorlab.NamedColors) []string {
- var names []string
- for k, _ := range n {
- names = append(names, k)
- }
- sort.Sort(sort.StringSlice(names))
-
- var allNames []string
- for _, n := range baseNames {
- allNames = append(allNames, n)
- }
- for _, n := range accentNames {
- allNames = append(allNames, n)
- }
- score := func(idx int, exact bool) int {
- s := (len(allNames) - idx) + 1
- if exact {
- s = s + len(allNames)
- }
- return s
- }
- sort.SliceStable(names, func(i int, j int) bool {
- var is, js int // scores
- in := names[i]
- jn := names[j]
- scoring:
- for sortIdx, sortName := range allNames {
- if is == 0 {
- // log.Println(in, sortName)
- if strings.Contains(in, sortName) {
- is = score(sortIdx, in == sortName)
- // fmt.Println("score in", in, sortName, is)
- }
- }
- if js == 0 {
- if strings.Contains(jn, sortName) {
- js = score(sortIdx, jn == sortName)
- // fmt.Println("score j", jn, sortName, js)
- }
- }
- if is != 0 && js != 0 {
- break scoring
- }
- }
- // log.Println(is, js, in,jn)
- return is > js
- })
- return names
-}