diff --git a/colorful/src/test/java/com/github/tommyettinger/colorful/oklab/BasicChecks.java b/colorful/src/test/java/com/github/tommyettinger/colorful/oklab/BasicChecks.java index 1f85d43b..46210789 100644 --- a/colorful/src/test/java/com/github/tommyettinger/colorful/oklab/BasicChecks.java +++ b/colorful/src/test/java/com/github/tommyettinger/colorful/oklab/BasicChecks.java @@ -129,17 +129,21 @@ public void testPalette() { } } public static double reverseLight(double L) { - L = Math.sqrt(L * 0x0.ffp0); // 255.0/256.0 - final double shape = 1.52, turning = 0.963; - final double d = turning - L; - double r; - if(d < 0) - r = ((1.0 - turning) * (L - 1.0)) / (1.0 - (L + shape * d)) + 1.0; - else - r = (turning * L) / (1e-50 + (L + shape * d)); - return r; + return Math.pow(L, 2.0/3.0); } +// public static double reverseLight(double L) { +// L = Math.sqrt(L * 0x0.ffp0); // 255.0/256.0 +// final double shape = 1.52, turning = 0.963; +// final double d = turning - L; +// double r; +// if(d < 0) +// r = ((1.0 - turning) * (L - 1.0)) / (1.0 - (L + shape * d)) + 1.0; +// else +// r = (turning * L) / (1e-50 + (L + shape * d)); +// return r; +// } + /** * Returns true if the given Oklab values are valid to convert losslessly back to RGBA. * @param L lightness channel, as a double from 0 to 1 @@ -150,7 +154,7 @@ public static double reverseLight(double L) { public static boolean inGamut(double L, double A, double B) { //reverseLight() for double - L = reverseLight(L); + L = reverseLight(L) * 0x0.ffp0; //forwardLight() for double // L = (L - 1.00457) / (1.0 - L * 0.4285714) + 1.00457; A -= 0x1.fdfdfep-2; diff --git a/colorful/src/test/java/com/github/tommyettinger/colorful/oklab/internal/GamutWriter.java b/colorful/src/test/java/com/github/tommyettinger/colorful/oklab/internal/GamutWriter.java index 0152b6ce..3f53c910 100644 --- a/colorful/src/test/java/com/github/tommyettinger/colorful/oklab/internal/GamutWriter.java +++ b/colorful/src/test/java/com/github/tommyettinger/colorful/oklab/internal/GamutWriter.java @@ -149,16 +149,19 @@ public static void generateByteString(final byte[] data, String filename){ System.out.println("Wrote code snippet to " + filename); } public static double reverseLight(double L) { - L = Math.sqrt(L); - final double shape = 1.55, turning = 0.95; - final double d = turning - L; - double r; - if(d < 0) - r = ((1.0 - turning) * (L - 1.0)) / (1.0 - (L + shape * d)) + 1.0; - else - r = (turning * L) / (1e-50 + (L + shape * d)); - return r; + return Math.pow(L, 2.0/3.0); } +// public static double reverseLight(double L) { +// L = Math.sqrt(L); +// final double shape = 1.55, turning = 0.95; +// final double d = turning - L; +// double r; +// if(d < 0) +// r = ((1.0 - turning) * (L - 1.0)) / (1.0 - (L + shape * d)) + 1.0; +// else +// r = (turning * L) / (1e-50 + (L + shape * d)); +// return r; +// } /** * Returns true if the given Oklab values are valid to convert losslessly back to RGBA.