增加文字颜色与背景颜色色差设置

This commit is contained in:
Looly
2024-08-08 16:32:37 +08:00
parent d730347399
commit 57d9a415fc
3 changed files with 19 additions and 16 deletions

View File

@@ -169,16 +169,6 @@ public class ColorUtil {
return new Color(r, g, b);
}
/**
* 生成随机颜色
*
* @return 随机颜色
* @since 3.1.2
*/
public static Color randomColor() {
return randomColor(null);
}
/**
* 生成随机颜色,与指定颜色有一定的区分度
*
@@ -188,13 +178,23 @@ public class ColorUtil {
* @since 5.8.30
*/
public static Color randomColor(Color compareColor,int minDistance) {
Color color = randomColor(null);
Color color = randomColor();
while (computeColorDistance(compareColor,color) < minDistance) {
color = randomColor(null);
color = randomColor();
}
return color;
}
/**
* 生成随机颜色
*
* @return 随机颜色
* @since 3.1.2
*/
public static Color randomColor() {
return randomColor(null);
}
/**
* 计算两个颜色之间的色差,按三维坐标距离计算
*
@@ -283,7 +283,7 @@ public class ColorUtil {
* @return 是否匹配
*/
private static boolean matchFilters(int r, int g, int b, int[]... rgbFilters) {
if (rgbFilters != null && rgbFilters.length > 0) {
if (ArrayUtil.isNotEmpty(rgbFilters)) {
for (int[] rgbFilter : rgbFilters) {
if (r == rgbFilter[0] && g == rgbFilter[1] && b == rgbFilter[2]) {
return true;