Documentation ¶
Overview ¶
Package color implements a basic color library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Black = Gray16{0} White = Gray16{0xffff} Transparent = Alpha16{0} Opaque = Alpha16{0xffff} )
Standard colors.
Functions ¶
func RGBToYCbCr ¶
RGBToYCbCr converts an RGB triple to a Y'CbCr triple.
Types ¶
type Color ¶
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. RGBA() (r, g, b, a uint32) }
Color can convert itself to alpha-premultiplied 16-bits per channel RGBA. The conversion may be lossy.
type Model ¶
Model can convert any Color to one from its own color model. The conversion may be lossy.
var ( RGBAModel Model = ModelFunc(rgbaModel) RGBA64Model Model = ModelFunc(rgba64Model) NRGBAModel Model = ModelFunc(nrgbaModel) NRGBA64Model Model = ModelFunc(nrgba64Model) AlphaModel Model = ModelFunc(alphaModel) Alpha16Model Model = ModelFunc(alpha16Model) GrayModel Model = ModelFunc(grayModel) Gray16Model Model = ModelFunc(gray16Model) )
Models for the standard color types.
type NRGBA ¶
type NRGBA struct {
R, G, B, A uint8
}
NRGBA represents a non-alpha-premultiplied 32-bit color.
type NRGBA64 ¶
type NRGBA64 struct {
R, G, B, A uint16
}
NRGBA64 represents a non-alpha-premultiplied 64-bit color, having 16 bits for each of red, green, blue and alpha.
type Palette ¶
type Palette []Color
Palette is a palette of colors.
type RGBA ¶
type RGBA struct {
R, G, B, A uint8
}
RGBA represents a traditional 32-bit alpha-premultiplied color, having 8 bits for each of red, green, blue and alpha.
type RGBA64 ¶
type RGBA64 struct {
R, G, B, A uint16
}
RGBA64 represents a 64-bit alpha-premultiplied color, having 16 bits for each of red, green, blue and alpha.
type YCbCr ¶
type YCbCr struct {
Y, Cb, Cr uint8
}
YCbCr represents a fully opaque 24-bit Y'CbCr color, having 8 bits each for one luma and two chroma components.
JPEG, VP8, the MPEG family and other codecs use this color model. Such codecs often use the terms YUV and Y'CbCr interchangeably, but strictly speaking, 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, slightly different formulae for converting between the two. This package follows the JFIF specification at http://www.w3.org/Graphics/JPEG/jfif3.pdf.