refactor and simplify rendering logic; remove redundant code and consolidate utility methods
This commit is contained in:
1 parent
c5d5eae1c1
commit
094aa463c5
31 files changed
+343
-407
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package eu.mhsl.minecraft.pixelpics.utils;
|
||||
|
||||
import eu.mhsl.minecraft.pixelpics.render.util.ColorUtil;
|
||||
import org.bukkit.map.MapPalette;
|
||||
|
||||
import java.awt.Color;
|
||||
@@ -80,7 +81,7 @@ public final class MapColorPalette {
|
||||
}
|
||||
|
||||
private static double[] rgbToLab(int r, int g, int b) {
|
||||
double rl = pivotSrgb(r), gl = pivotSrgb(g), bl = pivotSrgb(b);
|
||||
double rl = ColorUtil.toLinear(r), gl = ColorUtil.toLinear(g), bl = ColorUtil.toLinear(b);
|
||||
// sRGB -> XYZ (D65)
|
||||
double x = rl * 0.4124 + gl * 0.3576 + bl * 0.1805;
|
||||
double y = rl * 0.2126 + gl * 0.7152 + bl * 0.0722;
|
||||
@@ -91,11 +92,6 @@ public final class MapColorPalette {
|
||||
return new double[]{116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)};
|
||||
}
|
||||
|
||||
private static double pivotSrgb(int c) {
|
||||
double v = c / 255.0;
|
||||
return v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
|
||||
private static double pivotXyz(double t) {
|
||||
return t > 0.008856 ? Math.cbrt(t) : (7.787 * t + 16.0 / 116.0);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user