absence_thelab
diff src/common/color.h @ 0:1cffe3409164
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 23 Oct 2014 01:46:07 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/common/color.h Thu Oct 23 01:46:07 2014 +0300 1.3 @@ -0,0 +1,55 @@ 1.4 +#ifndef _COLORS_H_ 1.5 +#define _COLORS_H_ 1.6 + 1.7 +#include <cmath> 1.8 +#include "typedefs.h" 1.9 + 1.10 +#ifdef _MSC_VER 1.11 +#ifdef DOUBLE_PRECISION_MATH 1.12 +typedef double float_t; 1.13 +#else 1.14 +typedef float float_t; 1.15 +#endif // DOUBLE_PRECISION_MATH 1.16 +#endif // _MSC_VER 1.17 + 1.18 +#ifdef NUC3D_VER_DIRECT3D 1.19 + 1.20 +#include "d3d8.h" 1.21 + 1.22 +class Color : public D3DCOLORVALUE { 1.23 +public: 1.24 + 1.25 +#else 1.26 + 1.27 +class Color { 1.28 +public: 1.29 + float_t r, g, b, a; 1.30 + 1.31 +#endif // NUC3D_VER_DIRECT3D 1.32 + 1.33 + Color(float_t intensity = 1.0f); 1.34 + Color(float_t r, float_t g, float_t b, float_t a = 1.0f); 1.35 + Color(unsigned int r, unsigned int g, unsigned int b, unsigned int a = 255); 1.36 + Color(int r, int g, int b, int a = 255); 1.37 + Color(dword pcol); 1.38 + Color(long pcol); 1.39 + 1.40 + Color operator +(const Color &col) const; 1.41 + Color operator -(const Color &col) const; 1.42 + Color operator *(const Color &col) const; 1.43 + Color operator *(float_t scalar) const; 1.44 + 1.45 + void operator +=(const Color &col); 1.46 + void operator -=(const Color &col); 1.47 + void operator *=(const Color &col); 1.48 + void operator *=(float_t scalar); 1.49 + 1.50 + dword GetPacked32() const; 1.51 + word GetPacked16() const; 1.52 + word GetPacked15() const; 1.53 + byte GetNearest8(const byte **pal) const; 1.54 +}; 1.55 + 1.56 +Color BlendColors(const Color &c1, const Color &c2, float_t t); 1.57 + 1.58 +#endif // _COLORS_H_