/usr/include/OGRE/OgreColourValue.h is in libogre-dev 1.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2011 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _COLOURVALUE_H__
#define _COLOURVALUE_H__
#include "OgrePrerequisites.h"
namespace Ogre {
/** \addtogroup Core
* @{
*/
/** \addtogroup General
* @{
*/
typedef uint32 RGBA;
typedef uint32 ARGB;
typedef uint32 ABGR;
typedef uint32 BGRA;
/** Class representing colour.
@remarks
Colour is represented as 4 components, each of which is a
floating-point value from 0.0 to 1.0.
@par
The 3 'normal' colour components are red, green and blue, a higher
number indicating greater amounts of that component in the colour.
The forth component is the 'alpha' value, which represents
transparency. In this case, 0.0 is completely transparent and 1.0 is
fully opaque.
*/
class _OgreExport ColourValue
{
public:
static const ColourValue ZERO;
static const ColourValue Black;
static const ColourValue White;
static const ColourValue Red;
static const ColourValue Green;
static const ColourValue Blue;
explicit ColourValue( float red = 1.0f,
float green = 1.0f,
float blue = 1.0f,
float alpha = 1.0f ) : r(red), g(green), b(blue), a(alpha)
{ }
bool operator==(const ColourValue& rhs) const;
bool operator!=(const ColourValue& rhs) const;
float r,g,b,a;
/** Retrieves colour as RGBA.
*/
RGBA getAsRGBA(void) const;
/** Retrieves colour as ARGB.
*/
ARGB getAsARGB(void) const;
/** Retrieves colour as BGRA.
*/
BGRA getAsBGRA(void) const;
/** Retrieves colours as ABGR */
ABGR getAsABGR(void) const;
/** Sets colour as RGBA.
*/
void setAsRGBA(const RGBA val);
/** Sets colour as ARGB.
*/
void setAsARGB(const ARGB val);
/** Sets colour as BGRA.
*/
void setAsBGRA(const BGRA val);
/** Sets colour as ABGR.
*/
void setAsABGR(const ABGR val);
/** Clamps colour value to the range [0, 1].
*/
void saturate(void)
{
if (r < 0)
r = 0;
else if (r > 1)
r = 1;
if (g < 0)
g = 0;
else if (g > 1)
g = 1;
if (b < 0)
b = 0;
else if (b > 1)
b = 1;
if (a < 0)
a = 0;
else if (a > 1)
a = 1;
}
/** As saturate, except that this colour value is unaffected and
the saturated colour value is returned as a copy. */
ColourValue saturateCopy(void) const
{
ColourValue ret = *this;
ret.saturate();
return ret;
}
/// Array accessor operator
inline float operator [] ( const size_t i ) const
{
assert( i < 4 );
return *(&r+i);
}
/// Array accessor operator
inline float& operator [] ( const size_t i )
{
assert( i < 4 );
return *(&r+i);
}
/// Pointer accessor for direct copying
inline float* ptr()
{
return &r;
}
/// Pointer accessor for direct copying
inline const float* ptr() const
{
return &r;
}
// arithmetic operations
inline ColourValue operator + ( const ColourValue& rkVector ) const
{
ColourValue kSum;
kSum.r = r + rkVector.r;
kSum.g = g + rkVector.g;
kSum.b = b + rkVector.b;
kSum.a = a + rkVector.a;
return kSum;
}
inline ColourValue operator - ( const ColourValue& rkVector ) const
{
ColourValue kDiff;
kDiff.r = r - rkVector.r;
kDiff.g = g - rkVector.g;
kDiff.b = b - rkVector.b;
kDiff.a = a - rkVector.a;
return kDiff;
}
inline ColourValue operator * (const float fScalar ) const
{
ColourValue kProd;
kProd.r = fScalar*r;
kProd.g = fScalar*g;
kProd.b = fScalar*b;
kProd.a = fScalar*a;
return kProd;
}
inline ColourValue operator * ( const ColourValue& rhs) const
{
ColourValue kProd;
kProd.r = rhs.r * r;
kProd.g = rhs.g * g;
kProd.b = rhs.b * b;
kProd.a = rhs.a * a;
return kProd;
}
inline ColourValue operator / ( const ColourValue& rhs) const
{
ColourValue kProd;
kProd.r = rhs.r / r;
kProd.g = rhs.g / g;
kProd.b = rhs.b / b;
kProd.a = rhs.a / a;
return kProd;
}
inline ColourValue operator / (const float fScalar ) const
{
assert( fScalar != 0.0 );
ColourValue kDiv;
float fInv = 1.0f / fScalar;
kDiv.r = r * fInv;
kDiv.g = g * fInv;
kDiv.b = b * fInv;
kDiv.a = a * fInv;
return kDiv;
}
inline friend ColourValue operator * (const float fScalar, const ColourValue& rkVector )
{
ColourValue kProd;
kProd.r = fScalar * rkVector.r;
kProd.g = fScalar * rkVector.g;
kProd.b = fScalar * rkVector.b;
kProd.a = fScalar * rkVector.a;
return kProd;
}
// arithmetic updates
inline ColourValue& operator += ( const ColourValue& rkVector )
{
r += rkVector.r;
g += rkVector.g;
b += rkVector.b;
a += rkVector.a;
return *this;
}
inline ColourValue& operator -= ( const ColourValue& rkVector )
{
r -= rkVector.r;
g -= rkVector.g;
b -= rkVector.b;
a -= rkVector.a;
return *this;
}
inline ColourValue& operator *= (const float fScalar )
{
r *= fScalar;
g *= fScalar;
b *= fScalar;
a *= fScalar;
return *this;
}
inline ColourValue& operator /= (const float fScalar )
{
assert( fScalar != 0.0 );
float fInv = 1.0f / fScalar;
r *= fInv;
g *= fInv;
b *= fInv;
a *= fInv;
return *this;
}
/** Set a colour value from Hue, Saturation and Brightness.
@param hue Hue value, scaled to the [0,1] range as opposed to the 0-360
@param saturation Saturation level, [0,1]
@param brightness Brightness level, [0,1]
*/
void setHSB(Real hue, Real saturation, Real brightness);
/** Convert the current colour to Hue, Saturation and Brightness values.
@param hue Output hue value, scaled to the [0,1] range as opposed to the 0-360
@param saturation Output saturation level, [0,1]
@param brightness Output brightness level, [0,1]
*/
void getHSB(Real* hue, Real* saturation, Real* brightness) const;
/** Function for writing to a stream.
*/
inline _OgreExport friend std::ostream& operator <<
( std::ostream& o, const ColourValue& c )
{
o << "ColourValue(" << c.r << ", " << c.g << ", " << c.b << ", " << c.a << ")";
return o;
}
};
/** @} */
/** @} */
} // namespace
#endif
|