mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 16:35:50 +00:00
Use color sampler as fallback instead of constant
This commit is contained in:
parent
5c916f7758
commit
b771e108b6
@ -8,7 +8,7 @@ import com.dfsek.terra.addons.image.sampler.SimpleColorSampler;
|
||||
|
||||
public class SingleColorSamplerTemplate extends ColorSamplerTemplate {
|
||||
@Value("fallback")
|
||||
private int fallback;
|
||||
private ColorSampler fallback;
|
||||
|
||||
@Override
|
||||
public ColorSampler get() {
|
||||
|
@ -8,13 +8,13 @@ public class SimpleColorSampler implements ColorSampler {
|
||||
|
||||
private final Image image;
|
||||
|
||||
private final Integer fallback;
|
||||
private final ColorSampler fallback;
|
||||
|
||||
private final ImageTransformation transformation;
|
||||
|
||||
public SimpleColorSampler(Image image, ColorSampler fallback, ImageTransformation transformation) {
|
||||
this.image = image;
|
||||
this.fallback = fallbackColor;
|
||||
this.fallback = fallback;
|
||||
this.transformation = transformation;
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ public class SimpleColorSampler implements ColorSampler {
|
||||
public Integer apply(int x, int z) {
|
||||
x = transformation.transformX(image, x);
|
||||
z = transformation.transformZ(image, z);
|
||||
if(x < 0 || z < 0 || x >= image.getWidth() || z >= image.getHeight()) return fallback;
|
||||
if(x < 0 || z < 0 || x >= image.getWidth() || z >= image.getHeight()) return fallback.apply(x, z);
|
||||
return image.getRGB(x, z);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user