From 3d52d5db159959486ec8a3fed18eaa5a2b5414d8 Mon Sep 17 00:00:00 2001 From: carm Date: Sun, 27 Nov 2022 23:32:39 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E4=BB=A5=E4=BE=BF=E9=98=85=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/carm/lib/easyplugin/utils/ColorParser.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/base/main/src/main/java/cc/carm/lib/easyplugin/utils/ColorParser.java b/base/main/src/main/java/cc/carm/lib/easyplugin/utils/ColorParser.java index 3f86e7d..5f6c188 100644 --- a/base/main/src/main/java/cc/carm/lib/easyplugin/utils/ColorParser.java +++ b/base/main/src/main/java/cc/carm/lib/easyplugin/utils/ColorParser.java @@ -99,20 +99,19 @@ public class ColorParser { String[] characters = text.split(""); int step = characters.length; // 变换次数 - int[] directions = new int[]{ - startColor.getRed() < endColor.getRed() ? 1 : -1, - startColor.getGreen() < endColor.getGreen() ? 1 : -1, - startColor.getBlue() < endColor.getBlue() ? 1 : -1 - }; // 决定每种颜色变换的方向 + // 决定每种颜色变换的方向 + int rDirection = startColor.getRed() < endColor.getRed() ? 1 : -1; + int gDirection = startColor.getGreen() < endColor.getGreen() ? 1 : -1; + int bDirection = startColor.getBlue() < endColor.getBlue() ? 1 : -1; int rStep = Math.abs(startColor.getRed() - endColor.getRed()) / (step - 1); int gStep = Math.abs(startColor.getGreen() - endColor.getGreen()) / (step - 1); int bStep = Math.abs(startColor.getBlue() - endColor.getBlue()) / (step - 1); String[] hexes = IntStream.range(0, step).mapToObj(i -> colorToHex( - startColor.getRed() + rStep * i * directions[0], - startColor.getGreen() + gStep * i * directions[1], - startColor.getBlue() + bStep * i * directions[2] + startColor.getRed() + rStep * i * rDirection, + startColor.getGreen() + gStep * i * gDirection, + startColor.getBlue() + bStep * i * bDirection )).toArray(String[]::new); return IntStream.range(0, characters.length)