colors

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AliceBlue            = NamedColor{"#f0f8ff"}
	AntiqueWhite         = NamedColor{"#faebd7"}
	Aqua                 = NamedColor{"#00ffff"}
	Aquamarine           = NamedColor{"#7fffd4"}
	Azure                = NamedColor{"#f0ffff"}
	Beige                = NamedColor{"#f5f5dc"}
	Bisque               = NamedColor{"#ffe4c4"}
	Black                = NamedColor{"#000000"}
	BlanchedAlmond       = NamedColor{"#ffebcd"}
	Blue                 = NamedColor{"#0000ff"}
	BlueViolet           = NamedColor{"#8a2be2"}
	Brown                = NamedColor{"#a52a2a"}
	BurlyWood            = NamedColor{"#deb887"}
	CadetBlue            = NamedColor{"#5f9ea0"}
	Chartreuse           = NamedColor{"#7fff00"}
	Chocolate            = NamedColor{"#d2691e"}
	Coral                = NamedColor{"#ff7f50"}
	CornflowerBlue       = NamedColor{"#6495ed"}
	Cornsilk             = NamedColor{"#fff8dc"}
	Crimson              = NamedColor{"#dc143c"}
	Cyan                 = NamedColor{"#00ffff"}
	DarkBlue             = NamedColor{"#00008b"}
	DarkCyan             = NamedColor{"#008b8b"}
	DarkGoldenRod        = NamedColor{"#b8860b"}
	DarkGray             = NamedColor{"#a9a9a9"}
	DarkGreen            = NamedColor{"#006400"}
	DarkKhaki            = NamedColor{"#bdb76b"}
	DarkMagenta          = NamedColor{"#8b008b"}
	DarkOliveGreen       = NamedColor{"#556b2f"}
	Darkorange           = NamedColor{"#ff8c00"}
	DarkOrchid           = NamedColor{"#9932cc"}
	DarkRed              = NamedColor{"#8b0000"}
	DarkSalmon           = NamedColor{"#e9967a"}
	DarkSeaGreen         = NamedColor{"#8fbc8f"}
	DarkSlateBlue        = NamedColor{"#483d8b"}
	DarkSlateGray        = NamedColor{"#2f4f4f"}
	DarkTurquoise        = NamedColor{"#00ced1"}
	DarkViolet           = NamedColor{"#9400d3"}
	DeepPink             = NamedColor{"#ff1493"}
	DeepSkyBlue          = NamedColor{"#00bfff"}
	DimGray              = NamedColor{"#696969"}
	DodgerBlue           = NamedColor{"#1e90ff"}
	FireBrick            = NamedColor{"#b22222"}
	FloralWhite          = NamedColor{"#fffaf0"}
	ForestGreen          = NamedColor{"#228b22"}
	Fuchsia              = NamedColor{"#ff00ff"}
	Gainsboro            = NamedColor{"#dcdcdc"}
	GhostWhite           = NamedColor{"#f8f8ff"}
	Gold                 = NamedColor{"#ffd700"}
	GoldenRod            = NamedColor{"#daa520"}
	Gray                 = NamedColor{"#808080"}
	Green                = NamedColor{"#008000"}
	GreenYellow          = NamedColor{"#adff2f"}
	HoneyDew             = NamedColor{"#f0fff0"}
	HotPink              = NamedColor{"#ff69b4"}
	IndianRed            = NamedColor{"#cd5c5c"}
	Indigo               = NamedColor{"#4b0082"}
	Ivory                = NamedColor{"#fffff0"}
	Khaki                = NamedColor{"#f0e68c"}
	Lavender             = NamedColor{"#e6e6fa"}
	LavenderBlush        = NamedColor{"#fff0f5"}
	LawnGreen            = NamedColor{"#7cfc00"}
	LemonChiffon         = NamedColor{"#fffacd"}
	LightBlue            = NamedColor{"#add8e6"}
	LightCoral           = NamedColor{"#f08080"}
	LightCyan            = NamedColor{"#e0ffff"}
	LightGoldenRodYellow = NamedColor{"#fafad2"}
	LightGreen           = NamedColor{"#90ee90"}
	LightGrey            = NamedColor{"#d3d3d3"}
	LightPink            = NamedColor{"#ffb6c1"}
	LightSalmon          = NamedColor{"#ffa07a"}
	LightSeaGreen        = NamedColor{"#20b2aa"}
	LightSkyBlue         = NamedColor{"#87cefa"}
	LightSlateGray       = NamedColor{"#778899"}
	LightSteelBlue       = NamedColor{"#b0c4de"}
	LightYellow          = NamedColor{"#ffffe0"}
	Lime                 = NamedColor{"#00ff00"}
	LimeGreen            = NamedColor{"#32cd32"}
	Linen                = NamedColor{"#faf0e6"}
	Magenta              = NamedColor{"#ff00ff"}
	Maroon               = NamedColor{"#800000"}
	MediumAquaMarine     = NamedColor{"#66cdaa"}
	MediumBlue           = NamedColor{"#0000cd"}
	MediumOrchid         = NamedColor{"#ba55d3"}
	MediumPurple         = NamedColor{"#9370d8"}
	MediumSeaGreen       = NamedColor{"#3cb371"}
	MediumSlateBlue      = NamedColor{"#7b68ee"}
	MediumSpringGreen    = NamedColor{"#00fa9a"}
	MediumTurquoise      = NamedColor{"#48d1cc"}
	MediumVioletRed      = NamedColor{"#c71585"}
	MidnightBlue         = NamedColor{"#191970"}
	MintCream            = NamedColor{"#f5fffa"}
	MistyRose            = NamedColor{"#ffe4e1"}
	Moccasin             = NamedColor{"#ffe4b5"}
	NavajoWhite          = NamedColor{"#ffdead"}
	Navy                 = NamedColor{"#000080"}
	OldLace              = NamedColor{"#fdf5e6"}
	Olive                = NamedColor{"#808000"}
	OliveDrab            = NamedColor{"#6b8e23"}
	Orange               = NamedColor{"#ffa500"}
	OrangeRed            = NamedColor{"#ff4500"}
	Orchid               = NamedColor{"#da70d6"}
	PaleGoldenRod        = NamedColor{"#eee8aa"}
	PaleGreen            = NamedColor{"#98fb98"}
	PaleTurquoise        = NamedColor{"#afeeee"}
	PaleVioletRed        = NamedColor{"#d87093"}
	PapayaWhip           = NamedColor{"#ffefd5"}
	PeachPuff            = NamedColor{"#ffdab9"}
	Peru                 = NamedColor{"#cd853f"}
	Pink                 = NamedColor{"#ffc0cb"}
	Plum                 = NamedColor{"#dda0dd"}
	PowderBlue           = NamedColor{"#b0e0e6"}
	Purple               = NamedColor{"#800080"}
	Red                  = NamedColor{"#ff0000"}
	RosyBrown            = NamedColor{"#bc8f8f"}
	RoyalBlue            = NamedColor{"#4169e1"}
	SaddleBrown          = NamedColor{"#8b4513"}
	Salmon               = NamedColor{"#fa8072"}
	SandyBrown           = NamedColor{"#f4a460"}
	SeaGreen             = NamedColor{"#2e8b57"}
	SeaShell             = NamedColor{"#fff5ee"}
	Sienna               = NamedColor{"#a0522d"}
	Silver               = NamedColor{"#c0c0c0"}
	SkyBlue              = NamedColor{"#87ceeb"}
	SlateBlue            = NamedColor{"#6a5acd"}
	SlateGray            = NamedColor{"#708090"}
	Snow                 = NamedColor{"#fffafa"}
	SpringGreen          = NamedColor{"#00ff7f"}
	SteelBlue            = NamedColor{"#4682b4"}
	Tan                  = NamedColor{"#d2b48c"}
	Teal                 = NamedColor{"#008080"}
	Thistle              = NamedColor{"#d8bfd8"}
	Tomato               = NamedColor{"#ff6347"}
	Turquoise            = NamedColor{"#40e0d0"}
	Violet               = NamedColor{"#ee82ee"}
	Wheat                = NamedColor{"#f5deb3"}
	White                = NamedColor{"#ffffff"}
	WhiteSmoke           = NamedColor{"#f5f5f5"}
	Yellow               = NamedColor{"#ffff00"}
	YellowGreen          = NamedColor{"#9acd32"}
)
View Source
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

func Parse

func Parse(s string) (Color, error)

Parse parses an unknown color type to it's appropriate type, or returns a ErrBadColor

type HEXColor

type HEXColor struct {
	// contains filtered or unexported fields
}

HEXColor represents a HEX color

func ParseHEX

func ParseHEX(s string) (*HEXColor, error)

ParseHEX validates an parses the provided string into a HEXColor object

func (*HEXColor) IsDark

func (c *HEXColor) IsDark() bool

IsDark returns whether the color is perceived to be a dark color

func (*HEXColor) IsLight

func (c *HEXColor) IsLight() bool

IsLight returns whether the color is perceived to be a light color

func (*HEXColor) String

func (c *HEXColor) String() string

String returns the string representation on the HEXColor

func (*HEXColor) ToHEX

func (c *HEXColor) ToHEX() *HEXColor

ToHEX converts the HEXColor to a HEXColor it's here to satisfy the Color interface

func (*HEXColor) ToRGB

func (c *HEXColor) ToRGB() *RGBColor

ToRGB converts the HEXColor to and RGBColor

func (*HEXColor) ToRGBA

func (c *HEXColor) ToRGBA() *RGBAColor

ToRGBA converts the HEXColor to an RGBAColor

type NamedColor

type NamedColor struct {
	Hex string
}

NamedColor hex value of named colors

func (NamedColor) Color

func (c NamedColor) Color() Color

Color return Color instance of named colors

func (NamedColor) String

func (c NamedColor) String() string

String return hex value of named colors

type RGBAColor

type RGBAColor struct {
	R uint8
	G uint8
	B uint8
	A float64
}

RGBAColor represents an RGBA color

func FromStdColor

func FromStdColor(c color.Color) *RGBAColor

func ParseRGBA

func ParseRGBA(s string) (*RGBAColor, error)

ParseRGBA validates an parses the provided string into an RGBAColor object supports both RGBA 255 and RGBA as percentages

func RGBA

func RGBA(r, g, b uint8, a float64) (*RGBAColor, error)

RGBA validates and returns a new RGBAColor object from the provided r, g, b, a values

func (*RGBAColor) IsDark

func (c *RGBAColor) IsDark() bool

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

func (c *RGBAColor) IsDarkAlpha(bg Color) bool

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

func (c *RGBAColor) IsLight() bool

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

func (c *RGBAColor) IsLightAlpha(bg Color) bool

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) String

func (c *RGBAColor) String() string

String returns the string representation on the RGBAColor

func (*RGBAColor) ToHEX

func (c *RGBAColor) ToHEX() *HEXColor

ToHEX converts the RGBAColor to a HEXColor

func (*RGBAColor) ToRGB

func (c *RGBAColor) ToRGB() *RGBColor

ToRGB converts the RGBAColor to an RGBColor

func (*RGBAColor) ToRGBA

func (c *RGBAColor) ToRGBA() *RGBAColor

ToRGBA converts the RGBAColor to an RGBAColor it's here to satisfy the Color interface

type RGBColor

type RGBColor struct {
	R uint8
	G uint8
	B uint8
}

RGBColor represents an RGB color

func ParseRGB

func ParseRGB(s string) (*RGBColor, error)

ParseRGB validates an parses the provided string into an RGBColor object supports both RGB 255 and RGB as percentages

func RGB

func RGB(r, g, b uint8) (*RGBColor, error)

RGB validates and returns a new RGBColor object from the provided r, g, b values

func (*RGBColor) IsDark

func (c *RGBColor) IsDark() bool

IsDark returns whether the color is perceived to be a dark color

func (*RGBColor) IsLight

func (c *RGBColor) IsLight() bool

IsLight returns whether the color is perceived to be a light color

func (*RGBColor) String

func (c *RGBColor) String() string

String returns the string representation on the RGBColor

func (*RGBColor) ToHEX

func (c *RGBColor) ToHEX() *HEXColor

ToHEX converts the RGBColor to a HEXColor

func (*RGBColor) ToRGB

func (c *RGBColor) ToRGB() *RGBColor

ToRGB converts the RGBColor to an RGBColor it's here to satisfy the Color interface

func (*RGBColor) ToRGBA

func (c *RGBColor) ToRGBA() *RGBAColor

ToRGBA converts the RGBColor to an RGBAColor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL