34 template <
typename T>
class RGBA
89 return (a.
r==b.
r && a.g==b.g && a.b==b.b && a.a==b.a);
95 return (a.
r!=b.
r || a.g!=b.g || a.b!=b.b || a.a!=b.a);
152 :
RGBA<uchar>(vr,vg,vb,va)
161 static_cast<uchar>(255.0*clamped(c.
r,0.0f,1.0f)),
162 static_cast<uchar>(255.0*clamped(c.g,0.0f,1.0f)),
163 static_cast<uchar>(255.0*clamped(c.b,0.0f,1.0f)),
164 static_cast<uchar>(255.0*clamped(c.a,0.0f,1.0f))
168 std::ostream& write(std::ostream&)
const;
169 const std::string format_comma()
const;
190 :
RGBA<float>(vr,vg,vb,va)
197 :
RGBA<float>(c.
r/255.0f,c.g/255.0f,c.b/255.0,c.a/255.0)
201 std::ostream&
write(std::ostream&)
const;
203 const std::string format_pov_rgb()
const;
205 const std::string format_pov_rgbf()
const;
T r
Colour component.
Definition: rgb.h:39
FloatRGBA()
Null constructor.
Definition: rgb.h:180
Class to represent red-green-blue-alpha colours stored with 8-bit resolution.
Definition: rgb.h:136
bool operator==(const RGBA< T > &a, const RGBA< T > &b)
Colour equality operator.
Definition: rgb.h:87
RGBA< T > operator+(const RGBA< T > &a, const RGBA< T > &b)
Colour addition operator.
Definition: rgb.h:99
ByteRGBA(const RGBA< uchar > &c)
Copy constructor.
Definition: rgb.h:146
std::ostream & operator<<(std::ostream &out, const XYZ &v)
Stream output operator.
Definition: xyz.h:232
FloatRGBA(const RGBA< uchar > &c)
Initialise from ByteRGBA.
Definition: rgb.h:196
RGBA(T vr, T vg, T vb, T va)
Initialise from separate components.
Definition: rgb.h:60
RGBA< T > operator-(const RGBA< T > &c)
Colour negation operator.
Definition: rgb.h:111
bool operator!=(const RGBA< T > &a, const RGBA< T > &b)
Colour inequality operator.
Definition: rgb.h:93
FloatRGBA operator/(const FloatRGBA &c, float k)
Colour division-by-scalar operator.
Definition: rgb.h:233
std::ostream & write(std::ostream &) const
Output method.
Definition: rgb.cpp:40
ByteRGBA()
Null constructor. NB There are no default values.
Definition: rgb.h:141
FloatRGBA(float vr, float vg, float vb, float va)
Initialise from separate components.
Definition: rgb.h:189
ByteRGBA(const RGBA< float > &c)
Construct ByteRGBA from float RGBAs.
Definition: rgb.h:158
void operator+=(const RGBA &v)
Colour addition.
Definition: rgb.h:68
Class to represent red-green-blue-alpha colours stored to floating point accuracy.
Definition: rgb.h:173
FloatRGBA(const RGBA< float > &c)
Copy constructor.
Definition: rgb.h:184
ByteRGBA(uchar vr, uchar vg, uchar vb, uchar va)
Componentwise initialization.
Definition: rgb.h:151
RGBA()
Null constructor.
Definition: rgb.h:48
RGBA(const RGBA &c)
Copy constructor.
Definition: rgb.h:52
FloatRGBA operator*(float k, const FloatRGBA &c)
Colour multiplication-by-scalar operator.
Definition: rgb.h:209
void operator-=(const RGBA &v)
Colour subtraction.
Definition: rgb.h:77