2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef HEADER_SUPERTUX_VIDEO_COLOR_HPP
18 #define HEADER_SUPERTUX_VIDEO_COLOR_HPP
23 #include "util/log.hpp"
35 Color(float red_, float green_, float blue_, float alpha_ = 1.0) :
41 assert(0 <= red && red <= 1.0);
42 assert(0 <= green && green <= 1.0);
43 assert(0 <= blue && blue <= 1.0);
46 Color(const std::vector<float>& vals) :
52 assert(vals.size() >= 3);
60 assert(0 <= red && red <= 1.0);
61 assert(0 <= green && green <= 1.0);
62 assert(0 <= blue && blue <= 1.0);
65 bool operator==(const Color& other) const
67 return red == other.red && green == other.green && blue == other.blue
68 && alpha == other.alpha;
71 float greyscale() const
73 return red * 0.30f + green * 0.59f + blue * 0.11f;
76 bool operator < (const Color& other) const
78 return greyscale() < other.greyscale();
81 float red, green, blue, alpha;
83 static const Color BLACK;
84 static const Color RED;
85 static const Color GREEN;
86 static const Color BLUE;
87 static const Color CYAN;
88 static const Color MAGENTA;
89 static const Color YELLOW;
90 static const Color WHITE;