mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
ColorFunctions: improved performance of mix(), tint() and shade() color functions
(used UIDefaultsDump to verify whether results are the same as before)
This commit is contained in:
@@ -26,6 +26,17 @@ import java.awt.Color;
|
||||
public class ColorFunctions
|
||||
{
|
||||
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
|
||||
// 2. HSL to RGB in Mix.apply()
|
||||
// mix
|
||||
// 3. RGB to HSL in Mix.apply()
|
||||
// 4. HSL to RGB in this method
|
||||
if( functions.length == 1 && functions[0] instanceof Mix ) {
|
||||
Mix mixFunction = (Mix) functions[0];
|
||||
return mix( color, mixFunction.color2, mixFunction.weight / 100 );
|
||||
}
|
||||
|
||||
// convert RGB to HSL
|
||||
float[] hsl = HSLColor.fromRGB( color );
|
||||
float alpha = color.getAlpha() / 255f;
|
||||
|
||||
Reference in New Issue
Block a user