mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 02:20:57 +00:00
Use primitive int over Integer
This commit is contained in:
@@ -8,5 +8,5 @@ public interface ColorSampler {
|
||||
* @param z World z coordinate
|
||||
* @return Integer representing a web color
|
||||
*/
|
||||
Integer apply(int x, int z);
|
||||
int apply(int x, int z);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class SingleImageColorSampler implements ColorSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer apply(int x, int z) {
|
||||
public int apply(int x, int z) {
|
||||
var nx = transformation.transformX(image, x);
|
||||
var nz = transformation.transformZ(image, z);
|
||||
if(nx < 0 || nz < 0 || nx >= image.getWidth() || nz >= image.getHeight()) return fallback.apply(x, z);
|
||||
|
||||
@@ -19,7 +19,7 @@ public class TileImageColorSampler implements ColorSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer apply(int x, int z) {
|
||||
public int apply(int x, int z) {
|
||||
x = transformation.transformX(image, x);
|
||||
z = transformation.transformZ(image, z);
|
||||
return image.getRGB(FastMath.floorMod(x, image.getWidth()), FastMath.floorMod(z, image.getHeight()));
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.dfsek.terra.addons.image.colorsampler.mutate;
|
||||
|
||||
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
|
||||
|
||||
|
||||
public class RotateColorSampler implements ColorSampler {
|
||||
|
||||
@@ -16,7 +17,7 @@ public class RotateColorSampler implements ColorSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer apply(int x, int z) {
|
||||
public int apply(int x, int z) {
|
||||
return sampler.apply(
|
||||
(int) (x * FastMath.cos(radians) - z * FastMath.sin(radians)),
|
||||
(int) (z * FastMath.cos(radians) + x * FastMath.sin(radians))
|
||||
|
||||
@@ -15,7 +15,7 @@ public class TranslateColorSampler implements ColorSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer apply(int x, int z) {
|
||||
public int apply(int x, int z) {
|
||||
return sampler.apply(x - translateX, z - translateZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ClosestMatchColorConverter<T> implements ColorConverter<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(Integer color) {
|
||||
public T apply(int color) {
|
||||
int closest = 0;
|
||||
int smallestDistance = Integer.MAX_VALUE;
|
||||
for(int compare : colors) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.addons.image.converter;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
public interface ColorConverter<T> extends Function<Integer, T> {
|
||||
public interface ColorConverter<T> {
|
||||
|
||||
T apply(int color);
|
||||
|
||||
Iterable<T> getEntries();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ExactColorConverter<T> implements ColorConverter<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(Integer color) {
|
||||
public T apply(int color) {
|
||||
if (ignoreAlpha) {
|
||||
color = ColorUtil.zeroAlpha(color);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user