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.
|
|
package color
import "github.com/lucasb-eyer/go-colorful"
type RGB struct { Red float64 `json:"red"` Green float64 `json:"green"` Blue float64 `json:"blue"` }
func (rgb RGB) AtIntensity(intensity float64) RGB { hue, sat, _ := colorful.Color{R: rgb.Red, G: rgb.Green, B: rgb.Blue}.Hsv() hsv2 := colorful.Hsv(hue, sat, intensity) return RGB{Red: hsv2.R, Green: hsv2.G, Blue: hsv2.B} }
func (rgb RGB) Bytes() [3]uint8 { return [3]uint8{ uint8(rgb.Red * 255.0), uint8(rgb.Green * 255.0), uint8(rgb.Blue * 255.0), } }
func (rgb RGB) ToHS() HueSat { hue, sat, _ := colorful.Color{R: rgb.Red, G: rgb.Green, B: rgb.Blue}.Hsv() return HueSat{Hue: hue, Sat: sat} }
func (rgb RGB) ToXY() XY { x, y, z := (colorful.Color{R: rgb.Red, G: rgb.Green, B: rgb.Blue}).Xyz()
return XY{ X: x / (x + y + z), Y: y / (x + y + z), } }
|