zenity/color_darwin.go
2021-04-08 16:46:27 +01:00

28 lines
508 B
Go

package zenity
import (
"image/color"
"github.com/ncruces/zenity/internal/zenutil"
)
func selectColor(opts options) (color.Color, error) {
var col color.Color
if opts.color != nil {
col = opts.color
} else {
col = color.White
}
r, g, b, _ := col.RGBA()
out, err := zenutil.Run(opts.ctx, "color", []float32{
float32(r) / 0xffff,
float32(g) / 0xffff,
float32(b) / 0xffff,
})
str, ok, err := strResult(opts, out, err)
if ok {
return zenutil.ParseColor(str), nil
}
return nil, err
}