From ead24cc30480f3942dc44beed84fe64ff01c8e88 Mon Sep 17 00:00:00 2001 From: FrozenCow Date: Tue, 8 Mar 2011 16:42:21 +0100 Subject: [PATCH] Added heightmap like combination for flatmap. --- src/main/java/org/dynmap/flat/FlatMap.java | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/dynmap/flat/FlatMap.java b/src/main/java/org/dynmap/flat/FlatMap.java index a0adc02a..5cd52d54 100644 --- a/src/main/java/org/dynmap/flat/FlatMap.java +++ b/src/main/java/org/dynmap/flat/FlatMap.java @@ -1,6 +1,7 @@ package org.dynmap.flat; import java.awt.Color; +import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.awt.image.WritableRaster; import java.io.File; @@ -69,7 +70,10 @@ public class FlatMap extends MapType { boolean rendered = false; BufferedImage im = new BufferedImage(t.size, t.size, BufferedImage.TYPE_INT_RGB); - WritableRaster r = im.getRaster(); + WritableRaster raster = im.getRaster(); + + float[] hsb = new float[4]; + int[] pixel = new int[4]; for (int x = 0; x < t.size; x++) for (int y = 0; y < t.size; y++) { @@ -83,10 +87,26 @@ public class FlatMap extends MapType { Color c = colors[0]; if (c == null) continue; - r.setPixel(x, y, new int[] { - c.getRed(), - c.getGreen(), - c.getBlue() }); + + + Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsb); + + float normalheight = 64; + float below = Math.min(my, normalheight) / normalheight; + float above = 1.0f - Math.max(0, my - normalheight) / (128 - normalheight); + + // Saturation will be changed when going higher. + hsb[1] *= above; + + // Brightness will change when going lower + hsb[2] *= below; + + int rgb = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]); + pixel[0] = (rgb&0xff0000) >> 16; + pixel[1] = (rgb&0x00ff00) >> 8; + pixel[2] = (rgb&0x0000ff)/* >> 0*/; + + raster.setPixel(x, y, pixel); rendered = true; }