Add blackandwhite mode with threshold for two tone
This commit is contained in:
parent
23ea19e737
commit
4d44903571
3 changed files with 31 additions and 7 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue