Documentation ¶
Overview ¶
Package chroma provides a collection of useful color-related functions.
Index ¶
- Variables
- func ColorToInt(c gamut.Color) int
- func ColorToRgb(c gamut.Color) color.RGBA
- func Default(defaultRGBA, rgba color.Color, err error) color.Color
- func IntToColor(name string, i int) gamut.Color
- func IntToRgb(i int) color.RGBA
- func Must(rgba color.Color, err error) color.Color
- func ParseHex(s string) (color.Color, error)
- func RgbToColor(name string, rgb color.RGBA) gamut.Color
- func RgbToInt(rgb color.RGBA) int
- type HSLA
- type RGBA
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ColorToInt ¶ added in v1.1.0
ColorToInt converts a gamut.Color struct into an integer, ignoring the alpha channel. This is a useful shorthand for calling ColorToRgb() and RgbToInt().
func ColorToRgb ¶ added in v1.1.0
ColorToRgb converts a gamut.Color struct to a color.RGBA struct, ignoring the alpha channel.
func Default ¶
Default returns the provided rgba if err == nil, if not it returns the provided defaultRGBA.
func IntToColor ¶ added in v1.1.0
IntToColor converts an integer to a gamut.Color struct, ignoring the alpha channel and with an optional name. This is a useful shorthand for calling IntToRgb() and RgbToColor().
func IntToRgb ¶ added in v1.1.0
IntToRgb converts an integer to a color.RGBA struct, ignoring the alpha channel.
func Must ¶
Must returns the provided rgba and panics if err != nil. This is useful for one-line or functions where hex code validity is certain or hard-coded.
func ParseHex ¶
ParseHex parses a hex code into a color.RGBA struct. The hex code may be in any of the following formats: - #RGB (CSS 3-digit hex color notation) - #RGBA (CSS 3-digit hex color notation + alpha) - #RRGGBB (CSS 6-digit hex color notation) - #RRGGBBA (CSS 6-digit hex color notation + alpha) Thanks to "icza" on StackOverflow for the fast hex code parsing: https://stackoverflow.com/a/54200713
func RgbToColor ¶ added in v1.1.0
RgbToColor converts a color.RGBA struct to a gamut.Color struct, with an optional name.