mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-02 09:09:55 +01:00
parent
c5ba1864d1
commit
fd529ce967
@ -98,13 +98,16 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check by the greatest diff of the 3 values
|
// Check by the greatest diff of the 3 values
|
||||||
int rDiff = Math.abs(color.r - r);
|
int rAverage = (color.r + r) / 2;
|
||||||
int gDiff = Math.abs(color.g - g);
|
int rDiff = color.r - r;
|
||||||
int bDiff = Math.abs(color.b - b);
|
int gDiff = color.g - g;
|
||||||
int maxDiff = Math.max(Math.max(rDiff, gDiff), bDiff);
|
int bDiff = color.b - b;
|
||||||
if (closest == null || maxDiff < smallestDiff) {
|
int diff = ((2 + (rAverage >> 8)) * rDiff * rDiff)
|
||||||
|
+ (4 * gDiff * gDiff)
|
||||||
|
+ ((2 + ((255 - rAverage) >> 8)) * bDiff * bDiff);
|
||||||
|
if (closest == null || diff < smallestDiff) {
|
||||||
closest = color;
|
closest = color;
|
||||||
smallestDiff = maxDiff;
|
smallestDiff = diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return closest.colorName;
|
return closest.colorName;
|
||||||
|
Loading…
Reference in New Issue
Block a user