color
packagestandard libraryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package color implements a basic color library.
Index¶
- Variables
- func CMYKToRGB(c, m, y, k uint8) (uint8, uint8, uint8)
- func RGBToCMYK(r, g, b uint8) (uint8, uint8, uint8, uint8)
- func RGBToYCbCr(r, g, b uint8) (uint8, uint8, uint8)
- func YCbCrToRGB(y, cb, cr uint8) (uint8, uint8, uint8)
- type Alpha
- type Alpha16
- type CMYK
- type Color
- type Gray
- type Gray16
- type Model
- type NRGBA
- type NRGBA64
- type NYCbCrA
- type Palette
- type RGBA
- type RGBA64
- type YCbCr
Constants¶
This section is empty.
Variables¶
var (Black =Gray16{0}White =Gray16{0xffff}Transparent =Alpha16{0}Opaque =Alpha16{0xffff})
Standard colors.
Functions¶
funcRGBToYCbCr¶
RGBToYCbCr converts an RGB triple to a Y'CbCr triple.
Types¶
typeCMYK¶added ingo1.5
type CMYK struct {C, M, Y, Kuint8}CMYK represents a fully opaque CMYK color, having 8 bits for each of cyan,magenta, yellow and black.
It is not associated with any particular color profile.
typeColor¶
type Color interface {// RGBA returns the alpha-premultiplied red, green, blue and alpha values// for the color. Each value ranges within [0, 0xffff], but is represented// by a uint32 so that multiplying by a blend factor up to 0xffff will not// overflow.//// An alpha-premultiplied color component c has been scaled by alpha (a),// so has valid values 0 <= c <= a.RGBA() (r, g, b, auint32)}Color can convert itself to alpha-premultiplied 16-bits per channel RGBA.The conversion may be lossy.
typeModel¶
Model can convert anyColor to one from its own color model. The conversionmay be lossy.
var (RGBAModelModel =ModelFunc(rgbaModel)RGBA64ModelModel =ModelFunc(rgba64Model)NRGBAModelModel =ModelFunc(nrgbaModel)NRGBA64ModelModel =ModelFunc(nrgba64Model)AlphaModelModel =ModelFunc(alphaModel)Alpha16ModelModel =ModelFunc(alpha16Model)GrayModelModel =ModelFunc(grayModel)Gray16ModelModel =ModelFunc(gray16Model))
Models for the standard color types.
NYCbCrAModel is theModel for non-alpha-premultiplied Y'CbCr-with-alphacolors.
typeNRGBA¶
type NRGBA struct {R, G, B, Auint8}NRGBA represents a non-alpha-premultiplied 32-bit color.
typeNRGBA64¶
type NRGBA64 struct {R, G, B, Auint16}NRGBA64 represents a non-alpha-premultiplied 64-bit color,having 16 bits for each of red, green, blue and alpha.
typeNYCbCrA¶added ingo1.6
NYCbCrA represents a non-alpha-premultiplied Y'CbCr-with-alpha color, having8 bits each for one luma, two chroma and one alpha component.
typePalette¶
type Palette []Color
Palette is a palette of colors.
typeRGBA¶
type RGBA struct {R, G, B, Auint8}RGBA represents a traditional 32-bit alpha-premultiplied color, having 8bits for each of red, green, blue and alpha.
An alpha-premultiplied color component C has been scaled by alpha (A), sohas valid values 0 <= C <= A.
typeRGBA64¶
type RGBA64 struct {R, G, B, Auint16}RGBA64 represents a 64-bit alpha-premultiplied color, having 16 bits foreach of red, green, blue and alpha.
An alpha-premultiplied color component C has been scaled by alpha (A), sohas valid values 0 <= C <= A.
typeYCbCr¶
type YCbCr struct {Y, Cb, Cruint8}YCbCr represents a fully opaque 24-bit Y'CbCr color, having 8 bits each forone luma and two chroma components.
JPEG, VP8, the MPEG family and other codecs use this color model. Suchcodecs often use the terms YUV and Y'CbCr interchangeably, but strictlyspeaking, the term YUV applies only to analog video signals, and Y' (luma)is Y (luminance) after applying gamma correction.
Conversion between RGB and Y'CbCr is lossy and there are multiple, slightlydifferent formulae for converting between the two. This package followsthe JFIF specification athttps://www.w3.org/Graphics/JPEG/jfif3.pdf.