layers_hex_lighter

The Layers layers hex lighter function.

Description

layers_hex_lighter( $color, (int) $factor = 30 ); 

Parameters (2)

0. $color
The color.
1. $factor — Optional. (int) => 30
The factor.

Usage

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

Defined (1)

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

/core/helpers/color.php  
  1. function layers_hex_lighter( $color, $factor = 30 ) { 
  2.  
  3. $base = layers_hex2rgb( $color ); 
  4. $color = '#'; 
  5. foreach ( $base as $k => $v ) { 
  6. $amount = 255 - $v; 
  7. $amount = $amount / 100; 
  8. $amount = round( $amount * $factor ); 
  9. $new_decimal = $v + $amount; 
  10. $new_hex_component = dechex( $new_decimal ); 
  11. if ( strlen( $new_hex_component ) < 2 ) { 
  12. $new_hex_component = "0" . $new_hex_component; 
  13. $color .= $new_hex_component; 
  14. return $color;