mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-02-26 00:31:44 +01:00
New coloring system for flatmap.
This commit is contained in:
parent
10e03c4219
commit
d5ab98deaf
@ -71,7 +71,6 @@ public class FlatMap extends MapType {
|
|||||||
BufferedImage im = new BufferedImage(t.size, t.size, BufferedImage.TYPE_INT_RGB);
|
BufferedImage im = new BufferedImage(t.size, t.size, BufferedImage.TYPE_INT_RGB);
|
||||||
WritableRaster raster = im.getRaster();
|
WritableRaster raster = im.getRaster();
|
||||||
|
|
||||||
float[] hsb = new float[4];
|
|
||||||
int[] pixel = new int[4];
|
int[] pixel = new int[4];
|
||||||
|
|
||||||
for (int x = 0; x < t.size; x++)
|
for (int x = 0; x < t.size; x++)
|
||||||
@ -87,22 +86,36 @@ public class FlatMap extends MapType {
|
|||||||
if (c == null)
|
if (c == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsb);
|
boolean below = my < 64;
|
||||||
|
|
||||||
float normalheight = 64;
|
// Make height range from 0 - 1 (1 - 0 for below and 0 - 1 above)
|
||||||
float below = Math.min(my, normalheight) / normalheight;
|
float height = (below ? 64 - my : my - 64) / 64.0f;
|
||||||
float above = 1.0f - Math.max(0, my - normalheight) / (128 - normalheight);
|
|
||||||
|
|
||||||
// Saturation will be changed when going higher.
|
// Defines the 'step' in coloring.
|
||||||
hsb[1] *= above;
|
float step = 10 / 128.0f;
|
||||||
|
|
||||||
// Brightness will change when going lower
|
// The step applied to height.
|
||||||
hsb[2] *= below;
|
float scale = ((int)(height/step))*step;
|
||||||
|
|
||||||
int rgb = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]);
|
// Make the smaller values change the color (slightly) more than the higher values.
|
||||||
pixel[0] = (rgb & 0xff0000) >> 16;
|
scale = (float)Math.pow(scale, 1.1f);
|
||||||
pixel[1] = (rgb & 0x00ff00) >> 8;
|
|
||||||
pixel[2] = (rgb & 0x0000ff)/* >> 0 */;
|
// Don't let the color go fully white or fully black.
|
||||||
|
scale *= 0.8f;
|
||||||
|
|
||||||
|
pixel[0] = c.getRed();
|
||||||
|
pixel[1] = c.getGreen();
|
||||||
|
pixel[2] = c.getBlue();
|
||||||
|
|
||||||
|
if (below) {
|
||||||
|
pixel[0] -= pixel[0] * scale;
|
||||||
|
pixel[1] -= pixel[1] * scale;
|
||||||
|
pixel[2] -= pixel[2] * scale;
|
||||||
|
} else {
|
||||||
|
pixel[0] += (255-pixel[0]) * scale;
|
||||||
|
pixel[1] += (255-pixel[1]) * scale;
|
||||||
|
pixel[2] += (255-pixel[2]) * scale;
|
||||||
|
}
|
||||||
|
|
||||||
raster.setPixel(x, y, pixel);
|
raster.setPixel(x, y, pixel);
|
||||||
rendered = true;
|
rendered = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user