Documentation
¶
Overview ¶
Package blcolor contains color creation and manipulation tools.
Package blcolor contains color creation and manipulation tools.
Package blcolor contains color creation and manipulation tools.
Package blcolor contains color creation and manipulation tools.
Index ¶
- Variables
- type Color
- func CMYK(c, m, y, k float64) Color
- func FromCSSString(str string) Color
- func Grey(shade float64) Color
- func GreyHex(shade int) Color
- func HSL(h, s, l float64) Color
- func HSLA(h, s, l, a float64) Color
- func HSV(h float64, s float64, v float64) Color
- func HSVA(h float64, s float64, v float64, a float64) Color
- func Lerp(colorA, colorB Color, t float64) Color
- func Number(value int) Color
- func NumberWithAlpha(value int) Color
- func RGB(r float64, g float64, b float64) Color
- func RGBA(r float64, g float64, b float64, a float64) Color
- func RGBAHex(r int, g int, b int, a int) Color
- func RGBHex(r int, g int, b int) Color
- func RandomGrey() Color
- func RandomGreyRange(minVal float64, maxVal float64) Color
- func RandomHue() Color
- func RandomRGB() Color
- func (c Color) AddColor(b Color) Color
- func (c Color) AddRGB(r, g, b float64) Color
- func (c Color) CSSString() string
- func (c Color) ColorDiff(colorB Color) float64
- func (c Color) ColorDiffPercept(colorB Color) float64
- func (c Color) Contrast(c2 Color) float64
- func (c Color) Equals(colorB Color) bool
- func (c Color) Invert() Color
- func (c Color) Luminance() float64
- func (c Color) Quant(quant int) Color
- func (c Color) Rotate(degrees float64) Color
- func (c Color) Scale(mult float64) Color
- func (c Color) ToCMYK() (float64, float64, float64, float64)
- func (c Color) ToGray() Color
- func (c Color) ToHSL() (float64, float64, float64)
- func (c Color) ToHSV() (float64, float64, float64)
- func (c Color) WithSat(sat float64) Color
- func (c Color) WithVal(val float64) Color
- type Palette
- func AchromaticPalette(n int) Palette
- func AchromaticRangePalette(minVal, maxVal float64, n int) Palette
- func AnalagousPalette(c Color) Palette
- func ComplementaryPalette(c Color) Palette
- func MonoPalette(hue float64, n int) Palette
- func NewPalette() Palette
- func PaletteFromCSS(colors ...string) Palette
- func PastelPalette(hue0, hue1 float64, n int) Palette
- func ReadPalette(path string) Palette
- func RectangularPalette(c Color) Palette
- func SequentialPalette(colA, colB Color, n int) Palette
- func SpectralPalette(hue0, hue1 float64, n int) Palette
- func SplitCompPalette(c Color) Palette
- func TetradicPalette(c Color) Palette
- func TriadicPalette(c Color) Palette
- func (p *Palette) Add(color Color)
- func (p *Palette) AddRGB(r, g, b float64)
- func (p *Palette) AddRGBA(r, g, b, a float64)
- func (p Palette) Equal(pal Palette) bool
- func (p *Palette) Filter(filter func(Color) bool)
- func (p *Palette) FilterDark(minValue float64)
- func (p Palette) Get(index int) Color
- func (p Palette) GetRandom() Color
- func (p Palette) GetWeightedRandom(weights ...float64) Color
- func (p Palette) Len() int
- func (p Palette) Less(i, j int) bool
- func (p Palette) RandomHueRotate(amt float64)
- func (p Palette) RandomizeSat(minSat, maxSat float64)
- func (p Palette) RandomizeValue(minVal, maxVal float64)
- func (p *Palette) Remove(index int)
- func (p Palette) Reverse()
- func (p Palette) Save(path string)
- func (p Palette) SetSaturation(sat float64)
- func (p Palette) SetValue(val float64)
- func (p Palette) Size() int
- func (p Palette) SortByHue(offset float64)
- func (p Palette) SortByVal()
- func (p Palette) Swap(i, j int)
- func (p *Palette) Unique()
Constants ¶
This section is empty.
Variables ¶
var ( Blueviolet = RGBHex(138, 43, 226) Brown = RGBHex(165, 42, 42) Aliceblue = RGBHex(240, 248, 255) Antiquewhite = RGBHex(250, 235, 215) Aqua = RGBHex(0, 255, 255) Aquamarine = RGBHex(127, 255, 212) Azure = RGBHex(240, 255, 255) Beige = RGBHex(245, 245, 220) Bisque = RGBHex(255, 228, 196) Black = RGBHex(0, 0, 0) Blanchedalmond = RGBHex(255, 235, 205) Blue = RGBHex(0, 0, 255) Burlywood = RGBHex(222, 184, 135) Cadetblue = RGBHex(95, 158, 160) Chartreuse = RGBHex(127, 255, 0) Chocolate = RGBHex(210, 105, 30) Coral = RGBHex(255, 127, 80) Cornflowerblue = RGBHex(100, 149, 237) Cornsilk = RGBHex(255, 248, 220) Crimson = RGBHex(220, 20, 60) Cyan = RGBHex(0, 255, 255) Darkblue = RGBHex(0, 0, 139) Darkcyan = RGBHex(0, 139, 139) Darkgoldenrod = RGBHex(184, 134, 11) Darkgray = RGBHex(169, 169, 169) Darkgreen = RGBHex(0, 100, 0) Darkgrey = RGBHex(169, 169, 169) Darkkhaki = RGBHex(189, 183, 107) Darkmagenta = RGBHex(139, 0, 139) Darkolivegreen = RGBHex(85, 107, 47) Darkorange = RGBHex(255, 140, 0) Darkorchid = RGBHex(153, 50, 204) Darkred = RGBHex(139, 0, 0) Darksalmon = RGBHex(233, 150, 122) Darkseagreen = RGBHex(143, 188, 143) Darkslateblue = RGBHex(72, 61, 139) Darkslategray = RGBHex(47, 79, 79) Darkslategrey = RGBHex(47, 79, 79) Darkturquoise = RGBHex(0, 206, 209) Darkviolet = RGBHex(148, 0, 211) Deeppink = RGBHex(255, 20, 147) Deepskyblue = RGBHex(0, 191, 255) Dimgray = RGBHex(105, 105, 105) Dimgrey = RGBHex(105, 105, 105) Dodgerblue = RGBHex(30, 144, 255) Firebrick = RGBHex(178, 34, 34) Floralwhite = RGBHex(255, 250, 240) Forestgreen = RGBHex(34, 139, 34) Fuchsia = RGBHex(255, 0, 255) Gainsboro = RGBHex(220, 220, 220) Ghostwhite = RGBHex(248, 248, 255) Gold = RGBHex(255, 215, 0) Goldenrod = RGBHex(218, 165, 32) Gray = RGBHex(128, 128, 128) Green = RGBHex(0, 128, 0) Greenyellow = RGBHex(173, 255, 47) Honeydew = RGBHex(240, 255, 240) Hotpink = RGBHex(255, 105, 180) Indianred = RGBHex(205, 92, 92) Indigo = RGBHex(75, 0, 130) Ivory = RGBHex(255, 255, 240) Khaki = RGBHex(240, 230, 140) Lavender = RGBHex(230, 230, 250) Lavenderblush = RGBHex(255, 240, 245) Lawngreen = RGBHex(124, 252, 0) Lemonchiffon = RGBHex(255, 250, 205) Lightblue = RGBHex(173, 216, 230) Lightcoral = RGBHex(240, 128, 128) Lightcyan = RGBHex(224, 255, 255) Lightgoldenrodyellow = RGBHex(250, 250, 210) Lightgray = RGBHex(211, 211, 211) Lightgreen = RGBHex(144, 238, 144) Lightgrey = RGBHex(211, 211, 211) Lightpink = RGBHex(255, 182, 193) Lightsalmon = RGBHex(255, 160, 122) Lightseagreen = RGBHex(32, 178, 170) Lightskyblue = RGBHex(135, 206, 250) Lightslategray = RGBHex(119, 136, 153) Lightslategrey = RGBHex(119, 136, 153) Lightsteelblue = RGBHex(176, 196, 222) Lightyellow = RGBHex(255, 255, 224) Lime = RGBHex(0, 255, 0) Limegreen = RGBHex(50, 205, 50) Linen = RGBHex(250, 240, 230) Magenta = RGBHex(255, 0, 255) Maroon = RGBHex(128, 0, 0) Mediumaquamarine = RGBHex(102, 205, 170) Mediumblue = RGBHex(0, 0, 205) Mediumorchid = RGBHex(186, 85, 211) Mediumpurple = RGBHex(147, 112, 219) Mediumseagreen = RGBHex(60, 179, 113) Mediumslateblue = RGBHex(123, 104, 238) Mediumspringgreen = RGBHex(0, 250, 154) Mediumturquoise = RGBHex(72, 209, 204) Mediumvioletred = RGBHex(199, 21, 133) Midnightblue = RGBHex(25, 25, 112) Mintcream = RGBHex(245, 255, 250) Mistyrose = RGBHex(255, 228, 225) Moccasin = RGBHex(255, 228, 181) Oldlace = RGBHex(253, 245, 230) Olive = RGBHex(128, 128, 0) Olivedrab = RGBHex(107, 142, 35) Orange = RGBHex(255, 165, 0) Orangered = RGBHex(255, 69, 0) Orchid = RGBHex(218, 112, 214) Palegoldenrod = RGBHex(238, 232, 170) Palegreen = RGBHex(152, 251, 152) Paleturquoise = RGBHex(175, 238, 238) Palevioletred = RGBHex(219, 112, 147) Papayawhip = RGBHex(255, 239, 213) Peachpuff = RGBHex(255, 218, 185) Peru = RGBHex(205, 133, 63) Pink = RGBHex(255, 192, 203) Plum = RGBHex(221, 160, 221) Powderblue = RGBHex(176, 224, 230) Purple = RGBHex(128, 0, 128) Rebeccapurple = RGBHex(102, 51, 153) Red = RGBHex(255, 0, 0) Rosybrown = RGBHex(188, 143, 143) Royalblue = RGBHex(65, 105, 225) Saddlebrown = RGBHex(139, 69, 19) Salmon = RGBHex(250, 128, 114) Sandybrown = RGBHex(244, 164, 96) Seagreen = RGBHex(46, 139, 87) Seashell = RGBHex(255, 245, 238) Sienna = RGBHex(160, 82, 45) Silver = RGBHex(192, 192, 192) Skyblue = RGBHex(135, 206, 235) Slateblue = RGBHex(106, 90, 205) Slategray = RGBHex(112, 128, 144) Slategrey = RGBHex(112, 128, 144) Snow = RGBHex(255, 250, 250) Springgreen = RGBHex(0, 255, 127) Steelblue = RGBHex(70, 130, 180) Tan = RGBHex(210, 180, 140) Teal = RGBHex(0, 128, 128) Thistle = RGBHex(216, 191, 216) Tomato = RGBHex(255, 99, 71) Turquoise = RGBHex(64, 224, 208) Violet = RGBHex(238, 130, 238) Wheat = RGBHex(245, 222, 179) White = RGBHex(255, 255, 255) Whitesmoke = RGBHex(245, 245, 245) Yellow = RGBHex(255, 255, 0) Yellowgreen = RGBHex(154, 205, 50) )
Named color values
Functions ¶
This section is empty.
Types ¶
type Color ¶
Color holds rgba values for a color.
func FromCSSString ¶ added in v0.8.5
FromCSSString creates a new Color struct from a string like #rrggbb.
func Grey ¶
Grey creates a new Color struct with rgb all equal to the same value from 0.0 to 1.0 (a = 1.0).
func GreyHex ¶
GreyHex creates a new Color struct with rgb all equal to the same value from 0 to 255 (a = 1.0).
func HSL ¶
HSL creates a Color struct using hue (0.0 - 360.0), value (0.0 - 1.0) and lightness (0.0 - 1.0)
func HSLA ¶
HSLA creates a Color struct using hue (0.0 - 360.0), value (0.0 - 1.0), lightness (0.0 - 1.0), and alpha (0.0 - 1.0)
func HSV ¶
HSV creates a Color struct using hue (0.0 - 360.0), value (0.0 - 1.0) and value (0.0 - 1.0) (a = 1.0).
func HSVA ¶
HSVA creates a Color struct using hue (0.0 - 360.0), value (0.0 - 1.0), value (0.0 - 1.0) and alpha (0.0 - 1.0).
func NumberWithAlpha ¶
NumberWithAlpha creates a new Color struct with a 32-bit int 0xAARRGGBB.
func RandomGrey ¶
func RandomGrey() Color
RandomGrey creates a Color struct with a random grey shade from 0.0 to 1.0 (a = 1.0).
func RandomGreyRange ¶
RandomGreyRange creates a Color struct with a random grey shade from min to max (a = 1.0).
func RandomHue ¶ added in v0.8.3
func RandomHue() Color
RandomHue creates a color with a random hue, full saturation and value.
func RandomRGB ¶
func RandomRGB() Color
RandomRGB creates a color struct with random rgb values (a = 1.0).
func (Color) ColorDiffPercept ¶
ColorDiffPercept returns the euclidian distance between two colors.
func (Color) Contrast ¶
Contrast returns the contrast between this color and another color. ref: https://www.w3.org/TR/2012/NOTE-WCAG20-TECHS-20120103/G17.html
func (Color) Equals ¶
Equals returns whether or not this color is equal to another channel. Converts each channel to int 0-255 because that's what's actually going to be displayed.
func (Color) Scale ¶
Scale scales the r, g, b channels by a percent. This will lighten or darken the color. Scale(1.05) will lighten the color by 5% of its current value. Scale(0.95) will darken the color by 5% of its current value. This is virtually the same as getting h, s, l and scaling the l But probably simpler in most cases.
func (Color) ToHSL ¶
ToHSL returns the hue, saturation and lightness of a color. hue = 0-360, s = 0-1, l = 0-1
func (Color) ToHSV ¶
ToHSV returns the hue, saturation and value of a color. hue = 0-360, s = 0-1, v = 0-1
type Palette ¶
type Palette []Color
Palette is a list of colors.
func AchromaticPalette ¶ added in v0.8.3
AchromaticPalette creates a grayscale palette of n values.
func AchromaticRangePalette ¶ added in v0.9.0
AchromaticRangePalette creates a grayscale palette of n values in the given range.
func AnalagousPalette ¶ added in v0.8.3
AnalagousPalette creates a palette of the given color and two neighbors.
func ComplementaryPalette ¶ added in v0.8.3
ComplementaryPalette creates a palette of the given color and its complement.
func MonoPalette ¶ added in v0.8.3
MonoPalette creates a monochrom palette based on the given hue with a range of sat and luminance.
func PaletteFromCSS ¶ added in v0.8.5
PaletteFromCSS creates a new palette with the given css colors in the #rrggbb format.
func PastelPalette ¶ added in v0.8.3
PastelPalette creates a light pastel palette interpolated between the two hues.
func ReadPalette ¶ added in v0.8.4
ReadPalette loads a serialized palette from disk.
func RectangularPalette ¶ added in v0.8.3
RectangularPalette creates a four color rectangular palette based on the given color.
func SequentialPalette ¶ added in v0.8.3
SequentialPalette creates a palette of n colors interpolated between the two given colors.
func SpectralPalette ¶ added in v0.8.3
SpectralPalette creates a palette of n colors interpolated between the two hues.
func SplitCompPalette ¶ added in v0.8.3
SplitCompPalette creates a palette with the given color and its two split complements.
func TetradicPalette ¶ added in v0.8.3
TetradicPalette creates a palette with four colors in a square formation based on the given color.
func TriadicPalette ¶ added in v0.8.3
TriadicPalette creates a tetradic paletted based on the given color.
func (Palette) Equal ¶ added in v0.8.5
Equal reports whether or not this palette is equal to another.
func (*Palette) Filter ¶ added in v0.8.9
Filter removes any colors in the filter which do not pass the given function. Reduces the size of the palette.
func (*Palette) FilterDark ¶ added in v0.8.9
FilterDark filters out any colors whose values are less than the given minimum value. Reduces the size of the palette.
func (Palette) GetWeightedRandom ¶ added in v0.9.0
GetWeightedRandom returns a random color from the palette.
func (Palette) RandomHueRotate ¶ added in v0.9.0
RandomHueRotate randomly rotates the hue of all colors in this palette.
func (Palette) RandomizeSat ¶ added in v0.9.0
RandomizeSat randomizes the saturation of all colors in this palette to be in the specified range.
func (Palette) RandomizeValue ¶ added in v0.9.0
RandomizeValue randomizes the value of all colors in this palette to be in the specified range.
func (Palette) Reverse ¶
func (p Palette) Reverse()
Reverse reverses the order of the colors in the palette.
func (Palette) SetSaturation ¶ added in v0.9.0
SetSaturation sets the saturation of all colors in this palette to the specified saturation.
func (Palette) SetValue ¶ added in v0.9.0
SetValue sets the value of all colors in this palette to the specified value.
func (Palette) SortByVal ¶ added in v0.8.9
func (p Palette) SortByVal()
Sort sorts the palette based on luminance