Package com.atlassian.confluence.util
Class ColourUtils
java.lang.Object
com.atlassian.confluence.util.ColourUtils
Color manipulation utilities
- Since:
- 5.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
colorToHex
(Color color) Returns hexadecimal value for a color.static Color
Returns a color darker than the given colorstatic String
Returns a color darker than the given colorstatic Color
desaturate
(Color color, double amount) Returns a color less saturate than the given colorstatic String
desaturate
(String hexColor, double amount) Returns a color less saturate than the given colorstatic String
findClosetColor
(String hexColor, Set<String> colorList) static String
getColorWithInvertedLightness
(String hexColor) Given a HEX color, return a HEX value that is the given color at an inverse lightness percentage.static String
getFallbackColorForDesignTokenColor
(String styleValue) static Color
hexToColor
(String hexColor) Given a color hexadecimal value returns a Color object.static int[]
hslToRgb
(float[] hsl) Returns the color value in the RGB spacestatic boolean
isValidColor
(String color) static Color
Returns a color lighter than the given colorstatic String
Returns a color lighter than the given colorstatic Color
Returns a color more saturated than the given colorstatic String
Returns a color more saturated than the given colorstatic float[]
Returns the color value in the HSL space
-
Field Details
-
TEXT_COLOR_RGB_PATTERN
-
VALID_RGB_COLOR_PATTERN
-
VALID_RGBA_COLOR_PATTERN
-
VALID_HEX_COLOR_PATTERN
-
VALID_HSL_COLOR_PATTERN
-
VALID_HSLA_COLOR_PATTERN
-
VALID_COLOR_NAME_PATTERN
-
TEXT_COLOR_DESIGN_TOKEN_PATTERN
-
EPSILON
-
-
Constructor Details
-
ColourUtils
public ColourUtils()
-
-
Method Details
-
colorToHex
Returns hexadecimal value for a color.- Parameters:
color
- color object- Returns:
- color hexadecimal value
-
hexToColor
Given a color hexadecimal value returns a Color object.- Parameters:
hexColor
- color hexadecimal value- Returns:
- Color object
-
darken
Returns a color darker than the given color- Parameters:
hexColor
- color hexadecimal valueamount
- value between 0 and 100.- Returns:
- darker color
-
lighten
Returns a color lighter than the given color- Parameters:
hexColor
- color hexadecimal valueamount
- value between 0 and 100.- Returns:
- lighter color
-
saturate
Returns a color more saturated than the given color- Parameters:
hexColor
- color hexadecimal valueamount
- value between 0 and 100.- Returns:
- saturated color
-
desaturate
Returns a color less saturate than the given color- Parameters:
hexColor
- color hexadecimal valueamount
- value between 0 and 100.- Returns:
- desaturated color
-
darken
Returns a color darker than the given color- Parameters:
color
- color onjectamount
- value between 0 and 100.- Returns:
- darker color
-
lighten
Returns a color lighter than the given color- Parameters:
color
- color objectamount
- value between 0 and 100.- Returns:
- lighter color
-
desaturate
Returns a color less saturate than the given color- Parameters:
color
- color objectamount
- value between 0 and 100.- Returns:
- desaturated color
-
saturate
Returns a color more saturated than the given color- Parameters:
color
- color objectamount
- value between 0 and 100.- Returns:
- saturated color
-
toHSL
Returns the color value in the HSL space- Parameters:
color
- color object- Returns:
- { hue, saturation, lightness, alpha }
-
hslToRgb
public static int[] hslToRgb(float[] hsl) Returns the color value in the RGB space- Parameters:
hsl
- color in hsl space- Returns:
- rgb values [0, 255]
-
getColorWithInvertedLightness
Given a HEX color, return a HEX value that is the given color at an inverse lightness percentage.- Parameters:
hexColor
- a HEX value that whose lightness will be inverted.- Returns:
- a hex color with inverted lightness.
- Since:
- 8.9.0
-
findClosetColor
- Parameters:
hexColor
- the hex color valuecolorList
- list of all color which have design-token map value.- Returns:
- closest hex color
- Since:
- 8.9.0
-
getFallbackColorForDesignTokenColor
- Parameters:
styleValue
- the style attribute that may contain design token color- Returns:
- the fallback color value of design token color or null
- Since:
- 8.9.0
-
isValidColor
-