about summary refs log tree commit diff
path: root/src/game/client/gameclient.h
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-01-04 11:58:25 +0100
committeroy <Tom_Adams@web.de>2011-01-04 11:58:25 +0100
commitbcba9e5c89fad11afc34e2f9c0124edf2d0da74f (patch)
tree0f3cf517e6f3bdeb69ac614f2e1361332ea03483 /src/game/client/gameclient.h
parent336f00ae89be5051be20632c728076a436d93d3c (diff)
downloadzcatch-bcba9e5c89fad11afc34e2f9c0124edf2d0da74f.tar.gz
zcatch-bcba9e5c89fad11afc34e2f9c0124edf2d0da74f.zip
moved HslToRgb stuff
Diffstat (limited to 'src/game/client/gameclient.h')
-rw-r--r--src/game/client/gameclient.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h
index 2f8e21ea..5ee2c989 100644
--- a/src/game/client/gameclient.h
+++ b/src/game/client/gameclient.h
@@ -212,6 +212,31 @@ public:
 	class CScoreboard *m_pScoreboard;
 };
 
+
+inline float HueToRgb(float v1, float v2, float h)
+{
+   if(h < 0.0f) h += 1;
+   if(h > 1.0f) h -= 1;
+   if((6.0f * h) < 1.0f) return v1 + (v2 - v1) * 6.0f * h;
+   if((2.0f * h) < 1.0f) return v2;
+   if((3.0f * h) < 2.0f) return v1 + (v2 - v1) * ((2.0f/3.0f) - h) * 6.0f;
+   return v1;
+}
+
+inline vec3 HslToRgb(vec3 HSL)
+{
+	if(HSL.s == 0.0f)
+		return vec3(HSL.l, HSL.l, HSL.l);
+	else
+	{
+		float v2 = HSL.l < 0.5f ? HSL.l * (1.0f + HSL.s) : (HSL.l+HSL.s) - (HSL.s*HSL.l);
+		float v1 = 2.0f * HSL.l - v2;
+
+		return vec3(HueToRgb(v1, v2, HSL.h + (1.0f/3.0f)), HueToRgb(v1, v2, HSL.h), HueToRgb(v1, v2, HSL.h - (1.0f/3.0f)));
+	}
+}
+
+
 extern const char *Localize(const char *Str);
 
 #endif