Color Utils
object ColorUtils
Utility functions for color operations and contrast checking.
Functions
Link copied to clipboard
Calculates the contrast ratio between two colors.
Link copied to clipboard
Calculates the relative luminance of a color using the WCAG formula.
Link copied to clipboard
Generates a subtle shade of the given color. If the color is bright (light), returns a slightly darker shade. If the color is dark, returns a slightly lighter shade.
Link copied to clipboard
Checks if two colors have sufficient contrast for accessibility.
Link copied to clipboard
Determines if a color is bright (light) or dark based on its luminance.
Link copied to clipboard
Returns an appropriate shadow color based on background brightness.
Link copied to clipboard
fun readableTextColor(backgroundColor: Color, lightColor: Color = Color.White, darkColor: Color = Color.Black): Color
Returns an appropriate contrast color (light or dark) based on background color. Similar to iOS UIColor.readableTextColor()