Go package to generate and manage color palettes & schemes
import "github.com/muesli/gamut"
import "github.com/muesli/gamut/palette"
import "github.com/muesli/gamut/theme"
The Darker
and Lighter
functions darken and lighten respectively a given
color value by a specified percentage, without changing the color's hue:
gamut.Darker(color, 0.1) // => color.Color
// returns a 10% darker version of color
gamut.Lighter(color, 0.3) // => color.Color
// returns a 30% lighter version of color
Complementary
returns the complementary color for a given color:
gamut.Complementary(color) // => color.Color
Contrast
returns the color with the highest contrast to a given color, either
black or white:
gamut.Contrast(color) // => color.Color
All the following functions return colors of a different hue, but with the same lightness and saturation as the given colors:
gamut.Triadic(color) // => []color.Color{...}
gamut.Quadratic(color) // => []color.Color{...}
gamut.Tetradic(color1, color2) // => []color.Color{...}
gamut.Analogous(color) // => []color.Color{...}
gamut.SplitComplementary(color) // => []color.Color{...}
gamut.Warm(color) // => bool
gamut.Cool(color) // => bool
Monochromatic
returns colors of the same hue, but with a different
saturation/lightness:
gamut.Monochromatic(color, 8) // => []color.Color{...}
Shades
returns colors blended from the given color to black:
gamut.Shades(color, 8) // => []color.Color{...}
Tints
returns colors blended from the given color to white:
gamut.Tints(color, 8) // => []color.Color{...}
Tones
returns colors blended from the given color to gray:
gamut.Tones(color, 8) // => []color.Color{...}
Blends
returns interpolated colors by blending two colors:
gamut.Blends(color1, color2, 8) // => []color.Color{...}
Name | Colors | Source |
---|---|---|
Wikipedia | 1609 | https://en.wikipedia.org/wiki/List_of_colors_(compact) |
Crayola | 180 | https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors |
Resene | 759 | http://www.resene.co.nz |
Monokai | 17 |
Color Generators, like the provided PastelGenerator
, WarmGenerator
or
HappyGenerator
can produce random (within the color space constraits of the
generator) color palettes:
gamut.Generate(8, gamut.PastelGenerator{})
// => ([]color.Color{...}, error)
The SimilarHueGenerator
produces colors with a hue similar to a given color:
gamut.Generate(8, gamut.SimilarHueGenerator{Color: gamut.Hex("#2F1B82")})
// => ([]color.Color{...}, error)
Using the ColorGenerator
interface, you can also write your own color generators.
palette.Wikipedia.Name(color) // => (name string, distance float64)
// name = "Baby blue"
// distance between 0.0 and 1.0
palette.Crayola.Filter("Red") // => []color.Color{...}
// returns a slice of all "Red" colors in the Crayola palette
palette.Resene.Colors() // => []color.Color{...}
// returns a slice of all colors in the Resene palette
palette.Monokai.Clamped(colors) // => []color.Color{...}
// returns a slice of the nearest matching colors in the Monokai palette
You can combine all colors of two palettes by mixing them:
palette.Crayola.MixedWith(palette.Monokai) // => gamut.Palette
Name | Colors |
---|---|
Monokai | 7 |
theme.MonokaiTheme.Role(theme.Foreground) // => color.Color
Available roles are Foreground
, Background
, Base
, AlternateBase
, Text
,
Selection
, Highlight
.