• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

docs/H03-May-2022-

examples/H07-Aug-2019-234181

palette/H07-Aug-2019-2,6982,670

theme/H07-Aug-2019-9570

.gitignoreH A D07-Aug-2019192 1310

.travis.ymlH A D07-Aug-2019704 3124

LICENSEH A D07-Aug-20191.1 KiB2217

README.mdH A D07-Aug-20195.1 KiB182126

colors.goH A D07-Aug-20194.3 KiB174117

colors_test.goH A D07-Aug-20193.8 KiB150128

gamut.goH A D07-Aug-20192 KiB10680

gamut_test.goH A D07-Aug-20192.5 KiB119103

generator.goH A D07-Aug-20194.3 KiB173112

generator_test.goH A D07-Aug-2019745 4234

README.md

1# gamut
2
3Go package to generate and manage color palettes & schemes
4
5```go
6import "github.com/muesli/gamut"
7import "github.com/muesli/gamut/palette"
8import "github.com/muesli/gamut/theme"
9```
10
11## Colors
12
13#### Around the Color Wheel
14
15The `Darker` and `Lighter` functions darken and lighten respectively a given
16color value by a specified percentage, without changing the color's hue:
17
18```go
19gamut.Darker(color, 0.1) // => color.Color
20// returns a 10% darker version of color
21gamut.Lighter(color, 0.3) // => color.Color
22// returns a 30% lighter version of color
23```
24
25`Complementary` returns the complementary color for a given color:
26
27```go
28gamut.Complementary(color) // => color.Color
29```
30
31`Contrast` returns the color with the highest contrast to a given color, either
32black or white:
33
34```go
35gamut.Contrast(color) // => color.Color
36```
37
38All the following functions return colors of a different hue, but with the same
39lightness and saturation as the given colors:
40
41```go
42gamut.Triadic(color)            // => []color.Color{...}
43gamut.Quadratic(color)          // => []color.Color{...}
44gamut.Tetradic(color1, color2)  // => []color.Color{...}
45gamut.Analogous(color)          // => []color.Color{...}
46gamut.SplitComplementary(color) // => []color.Color{...}
47```
48
49#### Warm/Cool Colors
50
51```go
52gamut.Warm(color) // => bool
53gamut.Cool(color) // => bool
54```
55
56#### Shades, Tints & Tones
57
58`Monochromatic` returns colors of the same hue, but with a different
59saturation/lightness:
60
61```go
62gamut.Monochromatic(color, 8) // => []color.Color{...}
63```
64
65![Monochromatic Palette](https://github.com/muesli/gamut/blob/master/docs/palette_monochromatic.png)
66
67`Shades` returns colors blended from the given color to black:
68
69```go
70gamut.Shades(color, 8) // => []color.Color{...}
71```
72
73![Shades Palette](https://github.com/muesli/gamut/blob/master/docs/palette_shades.png)
74
75`Tints` returns colors blended from the given color to white:
76
77```go
78gamut.Tints(color, 8) // => []color.Color{...}
79```
80
81![Tints Palette](https://github.com/muesli/gamut/blob/master/docs/palette_tints.png)
82
83`Tones` returns colors blended from the given color to gray:
84
85```go
86gamut.Tones(color, 8) // => []color.Color{...}
87```
88
89![Tones Palette](https://github.com/muesli/gamut/blob/master/docs/palette_tones.png)
90
91#### Blending Colors
92
93`Blends` returns interpolated colors by blending two colors:
94
95```go
96gamut.Blends(color1, color2, 8) // => []color.Color{...}
97```
98
99![Blends Palette](https://github.com/muesli/gamut/blob/master/docs/palette_blends.png)
100
101## Palettes
102
103| Name      | Colors | Source                                                      |
104| --------- | ------:| ----------------------------------------------------------- |
105| Wikipedia |   1609 | https://en.wikipedia.org/wiki/List_of_colors_(compact)      |
106| Crayola   |    180 | https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors |
107| Resene    |    759 | http://www.resene.co.nz                                     |
108| Monokai   |     17 |                                                             |
109
110#### Generating Color Palettes
111
112Color Generators, like the provided `PastelGenerator`, `WarmGenerator` or
113`HappyGenerator` can produce random (within the color space constraits of the
114generator) color palettes:
115
116```go
117gamut.Generate(8, gamut.PastelGenerator{})
118// => ([]color.Color{...}, error)
119```
120
121![Pastel Palette](https://github.com/muesli/gamut/blob/master/docs/palette_pastel.png)
122
123The `SimilarHueGenerator` produces colors with a hue similar to a given color:
124
125```go
126gamut.Generate(8, gamut.SimilarHueGenerator{Color: gamut.Hex("#2F1B82")})
127// => ([]color.Color{...}, error)
128```
129
130![Similar Hue Palette](https://github.com/muesli/gamut/blob/master/docs/palette_similarhue.png)
131
132Using the `ColorGenerator` interface, you can also write your own color generators.
133
134#### Name A Color
135
136```go
137palette.Wikipedia.Name(color) // => (name string, distance float64)
138// name = "Baby blue"
139// distance between 0.0 and 1.0
140```
141
142#### Retrieving Colors
143
144```go
145palette.Crayola.Filter("Red") // => []color.Color{...}
146// returns a slice of all "Red" colors in the Crayola palette
147palette.Resene.Colors() // => []color.Color{...}
148// returns a slice of all colors in the Resene palette
149palette.Monokai.Clamped(colors) // => []color.Color{...}
150// returns a slice of the nearest matching colors in the Monokai palette
151```
152
153#### Mixing Palettes
154
155You can combine all colors of two palettes by mixing them:
156
157```go
158palette.Crayola.MixedWith(palette.Monokai) // => gamut.Palette
159```
160
161## Themes
162
163| Name    | Colors |
164| ------- | ------:|
165| Monokai |      7 |
166
167#### Roles
168
169```go
170theme.MonokaiTheme.Role(theme.Foreground) // => color.Color
171```
172
173Available roles are `Foreground`, `Background`, `Base`, `AlternateBase`, `Text`,
174`Selection`, `Highlight`.
175
176## Development
177
178[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/muesli/gamut)
179[![Build Status](https://travis-ci.org/muesli/gamut.svg?branch=master)](https://travis-ci.org/muesli/gamut)
180[![Coverage Status](https://coveralls.io/repos/github/muesli/gamut/badge.svg?branch=master)](https://coveralls.io/github/muesli/gamut?branch=master)
181[![Go ReportCard](http://goreportcard.com/badge/muesli/gamut)](http://goreportcard.com/report/muesli/gamut)
182