X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Fcolor.hpp;h=f0bd76d6b0ee87e78802b7823c521a96d81f4146;hb=4f423b9bbb6fa694b8c6bcc338e069aad45db3e3;hp=e94b362d0b3a8cdb3105d16321f253db4ad0bd1e;hpb=5e0bb78e0d7679399eb0f687ecaf93a91cfcb577;p=supertux.git diff --git a/src/video/color.hpp b/src/video/color.hpp index e94b362d0..f0bd76d6b 100644 --- a/src/video/color.hpp +++ b/src/video/color.hpp @@ -66,7 +66,26 @@ public: 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; + + 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