1 /*
2  * Copyright (C) 2006-2019 Christopho, Solarus - http://www.solarus-games.org
3  *
4  * Solarus 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.
8  *
9  * Solarus 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.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #ifndef SOLARUS_COLOR_H
18 #define SOLARUS_COLOR_H
19 
20 #include "solarus/core/Common.h"
21 #include <cstdint>
22 
23 namespace Solarus {
24 
25 /**
26  * \brief Represents a color.
27  *
28  * This class simply wraps the RGBA components of a color.
29  */
30 class SOLARUS_API Color {
31 
32   public:
33 
34     constexpr Color();
35     constexpr Color(int r, int g, int b, int a = 255);
36 
37     constexpr uint8_t get_alpha() const;
38     void set_alpha(uint8_t alpha);
39     void get_components(uint8_t& r, uint8_t& g, uint8_t& b, uint8_t& a) const;
40     void set_components(int r, int g, int b, int a = 255);
41 
42     // Some predefined colors.
43     static const Color transparent;
44     static const Color black;
45     static const Color white;
46     static const Color red;
47     static const Color green;
48     static const Color blue;
49     static const Color yellow;
50     static const Color magenta;
51     static const Color cyan;
52 
53     friend constexpr bool operator==(const Color& lhs, const Color& rhs);
54     friend constexpr bool operator!=(const Color& lhs, const Color& rhs);
55 
56     uint8_t r;     /**< The red component. */
57     uint8_t g;     /**< The green component. */
58     uint8_t b;     /**< The blue component. */
59     uint8_t a;     /**< The alpha (opacity) component. 255 is opaque. */
60 };
61 
62 }
63 
64 #include "solarus/graphics/Color.inl"
65 
66 #endif
67 
68