srgb

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: 9 Imported by: 8

Documentation

Overview

Package srgb provides support for the sRGB colour space.

Index

Constants

This section is empty.

Variables

View Source
var PrimaryBlue = ciexyy.Color{X: 0.15, Y: 0.06, YY: 1}
View Source
var PrimaryGreen = ciexyy.Color{X: 0.3, Y: 0.6, YY: 1}
View Source
var PrimaryRed = ciexyy.Color{X: 0.64, Y: 0.33, YY: 1}
View Source
var StandardWhitePoint = ciexyy.D65

Functions

func EncodeColor added in v0.26.0

func EncodeColor(c color.Color) color.RGBA64

EncodeColor converts a linear colour value to an sRGB encoded one.

func EncodeImage added in v0.26.0

func EncodeImage(dst draw.Image, src image.Image, parallelism int)

EncodeImage converts an image with linear colour into an sRGB encoded one.

src is the linearised image to be encoded.

dst is the image to write the result to, beginning 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.

func From16Bit added in v0.29.0

func From16Bit(v uint16) float32

From16Bit converts a 16-bit sRGB encoded value to a normalised linear value between 0.0 and 1.0.

This implementation uses a fast look-up table without sacrificing accuracy.

func From8Bit added in v0.2.0

func From8Bit(v uint8) float32

From8Bit converts an 8-bit sRGB encoded value to a normalised linear value between 0.0 and 1.0.

This implementation uses a fast look-up table without sacrificing accuracy.

func LineariseColor added in v0.26.0

func LineariseColor(c color.Color) color.RGBA64

LineariseColor converts an sRGB encoded colour into a linear one.

func LineariseImage added in v0.26.0

func LineariseImage(dst draw.Image, src image.Image, parallelism int)

LineariseImage converts an image with sRGB encoded colour to linear colour.

src is the encoded image to be linearised.

dst is the image to write the result to, beginning 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.

func To16Bit added in v0.27.2

func To16Bit(v float32) uint16

To16Bit converts a linear value to a 16-bit sRGB encoded value, clipping the linear value to between 0.0 and 1.0.

This implementation uses a fast look-up table and is approximate. For more accuracy, see ConvertLinearTo16Bit.

func To8Bit added in v0.2.0

func To8Bit(v float32) uint8

To8Bit converts a linear value to an 8-bit sRGB encoded value, clipping the linear value to between 0.0 and 1.0.

This implementation uses a fast look-up table and is approximate. For more accuracy, see ConvertLinearTo8Bit.

Types

type Color added in v0.4.0

type Color struct {
	linear.RGB
}

Color represents a linear normalised colour in sRGB space.

func ColorFromEncodedColor added in v0.26.0

func ColorFromEncodedColor(c color.Color) (col Color, alpha float32)

ColorFromEncodedColor creates a Color instance from an sRGB encoded color.Color value. The alpha value is returned as a normalised value between 0.0–1.0.

func ColorFromLinear added in v0.19.0

func ColorFromLinear(r, g, b float32) Color

ColorFromLinear creates a Color instance from a linear normalised RGB triplet.

func ColorFromLinearColor added in v0.26.0

func ColorFromLinearColor(c color.Color) (col Color, alpha float32)

ColorFromLinearColor creates a Color instance from a linear color.Color value. The alpha value is returned as a normalised value between 0.0–1.0.

func ColorFromNRGBA added in v0.4.0

func ColorFromNRGBA(c color.NRGBA) (col Color, alpha float32)

ColorFromNRGBA creates a Color instance by interpreting an 8-bit NRGBA colour as sRGB encoded. The alpha value is returned as a normalised value between 0.0–1.0.

func ColorFromRGBA added in v0.18.0

func ColorFromRGBA(c color.RGBA) (col Color, alpha float32)

ColorFromRGBA creates a Color instance by interpreting an 8-bit RGBA colour as sRGB encoded. The alpha value is returned as a normalised value between 0.0–1.0.

func ColorFromXYZ added in v0.4.0

func ColorFromXYZ(c ciexyz.Color) Color

ColorFromXYZ creates an sRGB Color instance from a CIE XYZ colour.

func (Color) ToNRGBA added in v0.8.0

func (c Color) ToNRGBA(alpha float32) color.NRGBA

ToNRGBA 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.

func (Color) ToRGBA added in v0.18.0

func (c Color) ToRGBA(alpha float32) color.RGBA

ToRGBA 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.

func (Color) ToRGBA64 added in v0.26.0

func (c Color) ToRGBA64(alpha float32) color.RGBA64

ToRGBA64 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.

func (Color) ToXYZ added in v0.4.0

func (c Color) ToXYZ() ciexyz.Color

ToXYZ returns a CIE XYZ representation of this colour.

Jump to

Keyboard shortcuts

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