1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198 | #include "fsSColour.h"
#include <sstream>
#include <fsCore/src/debug/fsAssert.h>
fsBool fsSColour::operator!=(const fsSColour& pRhs) const
{
return !(operator==(pRhs));
}
fsBool fsSColour::operator==(const fsSColour& pRhs) const
{
return mR == pRhs.mR && mG == pRhs.mG && mB == pRhs.mB && mA == pRhs.mA;
}
const fsSColour fsSColour::operator+(const fsSColour& pRhs) const
{
fsSColour ret = *this;
ret.mR += pRhs.mR;
if (ret.mR > 1.0f)
{
ret.mR = 1.0f;
}
ret.mG += pRhs.mG;
if (ret.mG > 1.0f)
{
ret.mG = 1.0f;
}
ret.mB += pRhs.mB;
if (ret.mB > 1.0f)
{
ret.mB = 1.0f;
}
ret.mA += pRhs.mA;
if (ret.mA > 1.0f)
{
ret.mA = 1.0f;
}
return ret;
}
const fsSColour fsSColour::operator-(const fsSColour& pRhs) const
{
fsSColour ret = *this;
ret.mR -= pRhs.mR;
ret.mG -= pRhs.mG;
ret.mB -= pRhs.mB;
ret.mA -= pRhs.mA;
return ret;
}
const fsSColour fsSColour::operator*(fsS32 pRhs) const
{
fsSColour ret = *this;
ret.mR *= pRhs;
ret.mG *= pRhs;
ret.mB *= pRhs;
ret.mA *= pRhs;
return ret;
}
const fsSColour fsSColour::operator/(fsS32 pRhs) const
{
fsSColour ret = *this;
ret.mR /= pRhs;
ret.mG /= pRhs;
ret.mB /= pRhs;
ret.mA /= pRhs;
return ret;
}
fsU8 fsSColour::redByteGet() const
{
return static_cast<fsU8>(mR * 255);
}
fsU8 fsSColour::greenByteGet() const
{
return static_cast<fsU8>(mG * 255);
}
fsU8 fsSColour::blueByteGet() const
{
return static_cast<fsU8>(mB * 255);
}
fsU8 fsSColour::alphaByteGet() const
{
return static_cast<fsU8>(mA * 255);
}
fsSColour::fsSColour() :
mR(1.0),
mG(1.0),
mB(1.0),
mA(1.0)
{
}
fsSColour::fsSColour(fsF32 pR, fsF32 pG, fsF32 pB, fsF32 pA) :
mR(pR),
mG(pG),
mB(pB),
mA(pA)
{
}
fsSColour::fsSColour(const fsSColour4B& pByteColour)
{
mR = static_cast<fsF32>(pByteColour.mR) / 255.0f;<--- Variable 'mR' is assigned in constructor body. Consider performing initialization in initialization list. [+]When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'mR' a value by passing the value to the constructor in the initialization list.
mG = static_cast<fsF32>(pByteColour.mG) / 255.0f;<--- Variable 'mG' is assigned in constructor body. Consider performing initialization in initialization list. [+]When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'mG' a value by passing the value to the constructor in the initialization list.
mB = static_cast<fsF32>(pByteColour.mB) / 255.0f;<--- Variable 'mB' is assigned in constructor body. Consider performing initialization in initialization list. [+]When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'mB' a value by passing the value to the constructor in the initialization list.
mA = static_cast<fsF32>(pByteColour.mA) / 255.0f;<--- Variable 'mA' is assigned in constructor body. Consider performing initialization in initialization list. [+]When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'mA' a value by passing the value to the constructor in the initialization list.
}
fsSColour::fsSColour(const fsStr& pRGBAStr)
{
fsAssert((pRGBAStr.dataSizeGet() == 10 || pRGBAStr.dataSizeGet() == 8),
"Expected an 8 character hex string when creating an fsCColour from a string (%s).\n", pRGBAStr.utf8Get());
fsU32 val = 0;
std::stringstream ss;
ss << std::hex << pRGBAStr.utf8Get();
ss >> val;
mR = static_cast<fsF32>(((val >> 24) & 0xFF)) / 255.0f;
mG = static_cast<fsF32>(((val >> 16) & 0xFF)) / 255.0f;
mB = static_cast<fsF32>(((val >> 8) & 0xFF)) / 255.0f;
mA = static_cast<fsF32>(((val >> 0) & 0xFF)) / 255.0f;
}
fsSColour::~fsSColour()
{
}
fsSColour4B::fsSColour4B(const fsStr& pRGBAStr)
{
fsAssert((pRGBAStr.dataSizeGet() == 10 || pRGBAStr.dataSizeGet() == 8),
"Expected an 8 character hex string when creating an fsCColour from a string (%s).\n", pRGBAStr.utf8Get());
fsU32 val = 0;
std::stringstream ss;
ss << std::hex << pRGBAStr.utf8Get();
ss >> val;
mR = static_cast<fsU8>((val >> 24) & 0xFF);
mG = static_cast<fsU8>((val >> 16) & 0xFF);
mB = static_cast<fsU8>((val >> 8) & 0xFF);
mA = static_cast<fsU8>((val >> 0) & 0xFF);
}
fsBool fsSColour4B::operator<(const fsSColour4B& pRhs) const
{
return this->mR < pRhs.mR;
}
fsBool fsSColour4B::operator==(const fsSColour4B& pRhs) const
{
return mR == pRhs.mR && mG == pRhs.mG && mB == pRhs.mB && mA == pRhs.mA;
}
fsBool fsSColour4B::operator!=(const fsSColour4B& pRhs) const
{
return !(operator==(pRhs));
}
fsSColour4B fsSColour4B::fsNONE()
{
return fsSColour4B(0, 0, 0, 0);
}
fsSColour4B fsSColour4B::fsBLACK()
{
return fsSColour4B(0, 0, 0, 255);
}
fsSColour4B fsSColour4B::fsWHITE()
{
return fsSColour4B(255, 255, 255, 255);
}
fsSColour4B fsSColour4B::fsRED()
{
return fsSColour4B(255, 0, 0, 255);
}
fsSColour4B::fsSColour4B(const fsSColour& pCol):
mR(static_cast<fsU8>(pCol.redByteGet())),
mG(static_cast<fsU8>(pCol.greenByteGet())),
mB(static_cast<fsU8>(pCol.blueByteGet())),
mA(static_cast<fsU8>(pCol.alphaByteGet()))
{
}
|