https://github.com/taigrr/colorhash
https://github.com/taigrr/colorhash
color colors go golang hacktoberfest
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/taigrr/colorhash
- Owner: taigrr
- License: 0bsd
- Created: 2022-03-22T04:15:32.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2026-02-23T03:02:56.000Z (4 months ago)
- Last Synced: 2026-02-23T10:57:41.282Z (4 months ago)
- Topics: color, colors, go, golang, hacktoberfest
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# colorhash
Map arbitrary strings and byte streams to deterministic colors from a given palette.
## Features
- **Deterministic hashing** — same input always produces the same color
- **FNV-64 based** — fast, well-distributed hash function
- **OKLCH palette generation** — perceptually uniform color palettes
- **ANSI terminal colors** — built-in escape code wrappers for terminal output
- **True color support** — 24-bit RGB terminal color output
## Install
```bash
go get github.com/taigrr/colorhash
```
## Usage
### Map a string to a color
```go
import (
"github.com/taigrr/colorhash"
"github.com/taigrr/simplecolorpalettes/flatui"
)
// Pick a color from a palette based on a string
c := colorhash.StringToColor(flatui.Palette, "alice")
```
### Generate an OKLCH palette
```go
// 8 evenly-spaced hues at lightness 0.7, chroma 0.15
palette := colorhash.GenerateOKLCHPalette(8, 0.7, 0.15)
```
### Terminal color output
```go
fmt.Println(colorhash.Red("error"))
fmt.Println(colorhash.Green("success"))
fmt.Println(colorhash.Info("info message"))
```
## License
0BSD