From 57d9a415fceeae7ccd51f52d6ba99d6a1586d76d Mon Sep 17 00:00:00 2001 From: Looly Date: Thu, 8 Aug 2024 16:32:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E5=AD=97=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E4=B8=8E=E8=83=8C=E6=99=AF=E9=A2=9C=E8=89=B2=E8=89=B2?= =?UTF-8?q?=E5=B7=AE=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../cn/hutool/captcha/CaptchaUtilTest.java | 8 +++--- .../java/cn/hutool/core/img/ColorUtil.java | 26 +++++++++---------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38f80ae28..7474d81b4 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ * 【http 】 CompressUtil.createExtractor支持tgz自动识别(pr#3674@Github) * 【poi 】 ExcelWriter.autoSizeColumn增加可选widthRatio参数,可配置中文字符宽度倍数(pr#3689@Github) * 【mail 】 MailAccount增加自定义参数支持(issue#3687@Github) +* 【mail 】 增加文字颜色与背景颜色色差设置(pr#1252@gitee) ### 🐞Bug修复 * 【core 】 修复因RFC3986理解有误导致的UrlPath处理冒号转义问题(issue#IAAE88@Gitee) diff --git a/hutool-captcha/src/test/java/cn/hutool/captcha/CaptchaUtilTest.java b/hutool-captcha/src/test/java/cn/hutool/captcha/CaptchaUtilTest.java index f3c03eab5..f2ac31734 100755 --- a/hutool-captcha/src/test/java/cn/hutool/captcha/CaptchaUtilTest.java +++ b/hutool-captcha/src/test/java/cn/hutool/captcha/CaptchaUtilTest.java @@ -1,7 +1,5 @@ package cn.hutool.captcha; -import cn.hutool.captcha.generator.CodeGenerator; -import cn.hutool.captcha.generator.MathGenerator; import cn.hutool.core.img.GraphicsUtil; import cn.hutool.core.img.ImgUtil; import cn.hutool.core.util.ObjectUtil; @@ -9,7 +7,10 @@ import cn.hutool.core.util.RandomUtil; import org.junit.Ignore; import org.junit.Test; -import java.awt.*; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; import java.awt.image.BufferedImage; import java.util.concurrent.ThreadLocalRandom; @@ -33,6 +34,7 @@ public class CaptchaUtilTest { } static class TestLineCaptcha extends AbstractCaptcha{ + private static final long serialVersionUID = -558846929114465692L; public TestLineCaptcha(int width, int height, int codeCount, int interfereCount) { super(width, height, codeCount, interfereCount); diff --git a/hutool-core/src/main/java/cn/hutool/core/img/ColorUtil.java b/hutool-core/src/main/java/cn/hutool/core/img/ColorUtil.java index 969cf1d05..71355d9a4 100644 --- a/hutool-core/src/main/java/cn/hutool/core/img/ColorUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/img/ColorUtil.java @@ -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;