{"id":13475395,"url":"https://github.com/muesli/gamut","last_synced_at":"2025-05-16T17:07:28.914Z","repository":{"id":33827518,"uuid":"134611107","full_name":"muesli/gamut","owner":"muesli","description":"Go package to generate and manage color palettes \u0026 schemes 🎨","archived":false,"fork":false,"pushed_at":"2023-09-05T09:51:01.000Z","size":332,"stargazers_count":555,"open_issues_count":7,"forks_count":26,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-12T15:58:50.068Z","etag":null,"topics":["color-blending","color-palettes","color-schemes","color-wheel","gamut","hue","themes","tints"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muesli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"muesli"}},"created_at":"2018-05-23T18:36:38.000Z","updated_at":"2025-04-08T19:10:47.000Z","dependencies_parsed_at":"2022-07-28T20:59:57.436Z","dependency_job_id":"6d7bade8-a3ec-47f8-8449-eb0bf20f8d2a","html_url":"https://github.com/muesli/gamut","commit_stats":{"total_commits":123,"total_committers":6,"mean_commits":20.5,"dds":0.06504065040650409,"last_synced_commit":"a58a8d51c526e4611d4f75189df23b0546b82a06"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fgamut","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fgamut/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fgamut/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fgamut/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muesli","download_url":"https://codeload.github.com/muesli/gamut/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254573588,"owners_count":22093731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color-blending","color-palettes","color-schemes","color-wheel","gamut","hue","themes","tints"],"created_at":"2024-07-31T16:01:20.045Z","updated_at":"2025-05-16T17:07:28.890Z","avatar_url":"https://github.com/muesli.png","language":"Go","funding_links":["https://github.com/sponsors/muesli"],"categories":["Go"],"sub_categories":[],"readme":"# gamut\n\n[![Latest Release](https://img.shields.io/github/release/muesli/gamut.svg)](https://github.com/muesli/gamut/releases)\n[![Build Status](https://github.com/muesli/gamut/workflows/build/badge.svg)](https://github.com/muesli/gamut/actions)\n[![Coverage Status](https://coveralls.io/repos/github/muesli/gamut/badge.svg?branch=master)](https://coveralls.io/github/muesli/gamut?branch=master)\n[![Go ReportCard](https://goreportcard.com/badge/muesli/gamut)](https://goreportcard.com/report/muesli/gamut)\n[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://pkg.go.dev/github.com/muesli/gamut)\n\nGo package to generate and manage color palettes \u0026 schemes\n\n```go\nimport \"github.com/muesli/gamut\"\nimport \"github.com/muesli/gamut/palette\"\nimport \"github.com/muesli/gamut/theme\"\n```\n\n## Colors\n\ngamut operates on various color spaces internally, but all color values you pass\nin as parameters and all return values will match Go’s color.Color interface.\n\nLet’s start with the basics. Just for convenience there’s a hex-value parser:\n\n```go\ncolor = gamut.Hex(\"#333\")\ncolor = gamut.Hex(\"#ABCDEF\")\n```\n\nBoth the short and standard formats are supported.\n\nConversely you can retrieve the hex encoding of any `color.Color` value:\n\n```go\nhex = gamut.ToHex(color)\n```\n\n### Around the Color Wheel\n\nThe `Darker` and `Lighter` functions darken and lighten respectively a given\ncolor value by a specified percentage, without changing the color's hue:\n\n```go\n// returns a 10% darker version of color\ncolor = gamut.Darker(color, 0.1)\n// returns a 30% lighter version of color\ncolor = gamut.Lighter(color, 0.3)\n```\n\n`Complementary` returns the complementary color for a given color:\n\n```go\ncolor = gamut.Complementary(color)\n```\n\n`Contrast` returns the color with the highest contrast to a given color, either\nblack or white:\n\n```go\ncolor = gamut.Contrast(color)\n```\n\nTo retrieve a color with the same lightness and saturation, but a different\nangle on the color wheel, you can use the HueOffset function:\n\n```go\ncolor = gamut.HueOffset(color, 90)\n```\n\nYou can also go in the opposite direction by using negative values.\n\n### Schemes\n\nAll the following functions return colors of a different hue, but with the same\nlightness and saturation as the given colors:\n\nTriadic schemes are made up of three hues equally spaced around the color wheel:\n\n```go\ncolors = gamut.Triadic(color)\n```\n\nQuadratic schemes are made up of four hues equally spaced around the color wheel:\n\n```go\ncolors = gamut.Quadratic(color)\n```\n\nTetradic schemes are made up by two colors and their complementary values:\n\n```go\ncolors = gamut.Tetradic(color1, color2)\n```\n\nAnalogous schemes are created by using colors that are next to each other on the\ncolor wheel:\n\n```go\ncolors = gamut.Analogous(color)\n```\n\nSplitComplementary schemes are created by using colors next to the complementary\nvalue of a given color:\n\n```go\ncolors = gamut.SplitComplementary(color)\n```\n\n### Warm/Cool Colors\n\n```go\nok = gamut.Warm(color)\nok = gamut.Cool(color)\n```\n\n### Shades, Tints \u0026 Tones\n\n`Monochromatic` returns colors of the same hue, but with a different\nsaturation/lightness:\n\n```go\ncolors = gamut.Monochromatic(color, 8)\n```\n\n![Monochromatic Palette](https://github.com/muesli/gamut/blob/master/docs/palette_monochromatic.png)\n\n`Shades` returns colors blended from the given color to black:\n\n```go\ncolors = gamut.Shades(color, 8)\n```\n\n![Shades Palette](https://github.com/muesli/gamut/blob/master/docs/palette_shades.png)\n\n`Tints` returns colors blended from the given color to white:\n\n```go\ncolors = gamut.Tints(color, 8)\n```\n\n![Tints Palette](https://github.com/muesli/gamut/blob/master/docs/palette_tints.png)\n\n`Tones` returns colors blended from the given color to gray:\n\n```go\ncolors = gamut.Tones(color, 8)\n```\n\n![Tones Palette](https://github.com/muesli/gamut/blob/master/docs/palette_tones.png)\n\n### Blending Colors\n\n`Blends` returns interpolated colors by blending two colors:\n\n```go\ncolors = gamut.Blends(color1, color2, 8)\n```\n\n![Blends Palette](https://github.com/muesli/gamut/blob/master/docs/palette_blends.png)\n\n## Palettes\n\nGamut comes with six curated color palettes: Wikipedia, Crayola, CSS, RAL,\nResene, and Monokai. The Wikipedia palette is an import of common colors from\nWikipedia’s List of Colors. New curated palettes and importers are welcome. Send me\na pull request!\n\n| Name      | Colors | Source                                                       |\n| --------- | -----: | ------------------------------------------------------------ |\n| Wikipedia |   1609 | https://en.wikipedia.org/wiki/List_of_colors_(compact)       |\n| Crayola   |    180 | https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors  |\n| CSS       |    147 | https://developer.mozilla.org/en-US/docs/Web/CSS/color_value |\n| RAL       |    213 | https://en.wikipedia.org/wiki/List_of_RAL_colors             |\n| Resene    |    759 | http://www.resene.co.nz                                      |\n| Monokai   |     17 |                                                              |\n\nThe function Colors lets you retrieve all colors in a palette:\n\n```go\nfor _, c := range palette.Wikipedia.Colors() {\n    fmt.Println(c.Name, c.Color)\n}\n```\n\nThis will print out a list of 1609 color names, as defined by Wikipedia.\n\n### Creating Your Own Palettes\n\n```go\nvar p gamut.Palette\np.AddColors(\n    gamut.Colors{\n        {\"Name\", gamut.Hex(\"#123456\"), \"Reference\"},\n        ...\n    }\n)\n```\n\nName and Reference are optional when creating your own palettes.\n\n### Names\n\nEach color in the curated palettes comes with an “official” name. You can filter\npalettes by colors with specific names. This code snippet will return a list of\nall “blue” colors in the Wikipedia palette:\n\n```go\ncolors = palette.Wikipedia.Filter(\"blue\")\n```\n\nYou can access a color with a specific name using the `Color` function:\n\n```go\ncolor, ok = palette.Wikipedia.Color(\"Pastel blue\")\n```\n\nCalling a palette’s `Name` function with a given color returns the name \u0026 distance\nof the closest (perceptually) matching color in it:\n\n```go\nname, distance = palette.Wikipedia.Name(color)\n// name = \"Baby blue\"\n// distance between 0.0 and 1.0\n```\n\n### Mixing Palettes\n\nYou can combine all colors of two palettes by mixing them:\n\n```go\np = palette.Crayola.MixedWith(palette.Monokai)\n```\n\n### Perception\n\nSometimes you got a slice of colors, but you have a limited color palette to\nwork with. The Clamped function returns a slice of the closest perceptually\nmatching colors in a palette, maintaining the same order as the original slice\nyou provided. Finally you can remix your favorite wallpapers in Crayola-style!\n\n```go\ncolors = palette.Crayola.Clamped(colors)\n```\n\n### Generating Color Palettes\n\nColor Generators, like the provided `PastelGenerator`, `WarmGenerator` or\n`HappyGenerator` can produce random (within the color space constraints of the\ngenerator) color palettes:\n\n```go\ncolors, err = gamut.Generate(8, gamut.PastelGenerator{})\n```\n\n![Pastel Palette](https://github.com/muesli/gamut/blob/master/docs/palette_pastel.png)\n\nThe `SimilarHueGenerator` produces colors with a hue similar to a given color:\n\n```go\ncolors, err = gamut.Generate(8, gamut.SimilarHueGenerator{Color: gamut.Hex(\"#2F1B82\")})\n```\n\n![Similar Hue Palette](https://github.com/muesli/gamut/blob/master/docs/palette_similarhue.png)\n\nUsing the `ColorGenerator` interface, you can also write your own color generators:\n\n```go\ntype BrightGenerator struct {\n\tBroadGranularity\n}\n\nfunc (cc BrightGenerator) Valid(col colorful.Color) bool {\n\t_, _, l := col.Lab()\n\treturn 0.7 \u003c= l \u0026\u0026 l \u003c= 1.0\n}\n\n...\ncolors, err := gamut.Generate(8, BrightGenerator{})\n```\n\nOnly colors with a lightness between 0.7 and 1.0 will be accepted by this generator.\n\n## Themes\n\n| Name    | Colors |\n| ------- | -----: |\n| Monokai |      7 |\n\n### Roles\n\n```go\ncolor = theme.MonokaiTheme.Role(theme.Foreground)\n```\n\nAvailable roles are `Foreground`, `Background`, `Base`, `AlternateBase`, `Text`,\n`Selection`, `Highlight`.\n\n## Feedback\n\nGot some feedback or suggestions? Please open an issue or drop me a note!\n\n* [Twitter](https://twitter.com/mueslix)\n* [The Fediverse](https://mastodon.social/@fribbledom)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuesli%2Fgamut","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuesli%2Fgamut","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuesli%2Fgamut/lists"}