Upload files to "src/openonyx/theme/internal"

This commit is contained in:
winterflyt committed 2026-11-30 06:15:14 +02:00
1 parent 5738e90e8a
commit a6ef66bbfb
5 files changed
+647

No files matched your search

+109
View File
@@ -0,0 +1,109 @@
package openonyx.theme.internal;
public final class Cam16 {
public final double I;
public final double d;
public final double i;
public final double f;
public final double H;
public final double e;
public static Cam16 L(int i) {
return L(ColorUtils.toXyz(ix), ViewingConditions.INSTANCE);
}
private static double d(double d, double e) {
ex = Math.pow(ex * Math.abs(dx) / 100.0, 0.42);
return Math.signum(dx) * 400.0 * ex / (ex + 27.13);
}
public int L(ViewingConditions viewingConditions) {
double dx = this.d != 0.0 && this.e != 0.0 ? this.d / Math.sqrt(this.e / 100.0) : 0.0;
dx = Math.pow(dx / Math.pow(1.64 - Math.pow(0.29, viewingConditions.i), 0.73), 1.1111111111111112);
double ex = Math.toRadians(this.I);
double fx = 0.25 * (Math.cos(ex + 2.0) + 3.8);
double g = viewingConditions.j * Math.pow(this.e / 100.0, 1.0 / viewingConditions.h / viewingConditions.I);
fx = fx * 3846.153846153846 * viewingConditions.d * viewingConditions.f;
g /= viewingConditions.L;
double h = Math.sin(ex);
ex = Math.cos(ex);
double ix;
ex = (ix = 23.0 * (g + 0.305) * dx / (23.0 * fx + 11.0 * dx * ex + 108.0 * dx * h)) * ex;
dx = ix * h;
fx = (460.0 * g + 451.0 * ex + 288.0 * dx) / 1403.0;
h = (460.0 * g - 891.0 * ex - 261.0 * dx) / 1403.0;
dx = (460.0 * g - 220.0 * ex - 6300.0 * dx) / 1403.0;
ex = L(fx, viewingConditions.H) / viewingConditions.m[0];
fx = L(h, viewingConditions.H) / viewingConditions.m[1];
dx = L(dx, viewingConditions.H) / viewingConditions.m[2];
g = 1.86206786 * ex - 1.01125463 * fx + 0.14918677 * dx;
h = 0.38752654 * ex + 0.62144744 * fx - 0.00897398 * dx;
dx = -0.0158415 * ex - 0.03412294 * fx + 1.04996444 * dx;
return ColorUtils.argbFromXyz(g, h, dx);
}
public static Cam16 L(double[] d, ViewingConditions viewingConditions) {
double ex = dx[0];
double fx = dx[1];
double g = dx[2];
double h = 0.401288 * ex + 0.650173 * fx - 0.051461 * g;
double ix = -0.250268 * ex + 1.204414 * fx + 0.045854 * g;
ex = -0.002079 * ex + 0.048952 * fx + 0.953127 * g;
fx = d(viewingConditions.m[0] * h, viewingConditions.H);
g = d(viewingConditions.m[1] * ix, viewingConditions.H);
ex = d(viewingConditions.m[2] * ex, viewingConditions.H);
h = (11.0 * fx - 12.0 * g + ex) / 11.0;
ix = (fx + g - 2.0 * ex) / 9.0;
double j = (20.0 * fx + 20.0 * g + 21.0 * ex) / 20.0;
ex = (40.0 * fx + 20.0 * g + ex) / 20.0;
g = Math.toRadians(fx = ColorUtils.sanitizeDegrees(Math.toDegrees(Math.atan2(ix, h))));
ex *= viewingConditions.L;
ex = 100.0 * Math.pow(ex / viewingConditions.j, viewingConditions.h * viewingConditions.I);
double k = fx < 20.14 ? fx + 360.0 : fx;
k = 0.25 * (Math.cos(Math.toRadians(k) + 2.0) + 3.8);
double l;
ix = (
l = Math.pow(3846.153846153846 * k * viewingConditions.d * viewingConditions.f * Math.hypot(h, ix) / (j + 0.305), 0.9)
* Math.pow(1.64 - Math.pow(0.29, viewingConditions.i), 0.73)
* Math.sqrt(ex / 100.0)
)
* viewingConditions.l;
j = 1.7 * ex / (1.0 + 0.007 * ex);
ix = 43.859649122807014 * Math.log1p(0.0228 * ix);
return new Cam16(fx, l, ex, j, ix * Math.cos(g), ix * Math.sin(g));
}
public double L(Cam16 cam161) {
double dx = this.f - cam161.f;
double ex = this.i - cam161.i;
double fx = this.H - cam161.H;
return 1.41 * Math.pow(Math.sqrt(dx * dx + ex * ex + fx * fx), 0.63);
}
private Cam16(double d, double e, double f, double g, double h, double i) {
this.I = dx;
this.d = ex;
this.e = fx;
this.f = g;
this.i = h;
this.H = ix;
}
private static double L(double d, double e) {
double fx = Math.max(0.0, 27.13 * Math.abs(dx) / (400.0 - Math.abs(dx)));
return Math.signum(dx) * (100.0 / ex) * Math.pow(fx, 2.380952380952381);
}
public static Cam16 L(double d, double e, double f) {
ViewingConditions viewingConditions = ViewingConditions.INSTANCE;
double g = ex * viewingConditions.l;
double h = 1.7 * dx / (1.0 + 0.007 * dx);
g = 43.859649122807014 * Math.log1p(0.0228 * g);
double ix = Math.toRadians(fx);
return new Cam16(fx, ex, dx, h, g * Math.cos(ix), g * Math.sin(ix));
}
public int L() {
return this.L(ViewingConditions.INSTANCE);
}
}
+233
View File
@@ -0,0 +1,233 @@
package openonyx.theme.internal;
public final class ColorUtils {
private static final double[][] f;
public static final double[] H;
private static final double[][] e;
public static double yFromLstar(double d) {
return 100.0 * i((d + 16.0) / 116.0);
}
public static double lstarFromArgb(int i) {
return lstarFromY(toXyz(i)[1]);
}
public static int withAlpha(int i, int j) {
return i & 16777215 | (j & 0xFF) << 24;
}
public static double linearized(int i) {
double d;
return (d = i / 255.0) <= 0.040449936 ? d / 12.92 * 100.0 : Math.pow((d + 0.055) / 1.055, 2.4) * 100.0;
}
public static int red(int i) {
return i >> 16 & 0xFF;
}
public static int hsvToArgb(float f, float g, float h, int i) {
float j = fx;
fx = (float)sanitizeDegrees(j) / 60.0F;
float n;
float k = (n = h * Math.clamp(g, 0.0F, 1.0F)) * (1.0F - Math.abs(fx % 2.0F - 1.0F));
h -= n;
float l;
float m;
return argb(switch ((int)fx % 6) {
case 0 -> {
while (false) {
}
fx = n;
l = k;
m = 0.0F;
yield i;
}
case 1 -> {
fx = k;
l = n;
m = 0.0F;
yield i;
}
case 2 -> {
fx = 0.0F;
l = n;
m = k;
yield i;
}
case 3 -> {
fx = 0.0F;
l = k;
m = n;
yield i;
}
case 4 -> {
fx = k;
l = 0.0F;
m = n;
yield i;
}
default -> {
fx = n;
l = 0.0F;
m = k;
yield i;
}
}, Math.round((fx + h) * 255.0F), Math.round((l + h) * 255.0F), Math.round((m + h) * 255.0F));
}
private static double i(double d) {
double ex = 0.008856451679035631;
double fx = 903.2962962962963;
double g;
return (g = d * d * d) > ex ? g : (116.0 * d - 16.0) / fx;
}
public static int argb(int i, int j, int k, int l) {
return (i & 0xFF) << 24 | (j & 0xFF) << 16 | (k & 0xFF) << 8 | l & 0xFF;
}
public static double sanitizeDegrees(double d) {
double ex;
return (ex = d % 360.0) < 0.0 ? ex + 360.0 : ex;
}
public static int delinearized(double d) {
double ex;
double fx = (ex = d / 100.0) <= 0.0031308 ? ex * 12.92 : 1.055 * Math.pow(ex, 0.4166666666666667) - 0.055;
return Math.clamp(Math.round(fx * 255.0), 0, 255);
}
public static int argbFromLstar(double d) {
int i = delinearized(yFromLstar(d));
return argb(255, i, i, i);
}
public static double lstarFromY(double d) {
return L(d / 100.0) * 116.0 - 16.0;
}
public static int withAlpha(int i, float f) {
return withAlpha(i, Math.round(Math.clamp(fx, 0.0F, 1.0F) * 255.0F));
}
public static int green(int i) {
return i >> 8 & 0xFF;
}
public static double[] toXyz(int i) {
double d = linearized(red(i));
double ex = linearized(green(i));
double fx = linearized(blue(i));
double[] g = new double[3];
boolean bl = true;
g[0] = f[0][0] * d + f[0][1] * ex + f[0][2] * fx;
g[1] = f[1][0] * d + f[1][1] * ex + f[1][2] * fx;
g[2] = f[2][0] * d + f[2][1] * ex + f[2][2] * fx;
return g;
}
private static double L(double d) {
double ex = 0.008856451679035631;
double fx = 903.2962962962963;
return d > ex ? Math.cbrt(d) : (fx * d + 16.0) / 116.0;
}
static {
double[] l = new double[3];
boolean bl = true;
l[0] = 95.047;
l[1] = 100.0;
l[2] = 108.883;
H = l;
double[][] d = new double[3][];
bl = true;
double[] fx = new double[3];
boolean bl1 = true;
fx[0] = 0.41233895;
fx[1] = 0.35762064;
fx[2] = 0.18051042;
d[0] = fx;
double[] g = new double[3];
bl1 = true;
g[0] = 0.2126;
g[1] = 0.7152;
g[2] = 0.0722;
d[1] = g;
double[] h = new double[3];
bl1 = true;
h[0] = 0.01932141;
h[1] = 0.11916382;
h[2] = 0.95034478;
d[2] = h;
f = d;
double[][] ex = new double[3][];
bl = true;
double[] i = new double[3];
bl1 = true;
i[0] = 3.2413774792388685;
i[1] = -1.5376652402851851;
i[2] = -0.49885366846268053;
ex[0] = i;
double[] j = new double[3];
bl1 = true;
j[0] = -0.9691452513005321;
j[1] = 1.8758853451067872;
j[2] = 0.04156585616912061;
ex[1] = j;
double[] k = new double[3];
bl1 = true;
k[0] = 0.05562093689691305;
k[1] = -0.20395524564742123;
k[2] = 1.0571799111220335;
ex[2] = k;
e = ex;
}
public static int alpha(int i) {
return i >>> 24;
}
private ColorUtils() {
}
public static int blue(int i) {
return i & 0xFF;
}
public static float[] toRgbFloats(int i) {
int j = i;
float k = red(j) / 255.0F;
float h = green(j) / 255.0F;
float g = blue(j) / 255.0F;
float fx = Math.max(k, Math.max(h, g));
float m = Math.min(k, Math.min(h, g));
float n = fx - m;
float l = 0.0F;
if (n > 0.0F) {
if (fx == k) {
l = 60.0F * ((h - g) / n % 6.0F);
} else if (fx == h) {
l = 60.0F * ((g - k) / n + 2.0F);
} else {
l = 60.0F * ((k - h) / n + 4.0F);
}
}
float[] o = new float[3];
boolean bl = true;
o[0] = (float)sanitizeDegrees(l);
o[1] = fx == 0.0F ? 0.0F : n / fx;
o[2] = fx;
return o;
}
public static int argbFromXyz(double d, double e, double f) {
int j = delinearized(e[0][0] * d + e[0][1] * ex + e[0][2] * fx);
int k = delinearized(e[1][0] * d + e[1][1] * ex + e[1][2] * fx);
int i = delinearized(e[2][0] * d + e[2][1] * ex + e[2][2] * fx);
return argb(255, j, k, i);
}
}
+155
View File
@@ -0,0 +1,155 @@
package openonyx.theme.internal;
public final class Hct {
private final double i;
private final double f;
private final int H;
private final double e;
public Hct D(double d) {
return L(this.i, this.f, d);
}
public Hct d(double d) {
return L(this.i, d, this.e);
}
private Hct(double d, double e, double f, int i) {
this.i = d;
this.f = ex;
this.e = fx;
this.H = ix;
}
public static Hct L(double d, double e, double f) {
return L(L(d, ex, fx));
}
public double D() {
return this.i;
}
public double d() {
return this.e;
}
private static Cam16 L(double d, double e, double f) {
double g = 0.0;
double h = 100.0;
double ix = 1000.0;
Cam16 cam16 = null;
while (Math.abs(g - h) > 0.01) {
double j;
int k;
double l = ColorUtils.lstarFromArgb(k = Cam16.L(j = g + (h - g) / 2.0, ex, d).L());
if (Math.abs(fx - l) < 0.2) {
Cam16 cam161;
Cam16 cam162 = cam161 = Cam16.L(k);
double m;
if ((m = cam162.L(Cam16.L(cam162.e, ex, d))) <= 1.0 && m <= ix) {
ix = m;
cam16 = cam161;
}
}
if (l < fx) {
g = j;
} else {
h = j;
}
}
return cam16;
}
public double L() {
return this.f;
}
private static int L(double d, double e, double f) {
if (!(ex < 1.0) && Math.round(fx) > 0L && Math.round(fx) < 100L) {
d = ColorUtils.sanitizeDegrees(d);
double g = 0.0;
double h = ex;
ex = ex;
boolean bl = true;
Cam16 cam16 = null;
double ix = g;
while (Math.abs(ix - h) >= 0.4) {
Cam16 cam161 = L(d, ex, fx);
if (bl) {
if (cam161 != null) {
return cam161.L();
}
bl = false;
ex = g + (h - g) / 2.0;
ix = g;
} else {
if (cam161 == null) {
h = ex;
ix = g;
} else {
cam16 = cam161;
ix = g = ex;
}
ex = ix + (h - g) / 2.0;
ix = g;
}
}
return cam16 == null ? ColorUtils.argbFromLstar(fx) : cam16.L();
} else {
return ColorUtils.argbFromLstar(fx);
}
}
public int L() {
return this.H;
}
public static String decrypt(String string) {
String string1 = string;
int n = --5 << 4 ^ 15;
String string2;
int p = (string2 = string1).length();
char[] ex = new char[p];
boolean bl = true;
int j;
int o = j = p - 1;
char[] c = ex;
byte b = 8;
byte d = 32;
int k = o;
int ix = n;
while (k >= 0) {
int l = j;
int m = string2.charAt(j);
j--;
c[l] = (char)(m ^ ix);
if (j < 0) {
break;
}
m = j--;
c[m] = (char)(string2.charAt(m) ^ b);
k = j;
}
return new String(c);
}
public static Hct L(int i) {
int j = ix;
Cam16 cam16 = Cam16.L(j);
return new Hct(cam16.I, cam16.d, ColorUtils.lstarFromArgb(j), j | 0xFF000000);
}
public Hct L(double d) {
return L(d, this.f, this.e);
}
}
@@ -0,0 +1,81 @@
package openonyx.theme.internal;
import java.util.HashMap;
import java.util.Map;
public final class TonalPalette {
private final double f;
private final double H;
private final Map<Integer, Integer> integerMap = new HashMap<>();
public Hct L(double d) {
return Hct.L(this.f, this.H, d);
}
public static TonalPalette L(double d, double e) {
return new TonalPalette(d, e);
}
public static TonalPalette L(int i) {
int j = i;
Hct hct = Hct.L(j);
return new TonalPalette(hct.D(), hct.L());
}
public int L(double d) {
return Hct.L(this.f, this.H, d).L();
}
private TonalPalette(double d, double e) {
this.f = d;
this.H = e;
}
public double d() {
return this.H;
}
public Map<Integer, Integer> getIntegerMap() {
return this.integerMap;
}
public int L(int i) {
return this.integerMap.computeIfAbsent(i, integer -> Hct.L(this.f, this.H, integer.intValue()).L());
}
public static String decrypt(String string) {
String string1 = string;
int m = (5 >> 1 ^ 5) << 4 ^ 6;
int o = 4 << 4 ^ 2 << 2 ^ 3;
String string2;
int p = (string2 = string1).length();
char[] d = new char[p];
boolean bl = true;
int j;
int k = j = p - 1;
char[] c = d;
int i = o;
m = k;
byte b = 49;
while (m >= 0) {
int n = j;
int l = string2.charAt(j);
j--;
c[n] = (char)(l ^ b);
if (j < 0) {
break;
}
l = j--;
c[l] = (char)(string2.charAt(l) ^ i);
m = j;
}
return new String(c);
}
public double L() {
return this.f;
}
}
@@ -0,0 +1,69 @@
package openonyx.theme.internal;
public final class ViewingConditions {
public final double L;
public final double j;
public final double[] m;
public final double h;
public final double l;
public final double I;
public final double d;
public final double i;
public final double f;
public final double H;
public static final ViewingConditions INSTANCE = L(ColorUtils.H, 63.66197723675813 * ColorUtils.yFromLstar(50.0) / 100.0, 50.0, 2.0, false);
private static double L(double d, double e, double f) {
return (1.0 - fx) * dx + fx * e;
}
public static ViewingConditions L(double[] d, double e, double f, double g, boolean bl) {
double hx = dx[0] * 0.401288 + dx[1] * 0.650173 + dx[2] * -0.051461;
double ix = dx[0] * -0.250268 + dx[1] * 1.204414 + dx[2] * 0.045854;
double jx = dx[0] * -0.002079 + dx[1] * 0.048952 + dx[2] * 0.953127;
double o;
double k = (o = 0.8 + g / 10.0) >= 0.9 ? L(0.59, 0.69, (o - 0.9) * 10.0) : L(0.525, 0.59, (o - 0.8) * 10.0);
double lx = bl ? 1.0 : o * (1.0 - 0.2777777777777778 * Math.exp((-e - 42.0) / 92.0));
lx = Math.clamp(lx, 0.0, 1.0);
double[] s = new double[3];
boolean bl1 = true;
s[0] = lx * (100.0 / hx) + 1.0 - lx;
s[1] = lx * (100.0 / ix) + 1.0 - lx;
s[2] = lx * (100.0 / jx) + 1.0 - lx;
double[] p = s;
double r = lx = 1.0 / (5.0 * e + 1.0);
lx = r * r * lx * lx;
double mx = 1.0 - lx;
e = lx * e + 0.1 * mx * mx * Math.cbrt(5.0 * e);
fx = ColorUtils.yFromLstar(fx) / dx[1];
lx = 1.48 + Math.sqrt(fx);
mx = 0.725 / Math.pow(fx, 0.2);
s = new double[3];
bl1 = true;
s[0] = Math.pow(e * p[0] * hx / 100.0, 0.42);
s[1] = Math.pow(e * p[1] * ix / 100.0, 0.42);
s[2] = Math.pow(e * p[2] * jx / 100.0, 0.42);
double[] q = s;
s = new double[3];
bl1 = true;
s[0] = 400.0 * q[0] / (q[0] + 27.13);
s[1] = 400.0 * q[1] / (q[1] + 27.13);
s[2] = 400.0 * q[2] / (q[2] + 27.13);
double[] n = s;
hx = (2.0 * n[0] + n[1] + 0.05 * n[2]) * mx;
return new ViewingConditions(fx, hx, mx, mx, k, o, e, Math.pow(e, 0.25), lx, p);
}
private ViewingConditions(double d, double e, double f, double g, double h, double i, double j, double k, double l, double[] m) {
this.i = dx;
this.j = e;
this.L = fx;
this.f = g;
this.h = hx;
this.d = ix;
this.H = jx;
this.l = k;
this.I = lx;
this.m = mx;
}
}