ScummVM API documentation
te_color.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TETRAEDGE_TE_TE_COLOR_H
23 #define TETRAEDGE_TE_TE_COLOR_H
24 
25 #include "common/types.h"
26 #include "common/stream.h"
27 
28 namespace Tetraedge {
29 
30 class TeColor {
31 public:
32  TeColor();
33  TeColor(uint32 rgba);
34  TeColor(uint16 shortcol);
35  TeColor(byte r, byte g, byte b, byte a);
36 
37  byte &r() { return _c[0]; };
38  byte &g() { return _c[1]; };
39  byte &b() { return _c[2]; };
40  byte &a() { return _c[3]; };
41 
42  const byte &r() const { return _c[0]; };
43  const byte &g() const { return _c[1]; };
44  const byte &b() const { return _c[2]; };
45  const byte &a() const { return _c[3]; };
46 
47  uint32 getPacked() const;
48  uint32 getPacked32() const;
49 
50  bool serialize(Common::WriteStream &stream) const;
51  bool deserialize(Common::ReadStream &stream);
52 
53  bool operator==(const TeColor &c) const {
54  return (_c[0] == c._c[0] && _c[1] == c._c[1] &&
55  _c[2] == c._c[2] && _c[3] == c._c[3]);
56  }
57  bool operator!=(const TeColor &c) {
58  return !operator==(c);
59  }
60 
61  Common::String dump() const {
62  return Common::String::format("TeColor(%d %d %d %d)",
63  _c[0], _c[1], _c[2], _c[3]);
64  }
65 
66 private:
67  byte _c[4];
68 };
69 
70 TeColor operator*(const TeColor &c1, const TeColor &c2);
71 TeColor operator*(const TeColor &c1, double amount);
72 TeColor operator+(const TeColor &c1, const TeColor &c2);
73 
74 } // end namespace Tetraedge
75 
76 #endif // TETRAEDGE_TE_TE_COLOR_H
Definition: str.h:59
Definition: detection.h:27
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: stream.h:77
Definition: te_color.h:30
Definition: stream.h:385