From 4d44903571f51105a7b471f932210f4e34052863 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sat, 16 May 2020 17:26:16 -0500 Subject: [PATCH] Add blackandwhite mode with threshold for two tone --- .../org/dynmap/hdmap/DefaultHDLighting.java | 28 ++++++++++++++----- .../dynmap/hdmap/LightLevelHDLighting.java | 1 + DynmapCore/src/main/resources/lightings.txt | 9 ++++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/DefaultHDLighting.java b/DynmapCore/src/main/java/org/dynmap/hdmap/DefaultHDLighting.java index 8cff6f40..8052fa75 100644 --- a/DynmapCore/src/main/java/org/dynmap/hdmap/DefaultHDLighting.java +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/DefaultHDLighting.java @@ -11,24 +11,38 @@ import static org.dynmap.JSONUtils.s; public class DefaultHDLighting implements HDLighting { private String name; protected boolean grayscale; + protected boolean blackandwhite; + protected int blackthreshold; protected final Color graytone; protected final Color graytonedark; public DefaultHDLighting(DynmapCore core, ConfigurationNode configuration) { name = (String) configuration.get("name"); grayscale = configuration.getBoolean("grayscale", false); - graytone = configuration.getColor("graytone", null); + graytone = configuration.getColor("graytone", "#FFFFFF"); graytonedark = configuration.getColor("graytonedark", "#000000"); + blackandwhite = configuration.getBoolean("blackandwhite", false); + if (blackandwhite) grayscale = false; + blackthreshold = configuration.getInteger("blackthreshold", 0x40); } protected void checkGrayscale(Color[] outcolor) { if (grayscale) { - outcolor[0].setGrayscale(); - if (graytone != null) outcolor[0].scaleColor(graytonedark,graytone); - if (outcolor.length > 1) { - outcolor[1].setGrayscale(); - if (graytone != null) outcolor[1].scaleColor(graytonedark, graytone); - } + for (int i = 0; i < outcolor.length; i++) { + outcolor[i].setGrayscale(); + outcolor[i].scaleColor(graytonedark,graytone); + } + } + else if (blackandwhite) { + for (int i = 0; i < outcolor.length; i++) { + outcolor[i].setGrayscale(); + if (outcolor[i].getRed() > blackthreshold) { + outcolor[i].setColor(graytone); + } + else { + outcolor[i].setColor(graytonedark); + } + } } } diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/LightLevelHDLighting.java b/DynmapCore/src/main/java/org/dynmap/hdmap/LightLevelHDLighting.java index 8fca4607..6b22a2bd 100644 --- a/DynmapCore/src/main/java/org/dynmap/hdmap/LightLevelHDLighting.java +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/LightLevelHDLighting.java @@ -18,6 +18,7 @@ public class LightLevelHDLighting extends DefaultHDLighting { public LightLevelHDLighting(DynmapCore core, ConfigurationNode configuration) { super(core, configuration); grayscale = true; // Force to grayscale + blackandwhite = false; for (int i = 0; i < 16; i++) { lightlevelcolors[i] = configuration.getColor("color" + i, null); } diff --git a/DynmapCore/src/main/resources/lightings.txt b/DynmapCore/src/main/resources/lightings.txt index fc8bc799..fc4af5c3 100644 --- a/DynmapCore/src/main/resources/lightings.txt +++ b/DynmapCore/src/main/resources/lightings.txt @@ -130,4 +130,13 @@ lightings: graytone: '#C09A53' graytonedark: '#400000' smooth-lighting: true + # Shadows enabled - black and white parchment, brown ink + - class: org.dynmap.hdmap.ShadowHDLighting + name: parchmentbrowninkbw + shadowstrength: 1.0 + blackandwhite: true + blackthreshold: 64 + graytone: '#C09A53' + graytonedark: '#400000' + smooth-lighting: true \ No newline at end of file