summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorProgramerus <alcadeias95@gmail.com>2012-06-20 17:44:27 +0300
committerProgramerus <alcadeias95@gmail.com>2012-06-20 17:44:27 +0300
commit918f677ae8e00b46db0305d74090f25350ad8d13 (patch)
tree0e78fbb503b721f2bb3e91a4166c305b7ce8e932 /src
parent1415bf0bd296a9e838cf582e376248deae9b4a7a (diff)
downloadcolobot-918f677ae8e00b46db0305d74090f25350ad8d13.tar.gz
colobot-918f677ae8e00b46db0305d74090f25350ad8d13.tar.bz2
colobot-918f677ae8e00b46db0305d74090f25350ad8d13.zip
Color functions
Diffstat (limited to 'src')
-rw-r--r--src/graphics/common/color.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/graphics/common/color.cpp b/src/graphics/common/color.cpp
index 6bffba4..85cd125 100644
--- a/src/graphics/common/color.cpp
+++ b/src/graphics/common/color.cpp
@@ -18,14 +18,12 @@
#include "graphics/common/color.h"
-// TODO
+// Returns the color corresponding long.
-// Returns the color corresponding D3DCOLOR.
-
-D3DCOLOR RetColor(float intensity)
+long RetColor(float intensity)
{
- D3DCOLOR color;
+ long color;
if ( intensity <= 0.0f ) return 0x00000000;
if ( intensity >= 1.0f ) return 0xffffffff;
@@ -38,11 +36,11 @@ D3DCOLOR RetColor(float intensity)
return color;
}
-// Returns the color corresponding D3DCOLOR.
+// Returns the color corresponding long.
-D3DCOLOR RetColor(D3DCOLORVALUE intensity)
+long RetColor(Color intensity)
{
- D3DCOLOR color;
+ long color;
color = (int)(intensity.a*255.0f)<<24;
color |= (int)(intensity.r*255.0f)<<16;
@@ -52,11 +50,11 @@ D3DCOLOR RetColor(D3DCOLORVALUE intensity)
return color;
}
-// Returns the color corresponding D3DCOLORVALUE.
+// Returns the color corresponding Color.
-D3DCOLORVALUE RetColor(D3DCOLOR intensity)
+Color RetColor(long intensity)
{
- D3DCOLORVALUE color;
+ Color color;
color.r = (float)((intensity>>16)&0xff)/256.0f;
color.g = (float)((intensity>>8 )&0xff)/256.0f;
@@ -69,7 +67,7 @@ D3DCOLORVALUE RetColor(D3DCOLOR intensity)
// RGB to HSV conversion.
-void RGB2HSV(D3DCOLORVALUE src, ColorHSV &dest)
+void RGB2HSV(Color src, ColorHSV &dest)
{
float min, max, delta;
@@ -109,7 +107,7 @@ void RGB2HSV(D3DCOLORVALUE src, ColorHSV &dest)
// HSV to RGB conversion.
-void HSV2RGB(ColorHSV src, D3DCOLORVALUE &dest)
+void HSV2RGB(ColorHSV src, Color &dest)
{
int i;
float f,v,p,q,t;