Skip to content

Commit

Permalink
improve/fix color configurability
Browse files Browse the repository at this point in the history
  • Loading branch information
svencc committed Mar 10, 2024
1 parent d838152 commit a5d3b47
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ private int calculateContour(
if (dem[adjacentNeighborX][adjacentNeighborY] > layer.getHeight()
&& dem[adjacentOppositeNeighborX][adjacentOppositeNeighborY] < layer.getHeight()
) {
return layer.getColor();
return layer.getColor(mapScheme);
} else if (dem[adjacentNeighborX][adjacentNeighborY] < layer.getHeight()
&& dem[adjacentOppositeNeighborX][adjacentOppositeNeighborY] > layer.getHeight()
) {
return layer.getColor();
return layer.getColor(mapScheme);
}
}
}
Expand Down Expand Up @@ -94,13 +94,13 @@ private List<ContourLineLayer> generateContourLineLayers(
}


@Getter
@Builder
@RequiredArgsConstructor
private static class ContourLineLayer {

@NonNull
private final MapDesignScheme mapScheme;
@Getter
private final float height;
private final int color;

Expand Down Expand Up @@ -136,38 +136,26 @@ public boolean isBelowSeaLevel() {
return height < 0;
}

public int getColor() {
public int getColor(@NonNull final MapDesignScheme mapScheme) {
if (height != 0) {
if (height % 100 == 0) {
if (height % mapScheme.getMainContourLineStepSize() == 0) {
if (isAboveSeaLevel()) {
return colorCalculator.modifyBrightness(color, mapScheme.getBrightnessModifierPrimaryLinesAboveSeaLevel());
return colorCalculator.modifyTransparency(color, mapScheme.getTransparencyModifierPrimaryLinesAboveSeaLevel());
} else {
return colorCalculator.modifyBrightness(color, mapScheme.getBrightnessModifierPrimaryLinesBelowSeaLevel());
return colorCalculator.modifyTransparency(color, mapScheme.getTransparencyModifierPrimaryLinesBelowSeaLevel());
}
} else {
if (isAboveSeaLevel()) {
return colorCalculator.modifyBrightness(color, mapScheme.getBrightnessModifierSecondaryLinesAboveSeaLevel());
return colorCalculator.modifyTransparency(color, mapScheme.getTransparencyModifierSecondaryLinesAboveSeaLevel());
} else {
return colorCalculator.modifyBrightness(color, mapScheme.getBrightnessModifierSecondaryLinesBelowSeaLevel());
return colorCalculator.modifyTransparency(color, mapScheme.getTransparencyModifierSecondaryLinesBelowSeaLevel());
}
}
}

return color;
}

public int getColor_() {
if (height != 0) {
if (isAboveSeaLevel()) {
return colorCalculator.modifyBrightness(color, mapScheme.getBrightnessModifierPrimaryLinesAboveSeaLevel());
} else {
return colorCalculator.modifyBrightness(color, mapScheme.getBrightnessModifierSecondaryLinesAboveSeaLevel());
}
}

return color;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public void clearCache() {
public abstract int getBaseColorContourLineTerrain();
public abstract int getBaseColorContourLineCoast();
public abstract int getBaseColorContourLineWater();
public abstract float getBrightnessModifierPrimaryLinesAboveSeaLevel();
public abstract float getBrightnessModifierSecondaryLinesAboveSeaLevel();
public abstract float getBrightnessModifierPrimaryLinesBelowSeaLevel();
public abstract float getBrightnessModifierSecondaryLinesBelowSeaLevel();
public abstract float getTransparencyModifierPrimaryLinesAboveSeaLevel();
public abstract float getTransparencyModifierSecondaryLinesAboveSeaLevel();
public abstract float getTransparencyModifierPrimaryLinesBelowSeaLevel();
public abstract float getTransparencyModifierSecondaryLinesBelowSeaLevel();
public abstract int getContourLineStepSize();
public abstract int getMainContourLineStepSize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public class MapDesignSchemeImplementation extends MapDesignScheme {
@Builder.Default
private int baseColorContourLineWater = 0x22597482;
@Builder.Default
private float brightnessModifierPrimaryLinesAboveSeaLevel = 0.6f;
private float transparencyModifierPrimaryLinesAboveSeaLevel = 0.6f;
@Builder.Default
private float brightnessModifierSecondaryLinesAboveSeaLevel = 1f;
private float transparencyModifierSecondaryLinesAboveSeaLevel = 1f;
@Builder.Default
private final float brightnessModifierPrimaryLinesBelowSeaLevel = 0.25f;
private final float transparencyModifierPrimaryLinesBelowSeaLevel = 0.25f;
@Builder.Default
private final float brightnessModifierSecondaryLinesBelowSeaLevel = 1f;
private final float transparencyModifierSecondaryLinesBelowSeaLevel = 1f;
@Builder.Default
private int contourLineStepSize = 20;
@Builder.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public class ReforgerMapDesignScheme extends MapDesignScheme {

// Contour line config
private final int baseColorContourBackground = 0x00000000;
private final int baseColorContourLineTerrain = 0x44BEAA8C;
private final int baseColorContourLineTerrain = 0xFFBEAA8C;
private final int baseColorContourLineCoast = 0xAA597482;
private final int baseColorContourLineWater = 0x22597482;
private final float brightnessModifierPrimaryLinesAboveSeaLevel = 0.6f;
private final float brightnessModifierSecondaryLinesAboveSeaLevel = 1f;
private final float brightnessModifierPrimaryLinesBelowSeaLevel = 0.25f;
private final float brightnessModifierSecondaryLinesBelowSeaLevel = 1f;
private final int contourLineStepSize = 20;
private final int mainContourLineStepSize = 100;
private final int baseColorContourLineWater = 0xFF597482;
private final float transparencyModifierPrimaryLinesAboveSeaLevel = 0.7f;
private final float transparencyModifierSecondaryLinesAboveSeaLevel = 0.3f;
private final float transparencyModifierPrimaryLinesBelowSeaLevel = 0.5f;
private final float transparencyModifierSecondaryLinesBelowSeaLevel = 0.15f;
private final int contourLineStepSize = 10;
private final int mainContourLineStepSize = 50;

// Sun config (shadowing)
private final int sunAzimutDeg = 315; // usually 315
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,27 @@ public class MapDesignSchemeDto {
@Nullable
@Schema
@JsonProperty()
public Float brightnessModifierPrimaryLinesAboveSeaLevel;
public Float transparencyModifierPrimaryLinesAboveSeaLevel;
@Nullable
@Schema
@JsonProperty()
public Float brightnessModifierSecondaryLinesAboveSeaLevel;
public Float transparencyModifierSecondaryLinesAboveSeaLevel;
@Nullable
@Schema
@JsonProperty()
public Float brightnessModifierPrimaryLinesBelowSeaLevel;
public Float transparencyModifierPrimaryLinesBelowSeaLevel;
@Nullable
@Schema
@JsonProperty()
public Float brightnessModifierSecondaryLinesBelowSeaLevel;
public Float transparencyModifierSecondaryLinesBelowSeaLevel;
@Nullable
@Schema
@JsonProperty()
public Integer contourLineStepSize;
@Nullable
@Schema
@JsonProperty()
public Integer mainContourLineStepSize;


// Sun config (shadowing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public interface MapDesignSchemeMapper {
@Mapping(source = "baseColorContourLineTerrain", target = "baseColorContourLineTerrain", qualifiedByName = "hexStringToInteger")
@Mapping(source = "baseColorContourLineCoast", target = "baseColorContourLineCoast", qualifiedByName = "hexStringToInteger")
@Mapping(source = "baseColorContourLineWater", target = "baseColorContourLineWater", qualifiedByName = "hexStringToInteger")

@Mapping(source = "shadowMapAlpha", target = "shadowMapAlpha", qualifiedByName = "hexStringToInteger")
MapDesignSchemeImplementation toDesignScheme(final MapDesignSchemeDto dto);

Expand Down

0 comments on commit a5d3b47

Please sign in to comment.