evolve_hexDarker

The evolve evolve hexDarker function.

Description

evolve_hexDarker( $hex, (int) $factor = 30 ); 

Parameters (2)

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

Usage

  1. if ( !function_exists( 'evolve_hexDarker' ) ) { 
  2. require_once '/library/functions/basic-functions.php'; 
  3.  
  4. // The hex. 
  5. $hex = null; 
  6.  
  7. // The factor. 
  8. $factor = 30; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = evolve_hexDarker($hex, $factor); 
  12.  

Defined (1)

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

/library/functions/basic-functions.php  
  1. function evolve_hexDarker($hex, $factor = 30) { 
  2. $new_hex = ''; 
  3.  
  4. // if hex code null than assign transparent for hide PHP warning / 
  5. $hex = empty($hex) ? 'ransparent' : $hex; 
  6.  
  7. $base['R'] = hexdec($hex{0} . $hex{1}); 
  8. $base['G'] = hexdec($hex{2} . $hex{3}); 
  9. $base['B'] = hexdec($hex{4} . $hex{5}); 
  10.  
  11. foreach ($base as $k => $v) { 
  12. $amount = $v / 100; 
  13. $amount = round($amount * $factor); 
  14. $new_decimal = $v - $amount; 
  15.  
  16. $new_hex_component = dechex($new_decimal); 
  17. if (strlen($new_hex_component) < 2) { 
  18. $new_hex_component = "0" . $new_hex_component; 
  19. $new_hex .= $new_hex_component; 
  20.  
  21. return $new_hex;