lincolor

package
v0.0.0-...-a1867f6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

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

func (i Image) At(x, y int) color.Color

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

func (i Image) Bounds() image.Rectangle

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

func (i Image) ColorModel() color.Model

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.

func (Image) Set

func (i Image) Set(x, y int, c color.Color)

Set changes a single pixel value to the color in image color space.

func (Image) Wrapped

func (i Image) Wrapped() image.Image

Wrapped returns the wrapped image.

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

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

ToLinear converts the color from sRGB to linear.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL