Skip to content
/ oklab Public

Oklab color space for Go's image.Color

License

Notifications You must be signed in to change notification settings

alltom/oklab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oklab/Oklch color space for Go

Go Reference

Oklab is a more perceptually-accurate color space than HSV. Oklch is the same space with polar coordinates.

Great compatibility with Go's image library:

  • oklab.Oklab and oklab.Oklch implement image.Color
  • oklab.OklabModel and oklab.OklchModel implement image.Model

See https://bottosson.github.io/posts/oklab/ for the details, but here's the tl;dr:

Comparison of gradients created in Oklab and HSV color spaces with lightness and chroma held fixed—the Oklab image is significantly smoother

This library is fully-documented, with examples, but here's how to convert Oklab to RGB:

oklabc := oklab.Oklab{L: 0.9322421414586456, A: 0.03673270292094283, B: 0.0006123556644819055}
r, g, b, _ := oklabc.RGBA()

About

Oklab color space for Go's image.Color

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages