Documentation
¶
Index ¶
- Variables
- type Color
- type HEXColor
- type RGBAColor
- func (c *RGBAColor) Equal(d Color) bool
- func (c *RGBAColor) IsDark() bool
- func (c *RGBAColor) IsDarkAlpha(bg Color) bool
- func (c *RGBAColor) IsLight() bool
- func (c *RGBAColor) IsLightAlpha(bg Color) bool
- func (c *RGBAColor) RGBA() (r, g, b, a uint32)
- func (c *RGBAColor) String() string
- func (c *RGBAColor) ToHEX() *HEXColor
- func (c *RGBAColor) ToRGB() *RGBColor
- func (c *RGBAColor) ToRGBA() *RGBAColor
- type RGBColor
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadColor is the default bad color error ErrBadColor = errors.New("parsing of color failed, Bad Color") )
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color interface { // ToHEX converts the Color interface to a concrete HEXColor ToHEX() *HEXColor // ToRGB converts the Color interface to a concrete RGBColor ToRGB() *RGBColor // ToRGBA converts the Color interface to a concrete RGBAColor ToRGBA() *RGBAColor // String returns the string representation of the Color String() string // IsLight returns whether the color is perceived to be a light color // http://stackoverflow.com/a/24213274/3158232 and http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx IsLight() bool // IsDark returns whether the color is perceived to be a dark color //for perceived luminance, not strict math IsDark() bool // RGBA implements std-lib color.Color interface. // It returns the red, green, blue and alpha values for the color. Each value ranges within [0, 0xffff] RGBA() (r, g, b, a uint32) // Equal reports whether the colors are the same Equal(Color) bool }
Color is the base color interface from which all others ascribe to
type HEXColor ¶
type HEXColor struct {
// contains filtered or unexported fields
}
HEXColor represents a HEX color
func (*HEXColor) RGBA ¶ added in v1.3.0
RGBA implements color.Color interface. It returns the red, green, blue and alpha values for the color. Each value ranges within [0, 0xffff]
func (*HEXColor) ToHEX ¶
ToHEX converts the HEXColor to a HEXColor it's here to satisfy the Color interface
type RGBAColor ¶
RGBAColor represents an RGBA color
func FromStdColor ¶ added in v1.2.0
func ParseRGBA ¶
ParseRGBA validates an parses the provided string into an RGBAColor object supports both RGBA 255 and RGBA as percentages
func (*RGBAColor) IsDark ¶
IsDark returns whether the color is perceived to be a dark color NOTE: this is determined only by the RGB values, if you need to take the alpha into account see the IsLightAlpha function
func (*RGBAColor) IsDarkAlpha ¶
IsDarkAlpha returns whether the color is perceived to be a dark color based on RGBA values and the provided background color algorithm based of of post here: http://stackoverflow.com/a/12228643/3158232
func (*RGBAColor) IsLight ¶
IsLight returns whether the color is perceived to be a light color NOTE: this is determined only by the RGB values, if you need to take the alpha into account see the IsLightAlpha function
func (*RGBAColor) IsLightAlpha ¶
IsLightAlpha returns whether the color is perceived to be a light color based on RGBA values and the provided background color algorithm based of of post here: http://stackoverflow.com/a/12228643/3158232
func (*RGBAColor) RGBA ¶ added in v1.3.0
RGBA implements color.Color interface. It returns the red, green, blue and alpha values for the color. Each value ranges within [0, 0xffff]
type RGBColor ¶
RGBColor represents an RGB color
func ParseRGB ¶
ParseRGB validates an parses the provided string into an RGBColor object supports both RGB 255 and RGB as percentages
func (*RGBColor) RGBA ¶ added in v1.3.0
RGBA implements color.Color interface. It returns the red, green, blue and alpha values for the color. Each value ranges within [0, 0xffff]