Package com.dianxin.tori.base.utils
Class ColorUtils
java.lang.Object
com.dianxin.tori.base.utils.ColorUtils
Utility class for color operations, hex transformations, and randomized palettes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ColorParses a hexadecimal string into aColorobject.static @NotNull Colorrandom()Generates a completely randomized RGBColor.static @NotNull ColorrandomColorRestricted(@NotNull String minHex, @NotNull String maxHex) Generates a randomized color bounded between two hexadecimal thresholds per channel.static @NotNull StringGenerates a randomized uppercase Hex string representation (e.g., "#FFAABB").static @NotNull StringtoHexString(@NotNull Color color) Converts aColorobject into an uppercase Hex string (#RRGGBB).
-
Method Details
-
random
Generates a completely randomized RGBColor.- Returns:
- a random color instance
-
randomHexString
Generates a randomized uppercase Hex string representation (e.g., "#FFAABB").- Returns:
- a 7-character hex color string
-
randomColorRestricted
@NotNull public static @NotNull Color randomColorRestricted(@NotNull @NotNull String minHex, @NotNull @NotNull String maxHex) Generates a randomized color bounded between two hexadecimal thresholds per channel. Useful for constrained palettes and gradient stepping.- Parameters:
minHex- the starting hex string (e.g., "#000000" or "000000")maxHex- the ending hex string (e.g., "#101010" or "101010")- Returns:
- a randomized color bounded within the designated range
- Throws:
IllegalArgumentException- if the hex string format or length is invalid
-
toHexString
Converts aColorobject into an uppercase Hex string (#RRGGBB).- Parameters:
color- the color to convert- Returns:
- formatted hex color string
-
fromHex
Parses a hexadecimal string into aColorobject.- Parameters:
hexStr- the hex string (e.g., "#FF0000" or "FF0000")- Returns:
- the resolved
Color - Throws:
IllegalArgumentException- if the string is null, empty, or improperly formatted
-