You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
362 B

  1. package color
  2. import (
  3. "github.com/lucasb-eyer/go-colorful"
  4. "math"
  5. )
  6. type HueSat struct {
  7. Hue float64 `json:"hue"`
  8. Sat float64 `json:"sat"`
  9. }
  10. func (hs HueSat) ToXY() XY {
  11. return hs.ToRGB().ToXY()
  12. }
  13. func (hs HueSat) ToRGB() RGB {
  14. c := colorful.Hsv(hs.Hue, hs.Sat, 1)
  15. return RGB{Red: math.Max(c.R, 0), Green: math.Max(c.G, 0), Blue: math.Max(c.B, 0)}
  16. }