zenity/color_darwin.go
2020-01-22 01:15:29 +00:00

27 lines
554 B
Go

package zenity
import (
"image/color"
"os/exec"
"github.com/ncruces/zenity/internal/zenutil"
)
func SelectColor(options ...Option) (color.Color, error) {
opts := optsParse(options)
var data zenutil.Color
if opts.color != nil {
n := color.NRGBA64Model.Convert(opts.color).(color.NRGBA64)
data.Color = []uint16{n.R, n.G, n.B}
}
out, err := zenutil.Run("color", data)
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 {
return nil, nil
}
if err != nil {
return nil, err
}
return zenutil.ParseColor(string(out)), nil
}