colour

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2017 License: BSD-2-Clause Imports: 1 Imported by: 7

Documentation

Overview

Package colour provides spectral, hero-wavelength and RGB support functions and types.

Index

Constants

View Source
const (
	LambdaMin = 450
	LambdaMax = 750
	LambdaN   = 4
)

Constants for min and maximum wavelength and number of wavelength samples in use for the hero-wavelength.

Variables

This section is empty.

Functions

func RGBToSpectrumSmits99

func RGBToSpectrumSmits99(r, g, b, lambda float32) (c float32)

RGBToSpectrumSmits99 converts an RGB triple to a spectrum at a given wavelength

Types

type CieObserverData

type CieObserverData struct {
	LambdaMin, LambdaMax float32
	// contains filtered or unexported fields
}

CieObserverData encapsulates Standard CIE observer functions

func (*CieObserverData) X

func (ob *CieObserverData) X(lambda float32) float32

X returns the x observer function for the given wavelength lambda.

func (*CieObserverData) Y

func (ob *CieObserverData) Y(lambda float32) float32

Y returns the y observer function for the given wavelength lambda.

func (*CieObserverData) Z

func (ob *CieObserverData) Z(lambda float32) float32

Z returns the z observer function for the given wavelength lambda.

type RGB

type RGB [3]float32

RGB represents a colour triple.

func (*RGB) Add

func (c *RGB) Add(o RGB)

Add adds the RGB triple o to c.

func (RGB) Maxh

func (c RGB) Maxh() float32

Maxh returns the maximum component.

func (RGB) Minh

func (c RGB) Minh() float32

Minh returns the minimum component.

func (*RGB) Mul

func (c *RGB) Mul(o RGB)

Mul multiples the RGB triple o into c.

func (*RGB) Normalize

func (c *RGB) Normalize()

Normalize will scale the components of c to have a max of 1.

func (*RGB) Scale

func (c *RGB) Scale(f float32)

Scale scales the RGB values in-place.

type RGBA

type RGBA [4]float32

RGBA represents a colour triple with an alpha value.

type Space

type Space struct {
	// contains filtered or unexported fields
}

Space represents a transform from XYZ to a different space.

func (*Space) XYZToRGB

func (s *Space) XYZToRGB(x, y, z float32) (rgb RGB)

XYZToRGB returns the transformed XYZ to RGB

type Spectrum

type Spectrum struct {
	C      [LambdaN]float32
	Lambda float32
}

Spectrum represents a line spectrum using the hero-wavelength idea.

func (*Spectrum) Add

func (wv *Spectrum) Add(other Spectrum)

Add adds other to the spectrum. Both spectra must represent the same wavelength.

func (*Spectrum) FromRGB

func (wv *Spectrum) FromRGB(rgb RGB) error

FromRGB ses the spectrum from the RGB values.

func (*Spectrum) Mul

func (wv *Spectrum) Mul(other Spectrum)

Mul multiplies the spectrum by other. Both spectra must represent the same wavelength.

func (*Spectrum) Scale

func (wv *Spectrum) Scale(s float32)

Scale scales the spectrum by s.

func (*Spectrum) Set

func (wv *Spectrum) Set(v float32)

Set sets the spectrum to a constant value.

func (*Spectrum) SetZero

func (wv *Spectrum) SetZero()

SetZero sets the spectrum to 0.

func (*Spectrum) ToRGB

func (wv *Spectrum) ToRGB() (rgb RGB)

ToRGB converts the spectrum to RGB.

func (*Spectrum) Wavelength

func (wv *Spectrum) Wavelength(j int) (v float32)

Wavelength returns the wavelength for index j (see hero-wavelength paper). j = 0..LambdaN

Jump to

Keyboard shortcuts

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