Documentation ¶
Index ¶
- Variables
- type Color
- type HEXColor
- type RGBAColor
- 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) 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() *HEXColor ToRGB() *RGBColor ToRGBA() *RGBAColor String() string IsLight() bool // http://stackoverflow.com/a/24213274/3158232 and http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx IsDark() bool //for perceived luminance, not strict math }
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) ToHEX ¶
ToHEX converts the HEXColor to a HEXColor it's here to satisfy the Color interface
type RGBAColor ¶
RGBAColor represents an RGBA color
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
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