Files
Server/internal/color/hs.go
T
2022-08-19 10:55:29 +02:00

21 lines
362 B
Go

package color
import (
"github.com/lucasb-eyer/go-colorful"
"math"
)
type HueSat struct {
Hue float64 `json:"hue"`
Sat float64 `json:"sat"`
}
func (hs HueSat) ToXY() XY {
return hs.ToRGB().ToXY()
}
func (hs HueSat) ToRGB() RGB {
c := colorful.Hsv(hs.Hue, hs.Sat, 1)
return RGB{Red: math.Max(c.R, 0), Green: math.Max(c.G, 0), Blue: math.Max(c.B, 0)}
}