Use primitive int over Integer

This commit is contained in:
Astrash
2023-06-14 11:15:25 +10:00
parent 5188477a6d
commit d0591f292e
8 changed files with 13 additions and 12 deletions

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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()));

View File

@@ -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))

View File

@@ -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);
}
}

View File

@@ -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) {

View File

@@ -1,8 +1,8 @@
package com.dfsek.terra.addons.image.converter;
import java.util.function.Function;
public interface ColorConverter<T> {
T apply(int color);
public interface ColorConverter<T> extends Function<Integer, T> {
Iterable<T> getEntries();
}

View File

@@ -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);
}