linear

package
v0.35.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Package linear provides support for working with linearised colour.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalisedTo16Bit added in v0.30.0

func NormalisedTo16Bit(v float32) uint16

NormalisedTo16Bit clamps and scales a normalised value to the range 0-65535.

func NormalisedTo8Bit added in v0.30.0

func NormalisedTo8Bit(v float32) uint8

NormalisedTo8Bit clamps and scales a normalised value to the range 0-255.

func NormalisedTo9Bit added in v0.30.0

func NormalisedTo9Bit(v float32) uint16

NormalisedTo9Bit clamps and scales a normalised value to the range 0-511.

func TransformImageColor added in v0.28.0

func TransformImageColor(dst draw.Image, src image.Image, parallelism int, transformColor func(color.Color) color.RGBA64)

TransformImageColor applies a colour transformation function to all pixels of src, writing the results to dst at its origin.

src and dst may be the same image.

parallelism specifies the degree of parallel processing; a value of 4 indicates that processing will be spread across four threads.

Types

type RGB added in v0.20.0

type RGB struct {
	R float32
	G float32
	B float32
}

RGB represents a linear normalised RGB colour value in an unspecified colour space.

func RGBFromEncoded added in v0.26.0

func RGBFromEncoded(c color.Color, trcDecode func(uint16) float32) (col RGB, alpha float32)

RGBFromEncoded returns a normalised RGB instance representing the specified color.Color value. The alpha component is returned as a normalised value in the range 0.0-1.0.

c is assumed to be an encoded colour.

func RGBFromLinear added in v0.26.0

func RGBFromLinear(c color.Color) (col RGB, alpha float32)

RGBFromLinear returns a normalised RGB instance representing the specified color.Color value. The alpha component is returned as a normalised value in the range 0.0-1.0.

c is assumed to be a linear colour.

func (RGB) Luminance added in v0.20.0

func (c RGB) Luminance() float32

Luminance returns the perceptual luminance of this colour.

func (RGB) ToEncodedNRGBA added in v0.20.0

func (c RGB) ToEncodedNRGBA(alpha float32, trcEncode func(float32) uint8) color.NRGBA

ToEncodedNRGBA returns an encoded 8-bit NRGBA representation of this colour suitable for use with instances of image.NRGBA.

alpha is the normalised alpha value and will be clipped to 0.0–1.0.

trcEncode is a tonal response curve encoding function.

func (RGB) ToEncodedRGBA added in v0.20.0

func (c RGB) ToEncodedRGBA(alpha float32, trcEncode func(float32) uint8) color.RGBA

ToEncodedRGBA returns an encoded 8-bit RGBA representation of this colour suitable for use with instances of image.RGBA.

alpha is the normalised alpha value and will be clipped to 0.0–1.0.

trcEncode is a tonal response curve encoding function.

func (RGB) ToEncodedRGBA64 added in v0.26.0

func (c RGB) ToEncodedRGBA64(alpha float32, trcEncode func(float32) uint16) color.RGBA64

ToEncodedRGBA64 returns an encoded 16-bit RGBA representation of this colour suitable for use with instances of image.RGBA64.

alpha is the normalised alpha value and will be clipped to 0.0–1.0.

trcEncode is a tonal response curve encoding function.

func (RGB) ToLinearRGBA64 added in v0.26.0

func (c RGB) ToLinearRGBA64(alpha float32) color.RGBA64

ToLinearRGBA64 returns a linear 16-bit RGBA representation of this colour suitable for use with instances of image.RGBA64.

alpha is the normalised alpha value and will be clipped to 0.0–1.0.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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