colt

package module
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 2 Imported by: 0

README

colt (color utility)

Utility module to help with processing of color data.

State of this project

Functions in srgb.go are good. Everything else isn't much tested or battle-tested.

Plans for the future

  • LAB
  • HSV

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteDecoded

func ByteDecoded(v uint8) float32

ByteDecoded decodes the range [0; 255] of a byte value into a float32 using range [0.0; 1.0] and returns it.

func ByteEncoded

func ByteEncoded(v float32) uint8

ByteEncoded lossily encodes the range [0.0; 1.0] of a float32 value into a byte using range [0; 255] and returns it.

func Linear

func Linear(v float32) float32

Linear returns the linear RGB color space value in range [0.0-1.0] for v, assuming v is in sRGB in range [0.0-1.0].

func Linear16

func Linear16(v uint16) float32

Linear16 returns the linear RGB color space value in range [0.0-1.0] for v, assuming v is in sRGB in range [0-65535].

func Linear16AllNew

func Linear16AllNew(values []uint16) []float32

Linear16AllNew returns a new slice containing the linearized elements of values assuming they are sRGB-encoded color components, or nil if values is empty.

func LinearAll

func LinearAll(values []float32)

LinearAll linearizes each element in values assuming it is an sRGB-encoded color component.

func LinearAllNew

func LinearAllNew(values []float32) []float32

LinearAllNew returns a new slice containing the linearized elements of values assuming they are sRGB-encoded color components, or nil if values is empty.

func Linearb

func Linearb(b uint8) float32

Linearb returns the linear RGB color space value in range [0.0-1.0] for b, assuming b is in sRGB in range [0-255].

func LinearbAllNew

func LinearbAllNew(values []uint8) []float32

LinearbAllNew returns a new slice containing the linearized elements of values assuming they are sRGB-encoded color components, or nil if values is empty.

func Standard

func Standard(v float32) float32

Standard returns the sRGB color space value in range [0.0-1.0] for v, assuming v is in linear RGB in range [0.0-1.0].

func Standard16

func Standard16(v float32) uint16

Standard16 returns the sRGB color space value in range [0-65535] for v, assuming v is in linear RGB in range [0.0-1.0].

func Standard16AllNew

func Standard16AllNew(values []float32) []uint16

Standard16AllNew returns a new slice containing the sRGB-encoded elements of values assuming they are linear RGB color components, or nil if values is empty.

func StandardAll

func StandardAll(values []float32)

StandardAll encodes each element in values in sRGB assuming it is an linear RGB color component.

func StandardAllNew

func StandardAllNew(values []float32) []float32

StandardAllNew returns a new slice containing the sRGB-encoded elements of values assuming they are linear RGB color components, or nil if values is empty.

func Standardb

func Standardb(v float32) uint8

Standardb returns the sRGB color space value in range [0-255] for v, assuming v is in linear RGB in range [0.0-1.0].

func StandardbAllNew

func StandardbAllNew(values []float32) []uint8

StandardbAllNew returns a new slice containing the sRGB-encoded elements of values assuming they are linear RGB color components, or nil if values is empty.

Types

type RGB

type RGB [3]float32

RGB represents a linear RGB color.

func (RGB) Add

func (c RGB) Add(other RGB) RGB

Add adds other to c.

func (RGB) Alpha

func (c RGB) Alpha(alpha float32) RGBA

Alpha returns RGBA{c[0], c[1], c[2], alpha}.

func (RGB) Blend

func (c RGB) Blend(other RGB, amount float32) RGB

Blend blends c with other*amount.

func (RGB) Clamp

func (c RGB) Clamp() RGB

Clamp clamps c's components to range [0;1].

func (RGB) Luminance

func (c RGB) Luminance() float32

Luminance returns the luminance of the color using standard luminance values.

func (RGB) LuminanceCustom

func (c RGB) LuminanceCustom(luminanceRed, luminanceGreen, luminanceBlue float32) float32

LuminanceCustom returns the luminance of the color using given luminance values.

func (RGB) Mul

func (c RGB) Mul(amount float32) RGB

Mul multiplies each component of c with amount.

func (RGB) Standard

func (c RGB) Standard() SRGB

Standard returns the sRGB-encoded representation of this linear RGB color.

func (RGB) Std

func (c RGB) Std() color.RGBA64

Std lossily returns c as a color.RGBA64, assuming it is alpha-premultiplied.

func (RGB) StdN

func (c RGB) StdN() color.NRGBA64

StdN lossily returns c as a color.NRGBA64, assuming it is not alpha-premultiplied.

func (RGB) Sub

func (c RGB) Sub(other RGB) RGB

Sub subtracts other from c.

func (RGB) SubC added in v3.1.0

func (c RGB) SubC(other RGBA) RGB

SubC subtracts the color components of other from c.

type RGBA

type RGBA [4]float32

RGBA represents a linear RGB color with alpha.

func (RGBA) Add

func (c RGBA) Add(other RGBA) RGBA

Add adds other to c.

func (RGBA) Add3

func (c RGBA) Add3(other RGB) RGBA

Add3 adds the color components of other to c.

func (RGBA) AddC

func (c RGBA) AddC(other RGBA) RGBA

AddC adds the color components of other to c.

func (RGBA) Blend

func (c RGBA) Blend(other RGBA, amount float32) RGBA

Blend blends c with other*amount.

func (RGBA) Clamp

func (c RGBA) Clamp() RGBA

Clamp clamps c's components to range [0;1].

func (RGBA) Luminance

func (c RGBA) Luminance() float32

Luminance returns the luminance of the color using standard luminance values, multiplied by its alpha value.

func (RGBA) LuminanceCustom

func (c RGBA) LuminanceCustom(luminanceRed, luminanceGreen, luminanceBlue float32) float32

LuminanceCustom returns the luminance of the color using given luminance values, multiplied by its alpha value.

func (RGBA) Mul

func (c RGBA) Mul(amount float32) RGBA

Mul multiplies each component of c with amount.

func (RGBA) NoAlpha

func (c RGBA) NoAlpha() RGB

NoAlpha returns RGB{c[0], c[1], c[2]}.

func (RGBA) Premultiplied

func (c RGBA) Premultiplied() RGBA

Premultiplied multiplies the R, G and B component of this color with its alpha component, such that in a normal blending scenario the new color is then given by source + dest * (1 - c[3]) instead of source * c[3] + dest * (1 - c[3]), in hopes of easing computational load.

It is the caller's responsibility to track whether this RGBA color is currently premulitplied or not.

func (RGBA) Standard

func (c RGBA) Standard() SRGBA

Standard returns the sRGB-encoded representation of this linear RGB color with alpha.

func (RGBA) Std

func (c RGBA) Std() color.RGBA64

Std lossily returns c as a color.RGBA64, assuming it is alpha-premultiplied.

func (RGBA) StdN

func (c RGBA) StdN() color.NRGBA64

StdN lossily returns c as a color.NRGBA64, assuming it is not alpha-premultiplied.

func (RGBA) Sub

func (c RGBA) Sub(other RGBA) RGBA

Sub subtracts other from c.

func (RGBA) Sub3

func (c RGBA) Sub3(other RGB) RGBA

Sub3 subtracts the color components of other from c.

func (RGBA) SubC

func (c RGBA) SubC(other RGBA) RGBA

SubC subtracts the color components of other from c.

func (RGBA) UnPremultiplied

func (c RGBA) UnPremultiplied() RGBA

UnPremultiplied reverts a prior multiplication of the R, G and B components of this color with its alpha value.

It is the caller's responsibility to track whether this RGBA color is currently premulitplied or not.

type SRGB

type SRGB [3]uint8

SRGB represents an sRGB color where each color component is encoded in a byte.

func (SRGB) Alpha

func (c SRGB) Alpha(alpha uint8) SRGBA

Alpha returns SRGBA{c[0], c[1], c[2], alpha}.

func (SRGB) Linear

func (c SRGB) Linear() RGB

Linear returns the linear RGB representation of this sRGB-encoded color.

func (SRGB) Std

func (c SRGB) Std() color.RGBA

Std returns c as a color.RGBA, assuming it is alpha-premultiplied.

func (SRGB) StdN

func (c SRGB) StdN() color.NRGBA

StdN returns c as a color.NRGBA, assuming it is not alpha-premultiplied.

type SRGBA

type SRGBA [4]uint8

SRGBA represents an sRGB color with alpha where each color component is encoded in a byte.

func (SRGBA) Linear

func (c SRGBA) Linear() RGBA

Linear returns the linear RGB representation of this sRGB-encoded color with alpha.

func (SRGBA) NoAlpha

func (c SRGBA) NoAlpha() SRGB

NoAlpha returns SRGB{c[0], c[1], c[2]}.

func (SRGBA) Std

func (c SRGBA) Std() color.RGBA

Std returns c as a color.RGBA, assuming it is alpha-premultiplied.

func (SRGBA) StdN

func (c SRGBA) StdN() color.NRGBA

StdN returns c as a color.NRGBA, assuming it is not alpha-premultiplied.

Jump to

Keyboard shortcuts

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