mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-18 23:01:03 +00:00
Move channels into image lib
This commit is contained in:
+1
-34
@@ -11,6 +11,7 @@ import net.jafama.FastMath;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import com.dfsek.terra.addons.image.util.ColorUtil.Channel;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
@@ -38,38 +39,4 @@ public class ImageSampler implements NoiseSampler {
|
||||
return noise(seed, x, y);
|
||||
}
|
||||
|
||||
public enum Channel {
|
||||
RED {
|
||||
@Override
|
||||
public int getChannel(int mashed) {
|
||||
return (mashed >> 16) & 0xff;
|
||||
}
|
||||
},
|
||||
GREEN {
|
||||
@Override
|
||||
public int getChannel(int mashed) {
|
||||
return (mashed >> 8) & 0xff;
|
||||
}
|
||||
},
|
||||
BLUE {
|
||||
@Override
|
||||
public int getChannel(int mashed) {
|
||||
return mashed & 0xff;
|
||||
}
|
||||
},
|
||||
GRAYSCALE {
|
||||
@Override
|
||||
public int getChannel(int mashed) {
|
||||
return (RED.getChannel(mashed) + GREEN.getChannel(mashed) + BLUE.getChannel(mashed)) / 3;
|
||||
}
|
||||
},
|
||||
ALPHA {
|
||||
@Override
|
||||
public int getChannel(int mashed) {
|
||||
return (mashed >> 24) & 0xff;
|
||||
}
|
||||
};
|
||||
|
||||
public abstract int getChannel(int mashed);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import com.dfsek.terra.addons.image.util.ColorUtil.Channel;
|
||||
import com.dfsek.terra.addons.noise.config.templates.SamplerTemplate;
|
||||
import com.dfsek.terra.addons.noise.image.ImageSampler;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
@@ -27,7 +28,7 @@ public class ImageSamplerTemplate extends SamplerTemplate<ImageSampler> {
|
||||
private @Meta double frequency;
|
||||
|
||||
@Value("channel")
|
||||
private ImageSampler.@Meta Channel channel;
|
||||
private @Meta Channel channel;
|
||||
|
||||
@Override
|
||||
public NoiseSampler get() {
|
||||
|
||||
Reference in New Issue
Block a user