aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs32
1 files changed, 16 insertions, 16 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
index 957a1df..615befc 100644
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
@@ -82,10 +82,10 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
82 // (for info about algorithm, see http://en.wikipedia.org/wiki/HSL_and_HSV) 82 // (for info about algorithm, see http://en.wikipedia.org/wiki/HSL_and_HSV)
83 public Color toColor() 83 public Color toColor()
84 { 84 {
85 if(s < 0f) Console.WriteLine("S < 0: " + s); 85 if (s < 0f) Console.WriteLine("S < 0: " + s);
86 else if(s > 1f) Console.WriteLine("S > 1: " + s); 86 else if (s > 1f) Console.WriteLine("S > 1: " + s);
87 if(v < 0f) Console.WriteLine("V < 0: " + v); 87 if (v < 0f) Console.WriteLine("V < 0: " + v);
88 else if(v > 1f) Console.WriteLine("V > 1: " + v); 88 else if (v > 1f) Console.WriteLine("V > 1: " + v);
89 89
90 float f = h / 60f; 90 float f = h / 60f;
91 int sector = (int)f % 6; 91 int sector = (int)f % 6;
@@ -95,7 +95,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
95 int ti = (int)(v * (1f - (1f - f) * s) * 255f); 95 int ti = (int)(v * (1f - (1f - f) * s) * 255f);
96 int vi = (int)(v * 255f); 96 int vi = (int)(v * 255f);
97 97
98 switch(sector) 98 switch (sector)
99 { 99 {
100 case 0: 100 case 0:
101 return Color.FromArgb(vi, ti, pi); 101 return Color.FromArgb(vi, ti, pi);
@@ -168,7 +168,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
168 { 168 {
169 AssetBase asset = m_scene.AssetCache.GetAsset(id, true); 169 AssetBase asset = m_scene.AssetCache.GetAsset(id, true);
170 m_log.DebugFormat("Fetched texture {0}, found: {1}", id, asset != null); 170 m_log.DebugFormat("Fetched texture {0}, found: {1}", id, asset != null);
171 if(asset == null) return null; 171 if (asset == null) return null;
172 return new Bitmap(OpenJPEG.DecodeToImage(asset.Data)); 172 return new Bitmap(OpenJPEG.DecodeToImage(asset.Data));
173 } 173 }
174 174
@@ -179,9 +179,9 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
179 // color-channel, so 2^24 is the maximum value we can get, adding everything. 179 // color-channel, so 2^24 is the maximum value we can get, adding everything.
180 // int is be big enough for that. 180 // int is be big enough for that.
181 int r = 0, g = 0, b = 0; 181 int r = 0, g = 0, b = 0;
182 for(int y = 0; y < bmp.Height; ++y) 182 for (int y = 0; y < bmp.Height; ++y)
183 { 183 {
184 for(int x = 0; x < bmp.Width; ++x) 184 for (int x = 0; x < bmp.Width; ++x)
185 { 185 {
186 Color c = bmp.GetPixel(x, y); 186 Color c = bmp.GetPixel(x, y);
187 r += (int)c.R & 0xff; 187 r += (int)c.R & 0xff;
@@ -218,14 +218,14 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
218 218
219 // interpolate two colors in HSV space and return the resulting color 219 // interpolate two colors in HSV space and return the resulting color
220 private HSV interpolateHSV(ref HSV c1, ref HSV c2, float ratio) { 220 private HSV interpolateHSV(ref HSV c1, ref HSV c2, float ratio) {
221 if(ratio <= 0f) return c1; 221 if (ratio <= 0f) return c1;
222 if(ratio >= 1f) return c2; 222 if (ratio >= 1f) return c2;
223 223
224 // make sure we are on the same side on the hue-circle for interpolation 224 // make sure we are on the same side on the hue-circle for interpolation
225 // We change the hue of the parameters here, but we don't change the color 225 // We change the hue of the parameters here, but we don't change the color
226 // represented by that value 226 // represented by that value
227 if(c1.h - c2.h > 180f) c1.h -= 360f; 227 if (c1.h - c2.h > 180f) c1.h -= 360f;
228 else if(c2.h - c1.h > 180f) c1.h += 360f; 228 else if (c2.h - c1.h > 180f) c1.h += 360f;
229 229
230 return new HSV(c1.h * (1f - ratio) + c2.h * ratio, 230 return new HSV(c1.h * (1f - ratio) + c2.h * ratio,
231 c1.s * (1f - ratio) + c2.s * ratio, 231 c1.s * (1f - ratio) + c2.s * ratio,
@@ -321,16 +321,16 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
321 } 321 }
322 322
323 HSV hsv; 323 HSV hsv;
324 if(hmod <= low) hsv = hsv1; // too low 324 if (hmod <= low) hsv = hsv1; // too low
325 else if(hmod >= high) hsv = hsv4; // too high 325 else if (hmod >= high) hsv = hsv4; // too high
326 else 326 else
327 { 327 {
328 // HSV-interpolate along the colors 328 // HSV-interpolate along the colors
329 // first, rescale h to 0.0 - 1.0 329 // first, rescale h to 0.0 - 1.0
330 hmod = (hmod - low) / (high - low); 330 hmod = (hmod - low) / (high - low);
331 // now we have to split: 0.00 => color1, 0.33 => color2, 0.67 => color3, 1.00 => color4 331 // now we have to split: 0.00 => color1, 0.33 => color2, 0.67 => color3, 1.00 => color4
332 if(hmod < 1f/3f) hsv = interpolateHSV(ref hsv1, ref hsv2, hmod * 3f); 332 if (hmod < 1f/3f) hsv = interpolateHSV(ref hsv1, ref hsv2, hmod * 3f);
333 else if(hmod < 2f/3f) hsv = interpolateHSV(ref hsv2, ref hsv3, (hmod * 3f) - 1f); 333 else if (hmod < 2f/3f) hsv = interpolateHSV(ref hsv2, ref hsv3, (hmod * 3f) - 1f);
334 else hsv = interpolateHSV(ref hsv3, ref hsv4, (hmod * 3f) - 2f); 334 else hsv = interpolateHSV(ref hsv3, ref hsv4, (hmod * 3f) - 2f);
335 } 335 }
336 336