color

Constants & Variables

Alpha16Model var #

Models for the standard color types.

var Alpha16Model Model = *ast.CallExpr

AlphaModel var #

Models for the standard color types.

var AlphaModel Model = *ast.CallExpr

Black var #

Standard colors.

var Black = Gray16{...}

CMYKModel var #

CMYKModel is the [Model] for CMYK colors.

var CMYKModel Model = *ast.CallExpr

Gray16Model var #

Models for the standard color types.

var Gray16Model Model = *ast.CallExpr

GrayModel var #

Models for the standard color types.

var GrayModel Model = *ast.CallExpr

NRGBA64Model var #

Models for the standard color types.

var NRGBA64Model Model = *ast.CallExpr

NRGBAModel var #

Models for the standard color types.

var NRGBAModel Model = *ast.CallExpr

NYCbCrAModel var #

NYCbCrAModel is the [Model] for non-alpha-premultiplied Y'CbCr-with-alpha colors.

var NYCbCrAModel Model = *ast.CallExpr

Opaque var #

Standard colors.

var Opaque = Alpha16{...}

RGBA64Model var #

Models for the standard color types.

var RGBA64Model Model = *ast.CallExpr

RGBAModel var #

Models for the standard color types.

var RGBAModel Model = *ast.CallExpr

Transparent var #

Standard colors.

var Transparent = Alpha16{...}

White var #

Standard colors.

var White = Gray16{...}

YCbCrModel var #

YCbCrModel is the [Model] for Y'CbCr colors.

var YCbCrModel Model = *ast.CallExpr

Type Aliases

Palette type #

Palette is a palette of colors.

type Palette []Color

Interfaces

Color interface #

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

type Color interface {
RGBA() (r uint32, g uint32, b uint32, a uint32)
}

Model interface #

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

type Model interface {
Convert(c Color) Color
}

Structs

Alpha struct #

Alpha represents an 8-bit alpha color.

type Alpha struct {
A uint8
}

Alpha16 struct #

Alpha16 represents a 16-bit alpha color.

type Alpha16 struct {
A uint16
}

CMYK struct #

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.

type CMYK struct {
C uint8
M uint8
Y uint8
K uint8
}

Gray struct #

Gray represents an 8-bit grayscale color.

type Gray struct {
Y uint8
}

Gray16 struct #

Gray16 represents a 16-bit grayscale color.

type Gray16 struct {
Y uint16
}

NRGBA struct #

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

type NRGBA struct {
R uint8
G uint8
B uint8
A uint8
}

NRGBA64 struct #

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

type NRGBA64 struct {
R uint16
G uint16
B uint16
A uint16
}

NYCbCrA struct #

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

type NYCbCrA struct {
YCbCr
A uint8
}

RGBA struct #

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.

type RGBA struct {
R uint8
G uint8
B uint8
A uint8
}

RGBA64 struct #

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.

type RGBA64 struct {
R uint16
G uint16
B uint16
A uint16
}

YCbCr struct #

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 https://www.w3.org/Graphics/JPEG/jfif3.pdf.

type YCbCr struct {
Y uint8
Cb uint8
Cr uint8
}

modelFunc struct #

type modelFunc struct {
f func(Color) Color
}

Functions

CMYKToRGB function #

CMYKToRGB converts a [CMYK] quadruple to an RGB triple.

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

Convert method #

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

func (p Palette) Convert(c Color) Color

Convert method #

func (m *modelFunc) Convert(c Color) Color

Index method #

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

func (p Palette) Index(c Color) int

ModelFunc function #

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

func ModelFunc(f func(Color) Color) Model

RGBA method #

func (c Alpha) RGBA() (r uint32, g uint32, b uint32, a uint32)

RGBA method #

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

RGBA method #

func (c YCbCr) RGBA() (uint32, uint32, uint32, uint32)

RGBA method #

func (c CMYK) RGBA() (uint32, uint32, uint32, uint32)

RGBA method #

func (c Gray16) RGBA() (r uint32, g uint32, b uint32, a uint32)

RGBA method #

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

RGBA method #

func (c RGBA64) RGBA() (r uint32, g uint32, b uint32, a uint32)

RGBA method #

func (c NRGBA) RGBA() (r uint32, g uint32, b uint32, a uint32)

RGBA method #

func (c NRGBA64) RGBA() (r uint32, g uint32, b uint32, a uint32)

RGBA method #

func (c Gray) RGBA() (r uint32, g uint32, b uint32, a uint32)

RGBA method #

func (c Alpha16) RGBA() (r uint32, g uint32, b uint32, a uint32)

RGBToCMYK function #

RGBToCMYK converts an RGB triple to a CMYK quadruple.

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

RGBToYCbCr function #

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

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

YCbCrToRGB function #

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

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

alpha16Model function #

func alpha16Model(c Color) Color

alphaModel function #

func alphaModel(c Color) Color

cmykModel function #

func cmykModel(c Color) Color

gray16Model function #

func gray16Model(c Color) Color

grayModel function #

func grayModel(c Color) Color

nYCbCrAModel function #

func nYCbCrAModel(c Color) Color

nrgba64Model function #

func nrgba64Model(c Color) Color

nrgbaModel function #

func nrgbaModel(c Color) Color

rgba64Model function #

func rgba64Model(c Color) Color

rgbaModel function #

func rgbaModel(c Color) Color

sqDiff function #

sqDiff returns the squared-difference of x and y, shifted by 2 so that adding four of those won't overflow a uint32. x and y are both assumed to be in the range [0, 0xffff].

func sqDiff(x uint32, y uint32) uint32

yCbCrModel function #

func yCbCrModel(c Color) Color

Generated with Arrow