Add stringers to color structs

This commit is contained in:
Ryan Cavicchioni 2021-04-18 16:16:34 +00:00
parent f79ea1df5d
commit 4c1678b62c
Signed by: chill9
GPG Key ID: 877EEDAF9245103D
1 changed files with 12 additions and 0 deletions

View File

@ -163,6 +163,10 @@ func (c RGBColor) ColorString() string {
return fmt.Sprintf("rgb:%d,%d,%d", c.R, c.G, c.B)
}
func (c RGBColor) String() string {
return c.ColorString()
}
func (c RGBColor) Hex() string {
return fmt.Sprintf("#%x%x%x", c.R, c.G, c.B)
}
@ -184,6 +188,10 @@ func (c HSBKColor) ColorString() string {
return strings.Join(s, " ")
}
func (c HSBKColor) String() string {
return c.ColorString()
}
func (c HSBKColor) MarshalText() ([]byte, error) {
return []byte(c.ColorString()), nil
}
@ -196,6 +204,10 @@ func (c NamedColor) ColorString() string {
return string(c)
}
func (c NamedColor) String() string {
return c.ColorString()
}
func (c *Client) ValidateColor(color Color) (Color, error) {
var (
err error