projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Getting rid of nasty tabs
[supertux.git]
/
src
/
video
/
color.hpp
diff --git
a/src/video/color.hpp
b/src/video/color.hpp
index
dc912f7
..
f0bd76d
100644
(file)
--- a/
src/video/color.hpp
+++ b/
src/video/color.hpp
@@
-21,6
+21,7
@@
#define __COLOR_HPP__
#include <vector>
#define __COLOR_HPP__
#include <vector>
+#include <assert.h>
#include "log.hpp"
class Color
#include "log.hpp"
class Color
@@
-38,6
+39,7
@@
public:
}
Color(const std::vector<float>& vals)
{
}
Color(const std::vector<float>& vals)
{
+ assert(vals.size() >= 3);
red = vals[0];
green = vals[1];
blue = vals[2];
red = vals[0];
green = vals[1];
blue = vals[2];
@@
-50,6
+52,12
@@
public:
#endif
}
#endif
}
+ bool operator==(const Color& other) const
+ {
+ return red == other.red && green == other.green && blue == other.blue
+ && alpha == other.alpha;
+ }
+
void check_color_ranges()
{
if(red < 0 || red > 1.0 || green < 0 || green > 1.0
void check_color_ranges()
{
if(red < 0 || red > 1.0 || green < 0 || green > 1.0
@@
-58,8
+66,26
@@
public:
log_warning << "color value out of range: " << red << ", " << green << ", " << blue << ", " << alpha << std::endl;
}
log_warning << "color value out of range: " << red << ", " << green << ", " << blue << ", " << alpha << std::endl;
}
+ float greyscale() const
+ {
+ return red * 0.30 + green * 0.59 + blue * 0.11;
+ }
+
+ bool operator < (const Color& other) const
+ {
+ return greyscale() < other.greyscale();
+ }
+
float red, green, blue, alpha;
float red, green, blue, alpha;
+
+ static const Color BLACK;
+ static const Color RED;
+ static const Color GREEN;
+ static const Color BLUE;
+ static const Color CYAN;
+ static const Color MAGENTA;
+ static const Color YELLOW;
+ static const Color WHITE;
};
#endif
};
#endif
-