// // Colour class // // Copyright (C) J. Belson 2000.05.20 // // $Author: jon $ : $Date: 2003/10/11 18:11:00 $ // #ifndef _FCOLOUR_H_ #define _FCOLOUR_H_ #include #include #include #include "types.h" #include "vector3d.h" /** * Class for representing and manipulating colours */ class fcolour { private: public: fcolour(float red, float green, float blue, float transparency=1.0); fcolour(uint32 col); fcolour() { r = 1.0; g = 1.0; b = 1.0; alpha = 1.0; }; // Range is 0.0 - 1.0 float r, g, b; float alpha; // Clamp to range 0.0 - 1.0 void clamp(void); // Normalise r/g/b to range 0.0 - 1.0 by desaturation void normalise(void); fcolour blend(fcolour& c); fcolour operator+(fcolour c); fcolour operator-(fcolour c); fcolour operator*(float f); fcolour operator/(float f); fcolour operator*(fcolour c); static void exposure(fcolour& c, float exp=1.0); friend std::ostream& operator<<(std::ostream& str, fcolour& c); static uint32 make_rgb32(uint8 r, uint8 g, uint8 b); // Convert colour to RGBA 32-bit format static uint32 get_rgb32(const fcolour& col); // Convert colour to rgb components void get_rgb8(uint8* r, uint8* g, uint8* b); }; #endif // _FCOLOUR_H_