From 831b3d851a9f2bb52b1dd1f101728b14c8f7bf07 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Mon, 3 Jan 2022 19:04:28 +0100 Subject: [PATCH] ColorFunctions: javadoc added; do not mix colors if they are equal --- .../java/com/formdev/flatlaf/util/ColorFunctions.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/ColorFunctions.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/ColorFunctions.java index 2b5794a6..913cf6a1 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/ColorFunctions.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/ColorFunctions.java @@ -122,6 +122,8 @@ public class ColorFunctions return color1; if( weight <= 0 ) return color2; + if( color1.equals( color2 ) ) + return color1; int r1 = color1.getRed(); int g1 = color1.getGreen(); @@ -196,6 +198,9 @@ public class ColorFunctions : (float) Math.pow( (value + 0.055) / 1.055, 2.4 ); } + /** + * Applies the given color functions to the given color and returns the new color. + */ public static Color applyFunctions( Color color, ColorFunction... functions ) { // if having only a single function of type Mix, then avoid four unnecessary conversions: // 1. RGB to HSL in this method @@ -221,6 +226,9 @@ public class ColorFunctions return HSLColor.toRGB( hsla[0], hsla[1], hsla[2], hsla[3] / 100 ); } + /** + * Clamps the given value between 0 and 100. + */ public static float clamp( float value ) { return (value < 0) ? 0