wc_hex_is_light( mixed $color )
Determine whether a hex color is light.
Description Description
Parameters Parameters
- $color
-
(Required) Color.
Return Return
(bool) True if a light color.
Source Source
File: includes/wc-formatting-functions.php
function wc_hex_is_light( $color ) {
$hex = str_replace( '#', '', $color );
$c_r = hexdec( substr( $hex, 0, 2 ) );
$c_g = hexdec( substr( $hex, 2, 2 ) );
$c_b = hexdec( substr( $hex, 4, 2 ) );
$brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
return $brightness > 155;
}