https://github.com/hsluv/hsluv-go
Go implementation of HSLuv (revision 4)
https://github.com/hsluv/hsluv-go
Last synced: about 1 year ago
JSON representation
Go implementation of HSLuv (revision 4)
- Host: GitHub
- URL: https://github.com/hsluv/hsluv-go
- Owner: hsluv
- License: mit
- Created: 2016-01-17T11:02:46.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-05-03T00:15:30.000Z (about 3 years ago)
- Last Synced: 2025-04-12T10:05:00.661Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 995 KB
- Stars: 31
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://github.com/hsluv/hsluv-go/actions/workflows/test.yml)
Go port of HSLuv (revision 4), written by [Michael Glanznig](https://github.com/nebulon42)
More details about HSLuv at http://www.hsluv.org.
# API
**hsluv.HsluvToHex(hue, saturation, lightness)**
*hue* is a number between 0 and 360, *saturation* and *lightness* are numbers between 0 and 100. This function returns the resulting color as a hex string.
**hsluv.HsluvlToRGB(hue, saturation, lightness)**
Like above, but returns 3 numbers between 0 and 1, for the r, g, and b channel.
**hsluv.HsluvFromHex(hex)**
Takes a hex string and returns the HSLuv color as 3 numbers for hue (0-360), saturation (0-100) and lightness (0-100).
_Note_: The result can have rounding errors. For example saturation can be 100.00000000000007
**hsluv.HsluvFromRGB(red, green, blue)**
Like above, but *red*, *green* and *blue* are passed as numbers between 0 and 1.
Use **HpluvToHex**, **HpluvToRGB**, **HpluvFromHex** and **HpluvFromRGB** for the pastel variant (HPLuv).
# Testing
Run `go test`.
# Thanks
Testing was inspired by [omniscale/magnacarto](https://github.com/omniscale/magnacarto).