wc_hex_is_light()
Determine whether a hex color is light.
No Hooks.
Return
true|false
. True if a light color.
Usage
wc_hex_is_light( $color );
- $color(mixed) (required)
- Color.
wc_hex_is_light() wc hex is light code WC 9.6.1
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; }