wc_hex_is_light() WC 1.0
Determine whether a hex color is light.
Хуков нет.
Возвращает
true/false. True if a light color.
Использование
wc_hex_is_light( $color );
- $color(разное) (обязательный)
- Color.
Код wc_hex_is_light() wc hex is light WC 5.0.0
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;
}