/usr/include/cegui-0.8.7/CEGUI/Colour.h is in libcegui-mk2-dev 0.8.7-2.
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 | /***********************************************************************
created: 20/8/2004
author: Paul D Turner (with code from Jeff Leigh)
purpose: Defines interface to the colour class used to represent
colour values within the system
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* 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 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 _CEGUIColour_h_
#define _CEGUIColour_h_
#include "CEGUI/Base.h"
// Start of CEGUI namespace section
namespace CEGUI
{
typedef uint32 argb_t; //!< 32 bit ARGB representation of a colour.
/*!
\brief
Class representing colour values within the system.
*/
class CEGUIEXPORT Colour :
public AllocatedObject<Colour>
{
public:
/*************************************************************************
Construction & Destruction
*************************************************************************/
Colour(void);
Colour(const Colour& val);
Colour(float red, float green, float blue, float alpha = 1.0f);
Colour(argb_t argb);
/*************************************************************************
Accessors
*************************************************************************/
argb_t getARGB(void) const
{
if (!d_argbValid)
{
d_argb = calculateARGB();
d_argbValid = true;
}
return d_argb;
}
float getAlpha(void) const {return d_alpha;}
float getRed(void) const {return d_red;}
float getGreen(void) const {return d_green;}
float getBlue(void) const {return d_blue;}
/*!
\brief
Calculates and returns the hue value based on the Colour
\return
The hue as a float value.
*/
float getHue(void) const;
/*!
\brief
Calculates and returns the saturation value based on the Colour
\return
The saturation as a float value.
*/
float getSaturation(void) const;
/*!
\brief
Calculates and returns the lumination value based on the Colour
\return
The lumination as a float value.
*/
float getLumination(void) const;
/*************************************************************************
Manipulators
*************************************************************************/
void setARGB(argb_t argb);
inline void setAlpha(float alpha)
{
d_argbValid = false;
d_alpha = alpha;
}
inline void setRed(float red)
{
d_argbValid = false;
d_red = red;
}
inline void setGreen(float green)
{
d_argbValid = false;
d_green = green;
}
inline void setBlue(float blue)
{
d_argbValid = false;
d_blue = blue;
}
inline void set(float red, float green, float blue, float alpha = 1.0f)
{
d_argbValid = false;
d_alpha = alpha;
d_red = red;
d_green = green;
d_blue = blue;
}
inline void setRGB(float red, float green, float blue)
{
d_argbValid = false;
d_red = red;
d_green = green;
d_blue = blue;
}
inline void setRGB(const Colour& val)
{
d_red = val.d_red;
d_green = val.d_green;
d_blue = val.d_blue;
if (d_argbValid)
{
d_argbValid = val.d_argbValid;
if (d_argbValid)
d_argb = (d_argb & 0xFF000000) | (val.d_argb & 0x00FFFFFF);
}
}
void setHSL(float hue, float saturation, float luminance, float alpha = 1.0f);
void invertColour(void);
void invertColourWithAlpha(void);
/*************************************************************************
Operators
*************************************************************************/
inline Colour& operator=(argb_t val)
{
setARGB(val);
return *this;
}
inline Colour& operator=(const Colour& val)
{
d_alpha = val.d_alpha;
d_red = val.d_red;
d_green = val.d_green;
d_blue = val.d_blue;
d_argb = val.d_argb;
d_argbValid = val.d_argbValid;
return *this;
}
inline Colour& operator&=(argb_t val)
{
setARGB(getARGB() & val);
return *this;
}
inline Colour& operator&=(const Colour& val)
{
setARGB(getARGB() & val.getARGB());
return *this;
}
inline Colour& operator|=(argb_t val)
{
setARGB(getARGB() | val);
return *this;
}
inline Colour& operator|=(const Colour& val)
{
setARGB(getARGB() | val.getARGB());
return *this;
}
inline Colour& operator<<=(int val)
{
setARGB(getARGB() << val);
return *this;
}
inline Colour& operator>>=(int val)
{
setARGB(getARGB() >> val);
return *this;
}
inline Colour operator+(const Colour& val) const
{
return Colour(
d_red + val.d_red,
d_green + val.d_green,
d_blue + val.d_blue,
d_alpha + val.d_alpha
);
}
inline Colour operator-(const Colour& val) const
{
return Colour(
d_red - val.d_red,
d_green - val.d_green,
d_blue - val.d_blue,
d_alpha - val.d_alpha
);
}
inline Colour operator*(const float val) const
{
return Colour(
d_red * val,
d_green * val,
d_blue * val,
d_alpha * val
);
}
inline Colour& operator*=(const Colour& val)
{
d_red *= val.d_red;
d_blue *= val.d_blue;
d_green *= val.d_green;
d_alpha *= val.d_alpha;
d_argbValid = false;
return *this;
}
/*************************************************************************
Compare operators
*************************************************************************/
inline bool operator==(const Colour& rhs) const
{
return d_red == rhs.d_red &&
d_green == rhs.d_green &&
d_blue == rhs.d_blue &&
d_alpha == rhs.d_alpha;
}
inline bool operator!=(const Colour& rhs) const
{
return !(*this == rhs);
}
//
// Conversion operators
//
operator argb_t() const {return getARGB();}
private:
/*************************************************************************
Implementation Methods
*************************************************************************/
/*!
\brief
calculate and return the ARGB value based on the current colour component values.
*/
argb_t calculateARGB(void) const;
/*************************************************************************
Implementation Data
*************************************************************************/
float d_alpha, d_red, d_green, d_blue; //!< Colour components.
mutable argb_t d_argb; //!< Colour as ARGB value.
mutable bool d_argbValid; //!< True if argb value is valid.
};
} // End of CEGUI namespace section
#endif // end of guard _CEGUIColour_h_
|