1
0
Fork 0
spectre/include/Spectre/Math/Color.h
Henrik Hautakoski e10daeaaa6
Move everything from global namespace to "sp" namespace
When writing the X11 (linux) implementation there was a problem with X11 defining a "Display" type and we also have a Display class in the engine.

So to fix that problem and minimize the risk for running into other name conflicts. We move everything from global namespace.
2019-09-30 19:10:17 +02:00

69 lines
1.7 KiB
C++

#ifndef SPECTRE_MATH_COLOR_H
#define SPECTRE_MATH_COLOR_H
#include "Vector3.h"
#include "Vector4.h"
namespace sp {
// Basic structure representing a color in 32bit RGBA
struct Color
{
public :
unsigned char r, g, b, a;
// Predefined colors
static const Color Black;
static const Color White;
static const Color Red;
static const Color Green;
static const Color Blue;
static const Color Transparant;
Color(unsigned char red = 0, unsigned char green = 0, unsigned char blue = 0, unsigned char alpha = 255);
// Assignment
Color(const Color& color);
Color& operator=(const Color& color);
// Convert to RGB float.
// Each component is clamped to the range [0.0f, 1.0f]
Vector3f toRGBf() const;
// Convert to RGBA float.
// Each component is clamped to the range [0.0f, 1.0f]
Vector4f toRGBAf() const;
};
// ---------
// Compare
// ---------
bool operator ==(const Color& a, const Color& b);
bool operator !=(const Color& a, const Color& b);
// ------------
// Arithmetic
// ------------
Color operator +(const Color& a, const Color& b);
Color operator -(const Color& a, const Color& b);
Color operator /(const Color& a, const Color& b);
Color operator *(const Color& a, const Color& b);
Color& operator +=(Color& a, const Color& b);
Color& operator -=(Color& a, const Color& b);
Color& operator /=(Color& a, const Color& b);
Color& operator *=(Color& a, const Color& b);
// -------------------
// Scalar arithmetic
// -------------------
Color operator +(const Color& a, unsigned int s);
Color operator -(const Color& a, unsigned int s);
Color operator /(const Color& a, unsigned int s);
Color operator *(const Color& a, unsigned int s);
} // namespace sp
#endif /* SPECTRE_MATH_COLOR_H */