Documentation ¶
Overview ¶
Package color contains types and functions for color management.
A new color type and model for HSL along with functions:
Complement - return the opposite color on the color wheel Monochrome - create a monochrome palatte for a color Analogous - returns the analogous (adjacent) colors from the color wheel Triad - returns the other two colors in the color wheel triad Tetrad - returns the other three colors in the color wheel tetrad Warmer - moves a color towards red by 10% Cooler - moves a color towards cyan by 10% Tint - adds 10% of white to a color Shade - adds 10% of black to a color Boost - increases saturation by 10% Tone - adds 10% of gray to a color Compound - returns the analogous colors of the color's complement
An embedded list of popular color names and their colors, from here - https://github.com/meodai/color-names.
Index ¶
- Variables
- func ColorFile0() []byte
- func ColorFile1() []byte
- func ColorRGBALerp(t float64, start, end color.Color) color.RGBA
- func HuePalette(hoffs, s, l float64, n int) []color.Color
- func NamedRGBPalette() []color.Color
- func Random() color.RGBA
- func RandomFromPalette(palette []color.Color) color.Color
- type HSL
- func Analogous(col color.Color) []HSL
- func Boost(col color.Color) HSL
- func ColorHSLLerp(t float64, start, end color.Color) HSL
- func ColorHSLLerpS(t float64, start, end color.Color) HSL
- func Complement(col color.Color) HSL
- func Compound(col color.Color) []HSL
- func Cooler(col color.Color) HSL
- func HuePair(col color.Color, d float64) []HSL
- func LightPair(col color.Color, d float64) []HSL
- func Monochrome(col color.Color, n int) []HSL
- func NewHSL(col color.Color) HSL
- func RandomHue() HSL
- func SatPair(col color.Color, d float64) []HSL
- func Shade(col color.Color) HSL
- func Tetrad(col color.Color) []HSL
- func Tint(col color.Color) HSL
- func Tone(col color.Color) HSL
- func Triad(col color.Color) []HSL
- func Warmer(col color.Color) HSL
- type NamedRGB
Constants ¶
This section is empty.
Variables ¶
var ( Black = color.RGBA{0x00, 0x00, 0x00, 0xff} Red = color.RGBA{0xff, 0x00, 0x00, 0xff} Green = color.RGBA{0x00, 0xff, 0x00, 0xff} Blue = color.RGBA{0x00, 0x00, 0xff, 0xff} Yellow = color.RGBA{0xff, 0xff, 0x00, 0xff} Magenta = color.RGBA{0xff, 0x00, 0xff, 0xff} Cyan = color.RGBA{0x00, 0xff, 0xff, 0xff} White = color.RGBA{0xff, 0xff, 0xff, 0xff} DarkGray = color.RGBA{0x63, 0x66, 0x6a, 0xff} Gray = color.RGBA{0x7f, 0x7f, 0x7f, 0xff} LightGray = color.RGBA{0xd9, 0xd9, 0xd6, 0xff} Brown = color.RGBA{0xa4, 0x75, 0x51, 0xff} Orange = color.RGBA{0xff, 0xa5, 0x00, 0xff} Purple = color.RGBA{0x40, 0x00, 0x80, 0xff} GopherBlue = color.RGBA{0x9d, 0xe8, 0xfd, 0xff} GopherBrown = color.RGBA{0xf3, 0xe2, 0xc9, 0xff} GopherGray = color.RGBA{0xbd, 0xb9, 0xaf, 0xff} StandardPalette = []color.Color{ Black, Red, Orange, Brown, Yellow, Green, Blue, Cyan, Purple, Magenta, White, Gray, } )
Predefined colors.
var BestNamedRGBs []*NamedRGB
NamedRGBs is the slice of colors loaded from the color names file.
var CSSNamedRGBs []*NamedRGB
var HSLModel color.Model = color.ModelFunc(hslModel)
HSLModel standard HSL color type with all values in range [0,1]
Functions ¶
func ColorRGBALerp ¶
ColorRGBALerp calculates the color value at t [0,1] given a start and end color in RGB space.
func HuePalette ¶
HuePalette creates a palette n long of equally spaced hues starting from hoffs, using the supplied saturation and lightness.
func NamedRGBPalette ¶
NamedRGBPalette performs a concrete to interface conversion
Types ¶
type HSL ¶
type HSL struct {
H, S, L, A float64
}
HSL describes a color in Hue Saturation Lightness space. All values are in range [0,1].
func ColorHSLLerp ¶
ColorHSLLerp calculates the color value at t [0,1] given a start and end color in HSL space.
func ColorHSLLerpS ¶
ColorHSLLerpS calculates the color value at t [0,1] given a start and end color in HSL space. Differs from ColorHSLLerp in that the shortest path for hue is taken.
func HuePair ¶
HuePair returns a pair of colors d away on either side of the color. d is in range [0,1]
func LightPair ¶
LightPair returns a pair of colors d away on either side of the color. d is in range [0,1]
func Monochrome ¶
Monochrome returns the color's monochrome palette (excluding black and white). Note the palette may not contain the original color since the values are equally spaced over L.
func RandomHue ¶
func RandomHue() HSL
RandomHue returns an HSL color with a random hue, fully saturated and 50% lightness.
type NamedRGB ¶
NamedRGB contains the name of the color and its RGB color representation.
func ByCSSName ¶
ByCSSName returns the color given by the name. If there's no match, error will be set.
func RandomNamedRGB ¶
func RandomNamedRGB() *NamedRGB
RandomNamedRGB returns a random color from the list of named colors.