Enki  1.9
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
Enki::Color Struct Reference

A color in RGBA. More...

#include <Types.h>

Public Member Functions

 Color (double r=0.0, double g=0.0, double b=0.0, double a=1.0)
 Constructor from separated components.
 
const double & operator[] (size_t i) const
 access component i
 
double & operator[] (size_t i)
 access component i
 
void operator+= (double d)
 Add d to each component.
 
Color operator+ (double d) const
 Add d to each component and return result in a new color. I'm left unchanged.
 
void operator-= (double d)
 Substract d from each component.
 
Color operator- (double d) const
 Substract d from each component and return result in a new color. I'm left unchanged.
 
void operator*= (double d)
 Multiply each component with d.
 
Color operator* (double d) const
 Multiply each component with d and return result in a new color. I'm left unchanged.
 
void operator/= (double d)
 Divide each component with d.
 
Color operator/ (double d) const
 Divide each component with d and return result in a new color. I'm left unchanged.
 
void operator+= (const Color &oc)
 Add oc's components to ours.
 
Color operator+ (const Color &oc) const
 Add oc's components to ours and return result in a new color. I'm left unchanged.
 
void operator-= (const Color &oc)
 Substract oc's components to ours.
 
Color operator- (const Color &oc) const
 Substract oc's components to ours and return result in a new color. I'm left unchanged.
 
bool operator== (const Color &c) const
 Compare all components and return true if they're the same.
 
bool operator!= (const Color &c) const
 Compare all components and return false if they're the same.
 
void threshold (const Color &limit)
 Threshold the color using limit. For each component, if value is below limit, set it to 0.
 
double toGray () const
 Return the grey level value.
 
std::string toString () const
 Return a string describing this color.
 
double r () const
 Red component value getter.
 
void setR (double value)
 Set the value of red component.
 
double g () const
 Green component value getter.
 
void setG (double value)
 Set the value of green component.
 
double b () const
 Blue component value getter.
 
void setB (double value)
 Set the value of blue component.
 
double a () const
 Alpha component value getter.
 
void setA (double value)
 Set the value of alpha component.
 

Static Public Member Functions

static Color fromARGB (uint32_t color)
 Build from an ARGB uint32_t (0xAARRGGBB in little endian)
 
static Color fromABGR (uint32_t color)
 Build from an ABGR uint32_t (0xAABBGGRR in little endian)
 
static uint32_t toARGB (Color color)
 Pack into ABGR uint32_t (0xAABBGGRR in little endian)
 

Public Attributes

double components [4]
 RGBA values in range [0..1].
 

Static Public Attributes

static const Color black
 black (0, 0, 0)
 
static const Color white
 white (1, 1, 1)
 
static const Color gray
 gray (0.5, 0.5, 0.5)
 
static const Color red
 red (1, 0, 0)
 
static const Color green
 green (0, 1, 0)
 
static const Color blue
 blue (0, 0, 1)
 

Friends

std::ostream & operator<< (std::ostream &os, const Color &c)
 

Detailed Description

A color in RGBA.


The documentation for this struct was generated from the following files: