summaryrefslogtreecommitdiff
path: root/src/gui/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/base')
-rw-r--r--src/gui/base/color.cpp39
-rw-r--r--src/gui/base/color.hpp15
2 files changed, 30 insertions, 24 deletions
diff --git a/src/gui/base/color.cpp b/src/gui/base/color.cpp
index 764259efc..485367e6d 100644
--- a/src/gui/base/color.cpp
+++ b/src/gui/base/color.cpp
@@ -72,22 +72,25 @@
namespace gcn
{
Color::Color() :
- r(0),
- g(0),
- b(0),
- a(255)
+ r(0U),
+ g(0U),
+ b(0U),
+ a(255U)
{
}
- Color::Color(const int color) :
+ Color::Color(const unsigned int color) :
r((color >> 16) & 0xFF),
g((color >> 8) & 0xFF),
b(color & 0xFF),
- a(255)
+ a(255U)
{
}
- Color::Color(const int ar, const int ag, const int ab, const int aa) :
+ Color::Color(const unsigned int ar,
+ const unsigned int ag,
+ const unsigned int ab,
+ const unsigned int aa) :
r(ar),
g(ag),
b(ab),
@@ -100,11 +103,11 @@ namespace gcn
Color result(r + color.r,
g + color.g,
b + color.b,
- 255);
+ 255U);
- result.r = (result.r>255?255:(result.r<0?0:result.r));
- result.g = (result.g>255?255:(result.g<0?0:result.g));
- result.b = (result.b>255?255:(result.b<0?0:result.b));
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
return result;
}
@@ -114,11 +117,11 @@ namespace gcn
Color result(r - color.r,
g - color.g,
b - color.b,
- 255);
+ 255U);
- result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
- result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
- result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
return result;
}
@@ -130,9 +133,9 @@ namespace gcn
static_cast<int>(static_cast<float>(b) * value),
a);
- result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
- result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
- result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
return result;
}
diff --git a/src/gui/base/color.hpp b/src/gui/base/color.hpp
index c32adb2e9..781b2cb60 100644
--- a/src/gui/base/color.hpp
+++ b/src/gui/base/color.hpp
@@ -93,7 +93,7 @@ namespace gcn
*
* @param color The color to initialise the object with.
*/
- explicit Color(const int color);
+ explicit Color(const unsigned int color);
/**
* Constructor. The default alpha value is 255.
@@ -104,7 +104,10 @@ namespace gcn
* @param a Alpha, used for transparency. A value of 0 means
* totaly transparent, 255 is totaly opaque.
*/
- Color(const int r, const int g, const int b, const int a = 255);
+ Color(const unsigned int r,
+ const unsigned int g,
+ const unsigned int b,
+ const unsigned int a = 255);
/**
* Adds the RGB values of two colors together. The values will be
@@ -169,23 +172,23 @@ namespace gcn
/**
* Holds the red color component (range 0-255).
*/
- int r;
+ unsigned int r;
/**
* Holds the green color component (range 0-255).
*/
- int g;
+ unsigned int g;
/**
* Holds the blue color component (range 0-255).
*/
- int b;
+ unsigned int b;
/**
* Holds the alpha color component. A value of 0 means totally
* transparent while a value of 255 is considered opaque.
*/
- int a;
+ unsigned int a;
};
} // namespace gcn