diff options
author | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
commit | b2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch) | |
tree | 3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llmath/v3color.cpp | |
parent | Second Life viewer sources 1.14.0.1 (diff) | |
download | meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2 meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz |
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/llmath/v3color.cpp')
-rw-r--r-- | linden/indra/llmath/v3color.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/linden/indra/llmath/v3color.cpp b/linden/indra/llmath/v3color.cpp index 9428093..5464a0b 100644 --- a/linden/indra/llmath/v3color.cpp +++ b/linden/indra/llmath/v3color.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2000-2007, Linden Research, Inc. | 5 | * Copyright (c) 2000-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -61,3 +62,52 @@ std::ostream& operator<<(std::ostream& s, const LLColor3 &a) | |||
61 | s << "{ " << a.mV[VX] << ", " << a.mV[VY] << ", " << a.mV[VZ] << " }"; | 62 | s << "{ " << a.mV[VX] << ", " << a.mV[VY] << ", " << a.mV[VZ] << " }"; |
62 | return s; | 63 | return s; |
63 | } | 64 | } |
65 | |||
66 | void LLColor3::calcHSL(F32* hue, F32* saturation, F32* luminance) const | ||
67 | { | ||
68 | F32 var_R = mV[VRED]; | ||
69 | F32 var_G = mV[VGREEN]; | ||
70 | F32 var_B = mV[VBLUE]; | ||
71 | |||
72 | F32 var_Min = ( var_R < ( var_G < var_B ? var_G : var_B ) ? var_R : ( var_G < var_B ? var_G : var_B ) ); | ||
73 | F32 var_Max = ( var_R > ( var_G > var_B ? var_G : var_B ) ? var_R : ( var_G > var_B ? var_G : var_B ) ); | ||
74 | |||
75 | F32 del_Max = var_Max - var_Min; | ||
76 | |||
77 | F32 L = ( var_Max + var_Min ) / 2.0f; | ||
78 | F32 H = 0.0f; | ||
79 | F32 S = 0.0f; | ||
80 | |||
81 | if ( del_Max == 0.0f ) | ||
82 | { | ||
83 | H = 0.0f; | ||
84 | S = 0.0f; | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | if ( L < 0.5 ) | ||
89 | S = del_Max / ( var_Max + var_Min ); | ||
90 | else | ||
91 | S = del_Max / ( 2.0f - var_Max - var_Min ); | ||
92 | |||
93 | F32 del_R = ( ( ( var_Max - var_R ) / 6.0f ) + ( del_Max / 2.0f ) ) / del_Max; | ||
94 | F32 del_G = ( ( ( var_Max - var_G ) / 6.0f ) + ( del_Max / 2.0f ) ) / del_Max; | ||
95 | F32 del_B = ( ( ( var_Max - var_B ) / 6.0f ) + ( del_Max / 2.0f ) ) / del_Max; | ||
96 | |||
97 | if ( var_R >= var_Max ) | ||
98 | H = del_B - del_G; | ||
99 | else | ||
100 | if ( var_G >= var_Max ) | ||
101 | H = ( 1.0f / 3.0f ) + del_R - del_B; | ||
102 | else | ||
103 | if ( var_B >= var_Max ) | ||
104 | H = ( 2.0f / 3.0f ) + del_G - del_R; | ||
105 | |||
106 | if ( H < 0.0f ) H += 1.0f; | ||
107 | if ( H > 1.0f ) H -= 1.0f; | ||
108 | } | ||
109 | |||
110 | if (hue) *hue = H; | ||
111 | if (saturation) *saturation = S; | ||
112 | if (luminance) *luminance = L; | ||
113 | } \ No newline at end of file | ||