layers_get_brightness

The Layers layers get brightness function.

Description

layers_get_brightness( $color ); 

Parameters (1)

0. $color
The color.

Usage

  1. if ( !function_exists( 'layers_get_brightness' ) ) { 
  2. require_once '/core/helpers/color.php'; 
  3.  
  4. // The color. 
  5. $color = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = layers_get_brightness($color); 
  9.  

Defined (1)

The function is defined in the following location(s).

/core/helpers/color.php  
  1. function layers_get_brightness( $color ) { 
  2.  
  3. $hex = str_replace( '#', '', $color ); 
  4.  
  5. $c_r = hexdec( substr( $hex, 0, 2 ) ); 
  6. $c_g = hexdec( substr( $hex, 2, 2 ) ); 
  7. $c_b = hexdec( substr( $hex, 4, 2 ) ); 
  8.  
  9. $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; 
  10.  
  11. return $brightness;