Module: stdgo.image.color
Overview
Package color implements a basic color library.
Index
-
function _alpha16Model(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _alphaModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _cmykModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _delta(_x:stdgo.GoUInt8, _y:stdgo.GoUInt8):stdgo.GoUInt8
-
function _eq(_c0:stdgo.image.color.Color, _c1:stdgo.image.color.Color):stdgo.Error
-
function _gray16Model(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _grayModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _nYCbCrAModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _nrgba64Model(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _nrgbaModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _rgba64Model(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _rgbaModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function _sqDiff(_x:stdgo.GoUInt32, _y:stdgo.GoUInt32):stdgo.GoUInt32
-
function _yCbCrModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
-
function benchmarkNYCbCrAToRGBA(_b:stdgo.Ref<stdgo.testing.B>):Void
-
function benchmarkRGBToYCbCr(_b:stdgo.Ref<stdgo.testing.B>):Void
-
function benchmarkYCbCrToRGB(_b:stdgo.Ref<stdgo.testing.B>):Void
-
function benchmarkYCbCrToRGBA(_b:stdgo.Ref<stdgo.testing.B>):Void
-
function testCMYKRoundtrip(_t:stdgo.Ref<stdgo.testing.T_>):Void
-
function testCMYKToRGBConsistency(_t:stdgo.Ref<stdgo.testing.T_>):Void
-
function testNYCbCrAAlpha(_t:stdgo.Ref<stdgo.testing.T_>):Void
-
function testNYCbCrAYCbCr(_t:stdgo.Ref<stdgo.testing.T_>):Void
-
function testYCbCrRoundtrip(_t:stdgo.Ref<stdgo.testing.T_>):Void
-
function testYCbCrToRGBConsistency(_t:stdgo.Ref<stdgo.testing.T_>):Void
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function new(?c:stdgo.GoUInt8, ?m:stdgo.GoUInt8, ?y:stdgo.GoUInt8, ?k:stdgo.GoUInt8):Void
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function new(?r:stdgo.GoUInt8, ?g:stdgo.GoUInt8, ?b:stdgo.GoUInt8, ?a:stdgo.GoUInt8):Void
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function new(?r:stdgo.GoUInt16, ?g:stdgo.GoUInt16, ?b:stdgo.GoUInt16, ?a:stdgo.GoUInt16):Void
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function new(?ycbCr:stdgo.image.color.YCbCr, ?a:stdgo.GoUInt8):Void
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function new(?r:stdgo.GoUInt8, ?g:stdgo.GoUInt8, ?b:stdgo.GoUInt8, ?a:stdgo.GoUInt8):Void
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function new(?r:stdgo.GoUInt16, ?g:stdgo.GoUInt16, ?b:stdgo.GoUInt16, ?a:stdgo.GoUInt16):Void
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
-
function new(?y:stdgo.GoUInt8, ?cb:stdgo.GoUInt8, ?cr:stdgo.GoUInt8):Void
-
function rgba():{ _3:stdgo.GoUInt32; _2:stdgo.GoUInt32; _1:stdgo.GoUInt32; _0:stdgo.GoUInt32;}
Variables
import stdgo.image.color.Color
var _sink32:stdgo.GoUInt32
var _sink8:stdgo.GoUInt8
var alpha16Model:stdgo.image.color.Model
Models for the standard color types.
var alphaModel:stdgo.image.color.Model
Models for the standard color types.
var black:stdgo.image.color.Gray16
Standard colors.
var cmykmodel:stdgo.image.color.Model
CMYKModel is the Model for CMYK colors.
var gray16Model:stdgo.image.color.Model
Models for the standard color types.
var grayModel:stdgo.image.color.Model
Models for the standard color types.
var nrgba64model:stdgo.image.color.Model
Models for the standard color types.
var nrgbamodel:stdgo.image.color.Model
Models for the standard color types.
var nycbCrAModel:stdgo.image.color.Model
NYCbCrAModel is the Model for non-alpha-premultiplied Y'CbCr-with-alpha colors.
var opaque:stdgo.image.color.Alpha16
Standard colors.
var rgba64model:stdgo.image.color.Model
Models for the standard color types.
var rgbamodel:stdgo.image.color.Model
Models for the standard color types.
var transparent:stdgo.image.color.Alpha16
Standard colors.
var white:stdgo.image.color.Gray16
Standard colors.
var ycbCrModel:stdgo.image.color.Model
YCbCrModel is the Model for Y'CbCr colors.
Functions
import stdgo.image.color.Color
function _alpha16Model
function _alpha16Model(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _alphaModel
function _alphaModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _cmykModel
function _cmykModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _delta
function _delta(_x:stdgo.GoUInt8, _y:stdgo.GoUInt8):stdgo.GoUInt8
function _eq
function _eq(_c0:stdgo.image.color.Color, _c1:stdgo.image.color.Color):stdgo.Error
function _gray16Model
function _gray16Model(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _grayModel
function _grayModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _nYCbCrAModel
function _nYCbCrAModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _nrgba64Model
function _nrgba64Model(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _nrgbaModel
function _nrgbaModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _rgba64Model
function _rgba64Model(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _rgbaModel
function _rgbaModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
function _sqDiff
function _sqDiff(_x:stdgo.GoUInt32, _y:stdgo.GoUInt32):stdgo.GoUInt32
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].
function _yCbCrModel
function _yCbCrModel(_c:stdgo.image.color.Color):stdgo.image.color.Color
function benchmarkNYCbCrAToRGBA
function benchmarkNYCbCrAToRGBA(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkRGBToYCbCr
function benchmarkRGBToYCbCr(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkYCbCrToRGB
function benchmarkYCbCrToRGB(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkYCbCrToRGBA
function benchmarkYCbCrToRGBA(_b:stdgo.Ref<stdgo.testing.B>):Void
function cmyktoRGB
function cmyktoRGB(_c:stdgo.GoUInt8, _m:stdgo.GoUInt8, _y:stdgo.GoUInt8, _k:stdgo.GoUInt8):{
_2:stdgo.GoUInt8;
_1:stdgo.GoUInt8;
_0:stdgo.GoUInt8;
}
CMYKToRGB converts a CMYK quadruple to an RGB triple.
function modelFunc
function modelFunc(_f:()):stdgo.image.color.Model
ModelFunc returns a Model that invokes f to implement the conversion.
function rgbtoCMYK
function rgbtoCMYK(_r:stdgo.GoUInt8, _g:stdgo.GoUInt8, _b:stdgo.GoUInt8):{
_3:stdgo.GoUInt8;
_2:stdgo.GoUInt8;
_1:stdgo.GoUInt8;
_0:stdgo.GoUInt8;
}
RGBToCMYK converts an RGB triple to a CMYK quadruple.
function rgbtoYCbCr
function rgbtoYCbCr(_r:stdgo.GoUInt8, _g:stdgo.GoUInt8, _b:stdgo.GoUInt8):{
_2:stdgo.GoUInt8;
_1:stdgo.GoUInt8;
_0:stdgo.GoUInt8;
}
RGBToYCbCr converts an RGB triple to a Y'CbCr triple.
function testCMYKGray
function testCMYKGray(_t:stdgo.Ref<stdgo.testing.T_>):Void
TestCMYKGray tests that CMYK colors are a superset of Gray colors.
function testCMYKRoundtrip
function testCMYKRoundtrip(_t:stdgo.Ref<stdgo.testing.T_>):Void
TestCMYKRoundtrip tests that a subset of RGB space can be converted to CMYK and back to within 1/256 tolerance.
function testCMYKToRGBConsistency
function testCMYKToRGBConsistency(_t:stdgo.Ref<stdgo.testing.T_>):Void
TestCMYKToRGBConsistency tests that calling the RGBA method (16 bit color) then truncating to 8 bits is equivalent to calling the CMYKToRGB function (8 bit color).
function testNYCbCrAAlpha
function testNYCbCrAAlpha(_t:stdgo.Ref<stdgo.testing.T_>):Void
TestNYCbCrAAlpha tests that NYCbCrA colors are a superset of Alpha colors.
function testNYCbCrAYCbCr
function testNYCbCrAYCbCr(_t:stdgo.Ref<stdgo.testing.T_>):Void
TestNYCbCrAYCbCr tests that NYCbCrA colors are a superset of YCbCr colors.
function testPalette
function testPalette(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testSqDiff
function testSqDiff(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testYCbCrGray
function testYCbCrGray(_t:stdgo.Ref<stdgo.testing.T_>):Void
TestYCbCrGray tests that YCbCr colors are a superset of Gray colors.
function testYCbCrRoundtrip
function testYCbCrRoundtrip(_t:stdgo.Ref<stdgo.testing.T_>):Void
TestYCbCrRoundtrip tests that a subset of RGB space can be converted to YCbCr and back to within 2/256 tolerance.
function testYCbCrToRGBConsistency
function testYCbCrToRGBConsistency(_t:stdgo.Ref<stdgo.testing.T_>):Void
TestYCbCrToRGBConsistency tests that calling the RGBA method (16 bit color) then truncating to 8 bits is equivalent to calling the YCbCrToRGB function (8 bit color).
function ycbCrToRGB
function ycbCrToRGB(_y:stdgo.GoUInt8, _cb:stdgo.GoUInt8, _cr:stdgo.GoUInt8):{
_2:stdgo.GoUInt8;
_1:stdgo.GoUInt8;
_0:stdgo.GoUInt8;
}
YCbCrToRGB converts a Y'CbCr triple to an RGB triple.
Classes
import stdgo.image.color.*
class Alpha
Alpha represents an 8-bit alpha color.
var a:stdgo.GoUInt8
Alpha function new
function new(?a:stdgo.GoUInt8):Void
Alpha function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class Alpha16
Alpha16 represents a 16-bit alpha color.
var a:stdgo.GoUInt16
Alpha16 function new
function new(?a:stdgo.GoUInt16):Void
Alpha16 function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class CMYK
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.
var c:stdgo.GoUInt8
var k:stdgo.GoUInt8
var m:stdgo.GoUInt8
var y:stdgo.GoUInt8
CMYK function new
function new(?c:stdgo.GoUInt8, ?m:stdgo.GoUInt8, ?y:stdgo.GoUInt8, ?k:stdgo.GoUInt8):Void
CMYK function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class Gray
Gray represents an 8-bit grayscale color.
var y:stdgo.GoUInt8
Gray function new
function new(?y:stdgo.GoUInt8):Void
Gray function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class Gray16
Gray16 represents a 16-bit grayscale color.
var y:stdgo.GoUInt16
Gray16 function new
function new(?y:stdgo.GoUInt16):Void
Gray16 function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class NRGBA
NRGBA represents a non-alpha-premultiplied 32-bit color.
var a:stdgo.GoUInt8
var b:stdgo.GoUInt8
var g:stdgo.GoUInt8
var r:stdgo.GoUInt8
NRGBA function new
function new(?r:stdgo.GoUInt8, ?g:stdgo.GoUInt8, ?b:stdgo.GoUInt8, ?a:stdgo.GoUInt8):Void
NRGBA function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class NRGBA64
NRGBA64 represents a non-alpha-premultiplied 64-bit color, having 16 bits for each of red, green, blue and alpha.
var a:stdgo.GoUInt16
var b:stdgo.GoUInt16
var g:stdgo.GoUInt16
var r:stdgo.GoUInt16
NRGBA64 function new
function new(?r:stdgo.GoUInt16, ?g:stdgo.GoUInt16, ?b:stdgo.GoUInt16, ?a:stdgo.GoUInt16):Void
NRGBA64 function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class NYCbCrA
NYCbCrA represents a non-alpha-premultiplied Y'CbCr-with-alpha color, having 8 bits each for one luma, two chroma and one alpha component.
var a:stdgo.GoUInt8
var ycbCr:stdgo.image.color.YCbCr
NYCbCrA function new
function new(?ycbCr:stdgo.image.color.YCbCr, ?a:stdgo.GoUInt8):Void
NYCbCrA function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class RGBA
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.
var a:stdgo.GoUInt8
var b:stdgo.GoUInt8
var g:stdgo.GoUInt8
var r:stdgo.GoUInt8
RGBA function new
function new(?r:stdgo.GoUInt8, ?g:stdgo.GoUInt8, ?b:stdgo.GoUInt8, ?a:stdgo.GoUInt8):Void
RGBA function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class RGBA64
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.
var a:stdgo.GoUInt16
var b:stdgo.GoUInt16
var g:stdgo.GoUInt16
var r:stdgo.GoUInt16
RGBA64 function new
function new(?r:stdgo.GoUInt16, ?g:stdgo.GoUInt16, ?b:stdgo.GoUInt16, ?a:stdgo.GoUInt16):Void
RGBA64 function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
class YCbCr
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.
var cb:stdgo.GoUInt8
var cr:stdgo.GoUInt8
var y:stdgo.GoUInt8
YCbCr function new
function new(?y:stdgo.GoUInt8, ?cb:stdgo.GoUInt8, ?cr:stdgo.GoUInt8):Void
YCbCr function rgba
function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}
Typedefs
import stdgo.image.color.*
typedef Color
typedef Color = {
public function rgba():{
_3:stdgo.GoUInt32;
_2:stdgo.GoUInt32;
_1:stdgo.GoUInt32;
_0:stdgo.GoUInt32;
}; // 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.
};
Color can convert itself to alpha-premultiplied 16-bits per channel RGBA. The conversion may be lossy.
typedef Model
typedef Model = {
public function convert(_c:stdgo.image.color.Color):stdgo.image.color.Color;
};
Model can convert any Color to one from its own color model. The conversion may be lossy.
typedef Palette
typedef Palette = stdgo.Slice<stdgo.image.color.Color>;
Palette is a palette of colors.