Add blackandwhite mode with threshold for two tone
This commit is contained in:
parent
bbd253853d
commit
5f518e7f00
3 changed files with 31 additions and 7 deletions
|
|
@ -11,24 +11,38 @@ import static org.dynmap.JSONUtils.s;
|
||||||
public class DefaultHDLighting implements HDLighting {
|
public class DefaultHDLighting implements HDLighting {
|
||||||
private String name;
|
private String name;
|
||||||
protected boolean grayscale;
|
protected boolean grayscale;
|
||||||
|
protected boolean blackandwhite;
|
||||||
|
protected int blackthreshold;
|
||||||
protected final Color graytone;
|
protected final Color graytone;
|
||||||
protected final Color graytonedark;
|
protected final Color graytonedark;
|
||||||
|
|
||||||
public DefaultHDLighting(DynmapCore core, ConfigurationNode configuration) {
|
public DefaultHDLighting(DynmapCore core, ConfigurationNode configuration) {
|
||||||
name = (String) configuration.get("name");
|
name = (String) configuration.get("name");
|
||||||
grayscale = configuration.getBoolean("grayscale", false);
|
grayscale = configuration.getBoolean("grayscale", false);
|
||||||
graytone = configuration.getColor("graytone", null);
|
graytone = configuration.getColor("graytone", "#FFFFFF");
|
||||||
graytonedark = configuration.getColor("graytonedark", "#000000");
|
graytonedark = configuration.getColor("graytonedark", "#000000");
|
||||||
|
blackandwhite = configuration.getBoolean("blackandwhite", false);
|
||||||
|
if (blackandwhite) grayscale = false;
|
||||||
|
blackthreshold = configuration.getInteger("blackthreshold", 0x40);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkGrayscale(Color[] outcolor) {
|
protected void checkGrayscale(Color[] outcolor) {
|
||||||
if (grayscale) {
|
if (grayscale) {
|
||||||
outcolor[0].setGrayscale();
|
for (int i = 0; i < outcolor.length; i++) {
|
||||||
if (graytone != null) outcolor[0].scaleColor(graytonedark,graytone);
|
outcolor[i].setGrayscale();
|
||||||
if (outcolor.length > 1) {
|
outcolor[i].scaleColor(graytonedark,graytone);
|
||||||
outcolor[1].setGrayscale();
|
}
|
||||||
if (graytone != null) outcolor[1].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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ public class LightLevelHDLighting extends DefaultHDLighting {
|
||||||
public LightLevelHDLighting(DynmapCore core, ConfigurationNode configuration) {
|
public LightLevelHDLighting(DynmapCore core, ConfigurationNode configuration) {
|
||||||
super(core, configuration);
|
super(core, configuration);
|
||||||
grayscale = true; // Force to grayscale
|
grayscale = true; // Force to grayscale
|
||||||
|
blackandwhite = false;
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
lightlevelcolors[i] = configuration.getColor("color" + i, null);
|
lightlevelcolors[i] = configuration.getColor("color" + i, null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,4 +130,13 @@ lightings:
|
||||||
graytone: '#C09A53'
|
graytone: '#C09A53'
|
||||||
graytonedark: '#400000'
|
graytonedark: '#400000'
|
||||||
smooth-lighting: true
|
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
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue