Documentation ¶
Overview ¶
Package colour provides types and functions to manipulate colors.
It is compatible with the standard library "image/color" package, but is designed to work well with GPUs.
The first difference is that it is based on float32 (instead of uint32), which can be used directly in shaders and graphics API such as OpenGL.
It also makes an explicit distinction between linear and sRGB color spaces, in addition to the distinction between alpha-premultiplied and alpha-postmultiplied.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Colour ¶
type Colour interface { // Linear returns the alpha-premultiplied red, green, blue and alpha // values for the color, in linear color space. Each value ranges within // [0, 1] and can be used directly by GPU shaders. // // An alpha-premultiplied color component c has been scaled by alpha (a), so // has valid values 0 <= c <= a. // // Note that additive blending can also be achieved when alpha is set to 0 // while the color components are non-null. Linear() (r, g, b, a float32) }
type RGB ¶
RGB represents a color in linear color space. Each value ranges within [0, 1], and can be used directly by GPU shaders.
type RGBA ¶
RGBA represents a color in alpha-premultiplied linear color space. Each value ranges within [0, 1], and can be used directly by GPU shaders.
An alpha-premultiplied color component c has been scaled by alpha (a), so has valid values 0 <= c <= a.
Note that additive blending can also be achieved when alpha is set to 0 while the color components are non-null.
type RGBnA ¶
RGBnA represents a color in *non* alpha-premultiplied linear color space. Each value ranges within [0, 1], and can be used directly by GPU shaders.
Note: prefer RGBA for use in shaders.
type SRGB ¶
SRGB represents a color in sRGB color space. Each value ranges within [0, 1], and can be used directly by GPU shaders.
type SRGB8 ¶
SRGB8 represents a 24-bit color in sRGB color space. There is 8 bits for each components.
type SRGBA ¶
SRGBA represents a color in alpha-premultiplied sRGB color space. Each value ranges within [0, 1].
An alpha-premultiplied color component c has been scaled by alpha (a), so has valid values 0 <= c <= a.
Note that additive blending can also be achieved when alpha is set to 0 while the color components are non-null.
type SRGBA8 ¶
SRGBA8 represents a 32-bit color in alpha-premultiplied sRGB color space. There is 8 bits for each components.
An alpha-premultiplied color component c has been scaled by alpha (a), so has valid values 0 <= c <= a.
Note that additive blending can also be achieved when alpha is set to 0 while the color components are non-null.
type SRGBnA ¶
SRGBnA represents a color in *non* alpha-premultiplied sRGB color space. Each value ranges within [0, 1].
An alpha-premultiplied color component c has been scaled by alpha (a), so has valid values 0 <= c <= a.
Note that additive blending can also be achieved when alpha is set to 0 while the color components are non-null.