Class ColorFunctions
java.lang.Object
com.formdev.flatlaf.util.ColorFunctions
Functions that modify colors.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classSet the alpha of a color.static classSet the hue, saturation, luminance or alpha of a color.static classIncrease or decrease hue, saturation, luminance or alpha of a color in the HSL color space by an absolute or relative amount.static classMix two colors usingmix(Color, Color, float).static classMix two colors usingmix(Color, Color, float). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ColorapplyFunctions(Color color, ColorFunctions.ColorFunction... functions) Applies the given color functions to the given color and returns the new color.static floatclamp(float value) Clamps the given value between 0 and 100.static ColorDecrease the lightness of a color in HSL color space by an absolute amount.static Colordesaturate(Color color, float amount) Decrease the saturation of a color in HSL color space by an absolute amount.static ColorSet the opacity (alpha) of a color.private static floatgammaCorrection(float value) private static ColorhslIncreaseDecrease(Color color, float amount, int hslIndex, boolean increase) static ColorIncrease the lightness of a color in HSL color space by an absolute amount.static floatCalculates the luma (perceptual brightness) of the given color.static ColorReturns a color that is a mixture of two colors.static ColorIncrease the saturation of a color in HSL color space by an absolute amount.static ColorMix color with black, which makes the color darker.static ColorRotate the hue angle (0-360) of a color in HSL color space in either direction.static ColorMix color with white, which makes the color brighter.
-
Constructor Details
-
ColorFunctions
public ColorFunctions()
-
-
Method Details
-
lighten
Increase the lightness of a color in HSL color space by an absolute amount.Consider using
tint(Color, float)as alternative.- Parameters:
color- base coloramount- the amount (in range 0-1) that is added to the lightness- Returns:
- new color
- Since:
- 2
-
darken
Decrease the lightness of a color in HSL color space by an absolute amount.Consider using
shade(Color, float)as alternative.- Parameters:
color- base coloramount- the amount (in range 0-1) that is subtracted from the lightness- Returns:
- new color
- Since:
- 2
-
saturate
-
desaturate
-
spin
-
hslIncreaseDecrease
-
fade
-
mix
Returns a color that is a mixture of two colors.This can be used to animate a color change from
color1tocolor2by invoking this method multiple times with growingweight(from 0 to 1).- Parameters:
color1- first colorcolor2- second colorweight- the weight (in range 0-1) to mix the two colors. Larger weight uses more of first color, smaller weight more of second color.- Returns:
- mixture of colors
-
tint
Mix color with white, which makes the color brighter. This is the same asmix(Color, Color, float)(Color.white, color, weight).- Parameters:
color- second colorweight- the weight (in range 0-1) to mix the two colors. Larger weight uses more of first color, smaller weight more of second color.- Returns:
- mixture of colors
- Since:
- 2
-
shade
Mix color with black, which makes the color darker. This is the same asmix(Color, Color, float)(Color.black, color, weight).- Parameters:
color- second colorweight- the weight (in range 0-1) to mix the two colors. Larger weight uses more of first color, smaller weight more of second color.- Returns:
- mixture of colors
- Since:
- 2
-
luma
-
gammaCorrection
private static float gammaCorrection(float value) -
applyFunctions
Applies the given color functions to the given color and returns the new color. -
clamp
public static float clamp(float value) Clamps the given value between 0 and 100.
-