Hex color for nc

Made sure that hex colors are cleared correctly.
This commit is contained in:
William Bergh
2020-07-31 21:46:44 +02:00
parent e25e785c26
commit 80e39d3db1
2 changed files with 110 additions and 7 deletions

View File

@ -771,6 +771,21 @@ public class FUtil
return colors;
}
/**
* Detects if two colors are alike.
* @param first The first Color to check.
* @param second The second Color to check.
* @param tresHold The maximum allowed difference between the colors.
* @return Returns true if the colors are alike.
*/
public static boolean colorClose(Color first, Color second, int tresHold)
{
int redDelta = Math.abs(first.getRed() - second.getRed());
int greenDelta = Math.abs(first.getGreen() - second.getGreen());
int blueDelta = Math.abs(first.getBlue() - second.getBlue());
return (redDelta + greenDelta + blueDelta) < tresHold;
}
public static Color fromAWT(java.awt.Color color)
{
return Color.fromRGB(color.getRed(), color.getGreen(), color.getBlue());