hdrcolour

package
v0.0.0-...-1c48c43 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2017 License: MIT Imports: 4 Imported by: 4

Documentation

Overview

Package hdrcolour provides a float32 RGB colour implementation which conforms to Go's color.Color interface (by conversion to sRGB)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Colour

type Colour struct {
	R, G, B float32
}

Colour is a representation of a float32 RGB colour

func AddColours

func AddColours(first, other *Colour) *Colour

AddColours adds two colours

func FromColor

func FromColor(c color.Color) *Colour

FromColor takes any colour that implements the color.Color interface and turns it into RGB colout(r, g, b are between 0 and 1)

func MultiplyColours

func MultiplyColours(first, other *Colour) *Colour

MultiplyColours returns the Product of two colours

func New

func New(r, g, b float32) *Colour

New returns a new RGB colour

func (*Colour) Add

func (c *Colour) Add(other *Colour)

Add adds another colour to this one

func (*Colour) Intensity

func (c *Colour) Intensity() float32

Intensity returns the intensity of the given colour

func (*Colour) MakeZero

func (c *Colour) MakeZero()

MakeZero returns black RGB colour

func (*Colour) MultiplyBy

func (c *Colour) MultiplyBy(other *Colour)

MultiplyBy other colour sets the given vector to its product with the other colour

func (*Colour) Scale

func (c *Colour) Scale(multiplier float32)

Scale multiplies the colour by the given multiplier

func (*Colour) Scaled

func (c *Colour) Scaled(multiplier float32) *Colour

Scaled returns a new colour which is the product of the original and multiplier

func (*Colour) SetColour

func (c *Colour) SetColour(r, g, b float32)

SetColour sets the colour's components to the given r, g and b

func (*Colour) String

func (c *Colour) String() string

String returns the string representation of the colour in the form of {r, g, b}

Example
c := New(0, 0, 0)
fmt.Printf("%s\n", c)
c = New(42, 3.04, -12.4)
fmt.Printf("%s\n", c)
Output:

{0, 0, 0}
{42, 3.04, -12.4}

func (*Colour) To32Bit

func (c *Colour) To32Bit() *Colour32Bit

To32Bit returns each of the components of the given RGB color to uint32

func (*Colour) UnmarshalJSON

func (c *Colour) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type Colour32Bit

type Colour32Bit struct {
	R, G, B uint32
}

Colour32Bit is 32bit colour implementing the color.Color interface

func NewColour32Bit

func NewColour32Bit(r, g, b uint32) *Colour32Bit

NewColour32Bit return a new 32bit colour

func (*Colour32Bit) RGBA

func (c *Colour32Bit) RGBA() (r, g, b, a uint32)

RGBA implements the color.Color interface converting the 32bit colour to 32bit colour with alpha

func (*Colour32Bit) String

func (c *Colour32Bit) String() string

String returns the string representation of the 32bit colour in the form of [r, g, b]

Jump to

Keyboard shortcuts

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