类型 ColorPickerValue

API 文档由 Go 源码生成,内容为英文。

type ColorPickerValue struct {
	Hue, Saturation, Brightness, Alpha float32
}

ColorPickerValue is caller-owned HSV editing state. Keeping HSV rather than rebuilding it from RGB on every paint preserves the hue at gray and black.

方法

AppendHex#

func (v ColorPickerValue) AppendHex(dst []byte, alpha bool) []byte

AppendHex appends canonical #RRGGBB (or #RRGGBBAA) to caller-owned storage. Format only when a value changes; painting consumes the caller's input text.

Color#

func (v ColorPickerValue) Color() ui.Color

Color converts the selected HSV value to straight RGBA without allocating.

WithColor#

func (v ColorPickerValue) WithColor(c ui.Color) ColorPickerValue

WithColor loads an RGB edit, retaining hue for achromatic colors and the previous saturation at black so a subsequent brightness change is useful.