Overview

Package color implements a basic color library.

Index

ycbcr.go

Variables

Standard colors.

func

  1. func CMYKToRGB(c, m, y, k ) (uint8, , uint8)

CMYKToRGB converts a CMYK quadruple to an RGB triple.

func

  1. func RGBToCMYK(r, g, b ) (uint8, , uint8, )

RGBToCMYK converts an RGB triple to a CMYK quadruple.

func RGBToYCbCr

  1. func RGBToYCbCr(r, g, b uint8) (, uint8, )

RGBToYCbCr converts an RGB triple to a Y’CbCr triple.

  1. func YCbCrToRGB(y, cb, cr uint8) (, uint8, )

YCbCrToRGB converts a Y’CbCr triple to an RGB triple.

type Alpha

  1. type Alpha struct {
  2. A uint8
  3. }

Alpha represents an 8-bit alpha color.

func (Alpha)

  1. func (c ) RGBA() (r, g, b, a uint32)

type

  1. type Alpha16 struct {
  2. A
  3. }

Alpha16 represents a 16-bit alpha color.

func (Alpha16) RGBA

  1. func (c Alpha16) RGBA() (r, g, b, a )

type CMYK

  1. type CMYK struct {
  2. C, M, Y, K uint8
  3. }

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.

func (CMYK)

  1. func (c ) RGBA() (uint32, , uint32, )

type Color

  1. type Color interface {
  2. // RGBA returns the alpha-premultiplied red, green, blue and alpha values
  3. // for the color. Each value ranges within [0, 0xffff], but is represented
  4. // by a uint32 so that multiplying by a blend factor up to 0xffff will not
  5. // overflow.
  6. //
  7. // An alpha-premultiplied color component c has been scaled by alpha (a),
  8. // so has valid values 0 <= c <= a.
  9. RGBA() (r, g, b, a uint32)
  10. }

Color can convert itself to alpha-premultiplied 16-bits per channel RGBA. The
conversion may be lossy.

type

Gray represents an 8-bit grayscale color.

func (Gray)

  1. func (c ) RGBA() (r, g, b, a uint32)

type

  1. type Gray16 struct {
  2. Y
  3. }

Gray16 represents a 16-bit grayscale color.

  1. func (c Gray16) RGBA() (r, g, b, a )

  1. type Model interface {
  2. Convert(c Color)
  3. }

Model can convert any Color to one from its own color model. The conversion may
be lossy.

  1. var (
  2. RGBAModel Model = (rgbaModel)
  3. NRGBAModel Model = (nrgbaModel)
  4. NRGBA64Model Model = (nrgba64Model)
  5. AlphaModel Model = (alphaModel)
  6. Alpha16Model Model = (alpha16Model)
  7. GrayModel Model = (grayModel)
  8. Gray16Model Model = (gray16Model)
  9. )

Models for the standard color types.

  1. var CMYKModel Model = (cmykModel)

CMYKModel is the Model for CMYK colors.

  1. var NYCbCrAModel Model = (nYCbCrAModel)

NYCbCrAModel is the Model for non-alpha-premultiplied Y’CbCr-with-alpha colors.

  1. var YCbCrModel Model = (yCbCrModel)

YCbCrModel is the Model for Y’CbCr colors.

func ModelFunc

  1. func ModelFunc(f func(Color) ) Model

ModelFunc returns a Model that invokes f to implement the conversion.

type

  1. type NRGBA struct {
  2. R, G, B, A
  3. }

NRGBA represents a non-alpha-premultiplied 32-bit color.

func (NRGBA) RGBA

  1. func (c NRGBA) RGBA() (r, g, b, a )

type NRGBA64

NRGBA64 represents a non-alpha-premultiplied 64-bit color, having 16 bits for
each of red, green, blue and alpha.

func (NRGBA64) RGBA

  1. func (c NRGBA64) RGBA() (r, g, b, a )

type NYCbCrA

  1. type NYCbCrA struct {
  2. YCbCr
  3. A
  4. }

NYCbCrA represents a non-alpha-premultiplied Y’CbCr-with-alpha color, having 8
bits each for one luma, two chroma and one alpha component.

func (NYCbCrA) RGBA

  1. func (c NYCbCrA) RGBA() (, uint32, , uint32)

type

  1. type Palette []

Palette is a palette of colors.

  1. func (p Palette) Convert(c ) Color

Convert returns the palette color closest to c in Euclidean R,G,B space.

func (Palette)

  1. func (p ) Index(c Color)

Index returns the index of the palette color closest to c in Euclidean R,G,B,A
space.

type RGBA

  1. type RGBA struct {
  2. R, G, B, A uint8
  3. }

RGBA represents a traditional 32-bit alpha-premultiplied color, having 8 bits
for each of red, green, blue and alpha.

An alpha-premultiplied color component C has been scaled by alpha (A), so has
valid values 0 <= C <= A.

func (RGBA)

  1. func (c ) RGBA() (r, g, b, a uint32)

type

  1. type RGBA64 struct {
  2. R, G, B, A
  3. }

RGBA64 represents a 64-bit alpha-premultiplied color, having 16 bits for each of
red, green, blue and alpha.

An alpha-premultiplied color component C has been scaled by alpha (A), so has
valid values 0 <= C <= A.

func (RGBA64) RGBA

  1. func (c RGBA64) RGBA() (r, g, b, a )

  1. type YCbCr struct {
  2. Y, Cb, Cr uint8
  3. }

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 .

func (YCbCr) RGBA

Subdirectories