Important
🔥 Found this useful? A quick star goes a long way.
An opinionated Go library for working with colors. These color types model color
spaces but do not implement color.Color or color.Model.
This is a semi-read-only clone of
github.com/Nadim147c/material/v2. This package only contains color models. Files prefixed withzz_*are generated usinggo run ./generate.
ARGBCam16HctLCHabLCHuvLabLinearRGBLuvModelOkLabOkLchXYZ
go get -u github.com/Nadim147c/go-chromaGenerate 10 shade of a color from a random hue. These colors are perceptually linear.
package main
import (
"fmt"
"math/rand"
"github.com/Nadim147c/go-chroma"
"github.com/Nadim147c/go-chroma/num"
)
func main() {
const count = 10.0 // generate 10 colors
const steps = 100 / (count - 1)
hue := rand.Float64() * 360 // random hue
palette := make([]chroma.ARGB, count)
for i := range palette {
tc := num.Clamp(5, 95, float64(i)*steps)
palette[i] = chroma.Hct{Hue: hue, Chroma: tc, Tone: tc}.ToARGB()
fmt.Println(palette[i].AnsiBg(" "))
}
}This code is licensed under the original Apache 2.0.
