{"id":31067323,"url":"https://github.com/bububa/colormix","last_synced_at":"2025-09-15T19:58:49.496Z","repository":{"id":277113845,"uuid":"930878059","full_name":"bububa/colormix","owner":"bububa","description":"A Go Library for Color Mixing Optimization","archived":false,"fork":false,"pushed_at":"2025-02-11T11:10:44.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T08:18:38.359Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bububa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-11T11:07:46.000Z","updated_at":"2025-02-11T11:09:41.000Z","dependencies_parsed_at":"2025-02-15T20:01:06.129Z","dependency_job_id":null,"html_url":"https://github.com/bububa/colormix","commit_stats":null,"previous_names":["bububa/colormix"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bububa/colormix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fcolormix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fcolormix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fcolormix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fcolormix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bububa","download_url":"https://codeload.github.com/bububa/colormix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fcolormix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275312966,"owners_count":25442563,"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","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-09-15T19:58:44.600Z","updated_at":"2025-09-15T19:58:49.478Z","avatar_url":"https://github.com/bububa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ColorMix - A Go Library for Color Mixing Optimization\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/bububa/colormix.svg)](https://pkg.go.dev/github.com/bububa/colormix)\n[![Go](https://github.com/bububa/colormix/actions/workflows/go.yml/badge.svg)](https://github.com/bububa/colormix/actions/workflows/go.yml)\n[![goreleaser](https://github.com/bububa/colormix/actions/workflows/goreleaser.yml/badge.svg)](https://github.com/bububa/colormix/actions/workflows/goreleaser.yml)\n[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/bububa/colormix.svg)](https://github.com/bububa/colormix)\n[![GoReportCard](https://goreportcard.com/badge/github.com/bububa/colormix)](https://goreportcard.com/report/github.com/bububa/colormix)\n[![GitHub license](https://img.shields.io/github/license/bububa/colormix.svg)](https://github.com/bububa/colormix/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/bububa/colormix.svg)](https://GitHub.com/bububa/colormix/releases/)\n\n_ColorMix_ is a Go library that optimizes color mixing by adjusting the proportions of a given set of colors to match a target color. The library uses optimization algorithms to find the best weights (proportions) for a set of colors in order to minimize the difference between the mixed color and the target color. The optimization is based on color differences, and it supports advanced optimization techniques.\n\n## Features\n\n- Mix colors to match a target color.\n- Uses CIEDE2000 color difference metric for better perceptual accuracy.\n- Supports different optimization algorithms like Nelder-Mead for general use cases.\n- Prevents zero color contributions through penalty functions.\n\n## Installation\n\nTo install the ColorMix library, use the go get command:\n\n```bash\ngo get -u github.com/bububa/colormix\n```\n\n## Example Usage\n\n### Import the package\n\n```golong\nimport \"github.com/yourusername/colormix\"\n```\n\n### Basic Example: Mix Colors to Match a Target\n\nHere is a simple example of how to use the library to mix a set of colors and match a target color.\n\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\t\"image/color\"\n\n\t\"github.com/bububa/colormix\"\n)\n\nfunc main() {\n\ttargetColor := color.RGBA{200, 100, 50, 255}\n\tpalette := colormix.NewPalette(\n\t\t// RED\n\t\tcolor.RGBA{255, 0, 0, 255},\n\t\t// GREEN\n\t\tcolor.RGBA{0, 255, 0, 255},\n\t\t// BLUE\n\t\tcolor.RGBA{0, 0, 255, 255},\n\t\t// WHITE\n\t\tcolor.RGBA{255, 255, 255, 255},\n\t\t// BLACK\n\t\tcolor.RGBA{0, 0, 0, 255},\n\t)\n\tmixedColor, err := colormix.Mix(targetColor, palette, RGB)\n\tif err != nil {\n\t\treturn\n\t}\n\tfmt.Printf(\"Target: %s\\n\", MakeColor(targetColor).Hex())\n\tfmt.Println(\"\")\n\tfor _, v := range palette.Colors() {\n\t\tfmt.Printf(\"%s: %.0f%%\\n\", v.Hex(), v.Ratio()*100)\n\t}\n\tfmt.Println(\"\")\n\tfmt.Printf(\"Mixed: %s\\n\", MakeColor(mixedColor).Hex())\n\t// Output:\n\t// Target: #c86432\n\t//\n\t// #ff0000: 56%\n\t// #00ff00: 11%\n\t// #0000ff: 1%\n\t// #ffffff: 2%\n\t// #000000: 30%\n\t//\n\t// Mixed: #c86432\n}\n```\n\n### Explanation\n\n1. _palette_: This is a matrix containing the available colors in RGB format.\n2. _targetColor_: The target color that we want to match through mixing.\n3. _Mix_: This function finds the optimal proportions (weights) of the available colors that best approximate the target color.\n4. _mixedColor_: Once the optimal weights are calculated, this function computes the resulting mixed color based on the color table and the calculated weights.\n\n## Color Metrics\n\nThe library uses the CIEDE2000 color difference metric to calculate the color differences, which provides a more perceptually accurate measure of color difference than Euclidean distance in RGB space.\n\n## Available Functions\n\nMixColors(targetColor color.Color, palette \\*colormix.Palette, colorspace colormix.ColorMix) (mixedColor color.Color, err error): Computes the optimal weights for the given color table to match the target color and Calculates the final mixed color based on the optimal weights and the color table.\n\n## Optimizers Supported\n\n- _Nelder-Mead_: A simplex-based optimization method that doesn't require derivatives. Suitable for non-differentiable functions.\n- _LBFGS (Limited-memory Broyden–Fletcher–Goldfarb–Shanno)_: A gradient-based method that is more efficient for smooth, differentiable functions.\n\n## Contributing\n\nWe welcome contributions! If you find a bug or want to suggest a feature, feel free to open an issue or submit a pull request.\n\n### Steps to Contribute:\n\n1. Fork the repository.\n2. Create a new branch (git checkout -b feature-name).\n3. Make your changes and commit them (git commit -am 'Add new feature').\n4. Push to the branch (git push origin feature-name).\n5. Open a pull request.\n\n## License\n\nThis project is licensed under the MIT License—see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Fcolormix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbububa%2Fcolormix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Fcolormix/lists"}