mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-25 10:07:37 +01:00
Added heightmap like combination for flatmap.
This commit is contained in:
parent
02e0f0aa24
commit
ead24cc304
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user