getLuma
Commons
stable
Returns the perceptual luminance (Y channel in CIE XYZ space) of a color. Used internally by the contrast checker to decide foreground colour on coloured surfaces.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- colorrequisTColorType
- The color to evaluate. Accepts any format supported by parseColor (hex, rgb, hsl, named CSS colour).
API
Valeur de retour
La valeur retournée par cet util.
- The relative luminance as a number between 0 (black) and 1 (white).
Usage
Exemples
Extraits de code prêts à coller.
Check luminance to choose a foreground colour