CRM_Utils_Color
class CRM_Utils_Color
Static utility functions for working with colors
Constants
COLOR_FILE |
|
Methods
Determine the appropriate text color for a given background.
Parse any color string into rgb decimal values
Calculate a highlight color from a base color
Convert named color (e.g. springgreen) to hex
Converts rgb array to hex string
Validate color input and convert it to standard hex notation
Details
at line 51
static string
getContrast(string $color, string $black = 'black', string $white = 'white')
Determine the appropriate text color for a given background.
Based on YIQ value.
at line 70
static int[]|null
getRgb(string $color)
Parse any color string into rgb decimal values
Accepted formats: Full hex: "#ffffff" Short hex: "#fff" Color name "white" RGB notation: "rgb(255, 255, 255)"
at line 96
static string
getHighlight($color)
Calculate a highlight color from a base color
at line 118
static string|null
nameToHex($colorName)
Convert named color (e.g. springgreen) to hex
at line 134
static string
rgbToHex(int[] $rgb)
Converts rgb array to hex string
at line 148
static bool
normalize(string $color)
Validate color input and convert it to standard hex notation