Documentation ¶
Overview ¶
Package hdrcolour provides a float32 RGB colour implementation which conforms to Go's color.Color interface (by conversion to sRGB)
Index ¶
- type Colour
- func (c *Colour) Add(other *Colour)
- func (c *Colour) Intensity() float32
- func (c *Colour) MakeZero()
- func (c *Colour) MultiplyBy(other *Colour)
- func (c *Colour) Scale(multiplier float32)
- func (c *Colour) Scaled(multiplier float32) *Colour
- func (c *Colour) SetColour(r, g, b float32)
- func (c *Colour) String() string
- func (c *Colour) To32Bit() *Colour32Bit
- func (c *Colour) UnmarshalJSON(data []byte) error
- type Colour32Bit
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 FromColor ¶
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 ¶
MultiplyColours returns the Product of two colours
func (*Colour) MultiplyBy ¶
MultiplyBy other colour sets the given vector to its product with the other colour
func (*Colour) Scaled ¶
Scaled returns a new colour which is the product of the original and multiplier
func (*Colour) 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 ¶
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]