Documentation ¶
Index ¶
- type Image
- func (i Image) At(x, y int) color.Color
- func (i Image) AverageColor(line, startX, nrOfPixels int) LinearColor
- func (i Image) Bounds() image.Rectangle
- func (i Image) ColorModel() color.Model
- func (i Image) LinearAt(x, y int) LinearColor
- func (i Image) LinearSet(x, y int, lc LinearColor)
- func (i Image) Set(x, y int, c color.Color)
- func (i Image) Wrapped() image.Image
- type LinearColor
- type Pixel
- type TransferFunction
- type TransferFunctionAdobeRGB
- type TransferFunctionSRGB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image wraps an image to allow operations in linear color space.
func WrapImage ¶
func WrapImage(img image.Image, transferFunc TransferFunction) Image
WrapImage wraps an existing image with a transfer function.
func (Image) At ¶
At returns the color of the pixel at (x, y) in the image color space. At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid. At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.
func (Image) AverageColor ¶
func (i Image) AverageColor(line, startX, nrOfPixels int) LinearColor
AverageColor returns the average pixel color of a horizontal line of pixels.
func (Image) Bounds ¶
Bounds returns the domain for which At can return non-zero color. The bounds do not necessarily contain the point (0, 0).
func (Image) ColorModel ¶
ColorModel returns the Image's color model.
func (Image) LinearAt ¶
func (i Image) LinearAt(x, y int) LinearColor
LinearAt returns the color of the pixel at (x, y) in linear color. At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid. At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.
func (Image) LinearSet ¶
func (i Image) LinearSet(x, y int, lc LinearColor)
LinearSet changes a single pixel value to the color in linear color.
type LinearColor ¶
type LinearColor struct {
R, G, B float64
}
LinearColor represents a linear RGB color without alpha. Values are stored as floating point in the [0, 1] interval.
func Alpha ¶
func Alpha( colorA, colorB LinearColor, alpha float64, ) LinearColor
Alpha returns the alpha blend of the two colours.
func Interpolate ¶
func Interpolate( colorA, colorB LinearColor, weightA, weightB float64, ) LinearColor
Interpolate returns the linear interpolation of the two colours.
func (LinearColor) Div ¶
func (lc LinearColor) Div(factor float64) LinearColor
Div returns this colour / factor
func (LinearColor) Plus ¶
func (lc LinearColor) Plus(linOther LinearColor) LinearColor
Plus returns this colour + other
type Pixel ¶
type Pixel struct { X int Color LinearColor }
Pixel represents a colour at a certain X-coordinate.
type TransferFunction ¶
type TransferFunction interface { ToLinear(color color.Color) LinearColor FromLinear(color LinearColor) color.Color // Name returns the name of the transfer function. Name() string }
TransferFunction describes how to convert from a colour space to linear color and back.
type TransferFunctionAdobeRGB ¶
type TransferFunctionAdobeRGB struct { }
TransferFunctionAdobeRGB converts between linear and AdobeRGB.
func (TransferFunctionAdobeRGB) FromLinear ¶
func (tf TransferFunctionAdobeRGB) FromLinear(lc LinearColor) color.Color
FromLinear returns the linear color as AdobeRGB.
func (TransferFunctionAdobeRGB) Name ¶
func (tf TransferFunctionAdobeRGB) Name() string
Name returns "AdobeRGB".
func (TransferFunctionAdobeRGB) ToLinear ¶
func (tf TransferFunctionAdobeRGB) ToLinear(c color.Color) LinearColor
ToLinear converts the color from AdobeRGB to linear.
type TransferFunctionSRGB ¶
type TransferFunctionSRGB struct { }
TransferFunctionSRGB converts between linear and sRGB.
func (TransferFunctionSRGB) FromLinear ¶
func (tf TransferFunctionSRGB) FromLinear(lc LinearColor) color.Color
FromLinear returns the linear color as sRGB.
func (TransferFunctionSRGB) Name ¶
func (tf TransferFunctionSRGB) Name() string
Name returns "sRGB".
func (TransferFunctionSRGB) ToLinear ¶
func (tf TransferFunctionSRGB) ToLinear(c color.Color) LinearColor
ToLinear converts the color from sRGB to linear.