Skip to content

jacquesamsel/color

Repository files navigation

color

Color formats implemented in golang (GO)

GoDoc Go report Coverage

Supported formats

RGBA

Red, green, blue, alpha

// Get RGBA values
r, g, b, a := color.RGBA()
// Parse RGBA
color2 := color.Color{255, 255, 255, 255}

HSLA

Hue, saturation, lightness, alpha

⚠️ the colors are internally represented as RGBA, so there may be a slight loss in precision if they are converted.

// Get HSLA values
h, s, l, a := color.HSLA()
// Parse HSLA float values (0.0-1.0)
color2 := color.ParseHSLA(1.0, 1.0, 1.0, 1.0)
// Parse HSLA whole numbers values (0-360), (0-100) * 3
color3 := color.ParseHSLAWhole(360, 100, 100, 100)

CMYKA

Cyan, magenta, yellow, black, alpha. Alpha is not often used in situations involving CMYK, but it is available

⚠️ the colors are internally represented as RGBA, so there may be a slight loss in precision if they are converted.

// Get CMYKA values
c, m, y, k, a := color.CMYKA()
// Parse CMYKA float values (0-1.0)
color2 := color.ParseCMYKA(1.0, 1.0, 1.0, 0.0)
// Parse CMYKA whole values (0-100)
color3 := color.ParseCMYKAWhole(100, 100, 100, 0)