blcolor

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 7 Imported by: 4

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

Constants

This section is empty.

Variables

View Source
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)
	Navajowhite          = RGBHex(255, 222, 173)
	Navy                 = RGBHex(0, 0, 128)
	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

type Color struct {
	R float64
	G float64
	B float64
	A float64
}

Color holds rgba values for a color.

func CMYK

func CMYK(c, m, y, k float64) Color

CMYK creates a color struct using cyan, yellow, magenta and black.

func Grey

func Grey(shade float64) Color

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

func GreyHex(shade int) Color

GreyHex creates a new Color struct with rgb all equal to the same value from 0 to 255 (a = 1.0).

func HSL

func HSL(h, s, l float64) Color

HSL creates a Color struct using hue (0.0 - 360.0), value (0.0 - 1.0) and lightness (0.0 - 1.0)

func HSLA

func HSLA(h, s, l, a float64) Color

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

func HSV(h float64, s float64, v float64) Color

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

func HSVA(h float64, s float64, v float64, a float64) Color

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 Lerp

func Lerp(colorA, colorB Color, t float64) Color

Lerp creates a new color by interpolating between two other colors

func Number

func Number(value int) Color

Number creates a new Color struct with a 24-bit int 0xRRGGBB (a = 1.0).

func NumberWithAlpha

func NumberWithAlpha(value int) Color

NumberWithAlpha creates a new Color struct with a 32-bit int 0xAARRGGBB.

func RGB

func RGB(r float64, g float64, b float64) Color

RGB creates a new Color struct with rgb values from 0.0 to 1.0 each (a = 1.0).

func RGBA

func RGBA(r float64, g float64, b float64, a float64) Color

RGBA creates a new Color struct with rgba values from 0.0 to 1.0 each.

func RGBAHex

func RGBAHex(r int, g int, b int, a int) Color

RGBAHex creates a Color struct with rgba values from 0 to 255 each.

func RGBHex

func RGBHex(r int, g int, b int) Color

RGBHex creates a Color struct with rgb values from 0 to 255 (a = 255).

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

func RandomGreyRange(min float64, max float64) Color

RandomGreyRange creates a Color struct with a random grey shade from min to max (a = 1.0).

func RandomRGB

func RandomRGB() Color

RandomRGB creates a color struct with random rgb values (a = 1.0).

func (Color) AddColor

func (c Color) AddColor(b Color) Color

AddColor adds a Color to this Color, returning a new Color.

func (Color) AddRGB

func (c Color) AddRGB(r, g, b float64) Color

AddRGB adds a value to each channel, returning a new Color.

func (Color) ColorDiff

func (c Color) ColorDiff(colorB Color) float64

ColorDiff returns the euclidian distance between two colors.

func (Color) ColorDiffPercept

func (c Color) ColorDiffPercept(colorB Color) float64

ColorDiffPercept returns the euclidian distance between two colors.

func (Color) Contrast

func (c Color) Contrast(c2 Color) float64

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

func (c Color) Equals(colorB Color) bool

Equals returns whether or not this color is equal to another channel.

func (Color) Invert

func (c Color) Invert() Color

Invert returns a color with the inverted RGB values of the original.

func (Color) Luminance

func (c Color) Luminance() float64

Luminance returnss the Luminance of a given color

func (Color) Quant

func (c Color) Quant(quant int) Color

Quant quantizes each color channel into a specified number of bands.

func (Color) Rotate

func (c Color) Rotate(degrees float64) Color

Rotate returns a color with the hue rotated by the specified amount.

func (Color) Scale

func (c Color) Scale(mult float64) Color

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

func (c Color) ToCMYK() (float64, float64, float64, float64)

ToCMYK returns the cyan, magenta, yellow and black of a color.

func (Color) ToGray

func (c Color) ToGray() Color

ToGray returns a new grayscale color from this color.

func (Color) ToHSL

func (c Color) ToHSL() (float64, float64, float64)

ToHSL returns the hue, saturation and lightness of a color. hue = 0-360, s = 0-1, l = 0-1

func (Color) ToHSV

func (c Color) ToHSV() (float64, float64, float64)

ToHSV returns the hue, saturation and value of a color. hue = 0-360, s = 0-1, v = 0-1

type Palette

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

Palette is a list of colors.

func NewPalette

func NewPalette() *Palette

NewPalette creates a new palette of the given size

func (*Palette) Add

func (p *Palette) Add(color Color)

Add adds a color to the palette.

func (*Palette) AddRGB

func (p *Palette) AddRGB(r, g, b float64)

AddRGB adds a new color defined by the rgb channels.

func (*Palette) AddRGBA

func (p *Palette) AddRGBA(r, g, b, a float64)

AddRGBA adds a new color defined by the rgb channels.

func (*Palette) Get

func (p *Palette) Get(index int) Color

Get returns the color at the given index, if available.

func (*Palette) GetRandom

func (p *Palette) GetRandom() Color

GetRandom returns a random color from the palette.

func (*Palette) Len

func (p *Palette) Len() int

Len returns the size of the palette (used for sorting).

func (*Palette) Less

func (p *Palette) Less(i, j int) bool

Less returns if one color has lower luminance another (used for sorting).

func (*Palette) Reverse

func (p *Palette) Reverse()

Reverse reverses the order of the colors in the palette.

func (*Palette) Size

func (p *Palette) Size() int

Size returns the number of colors in this palette.

func (*Palette) Sort

func (p *Palette) Sort()

Sort sorts the palette based on luminance

func (*Palette) SortByHue

func (p *Palette) SortByHue(offset float64)

SortByHue sorts the palette colors based on their hue.

func (*Palette) Swap

func (p *Palette) Swap(i, j int)

Swap swaps two colors in the palette (used for sorting).

Jump to

Keyboard shortcuts

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