/ Published in: PHP
See provided example at bottom of code block ...
Expand |
Embed | Plain Text
<?php /** * Color shift a hex value by a specific percentage factor * * @param string $supplied_hex Any valid hex value. Short forms e.g. #333 accepted. * @param string $shift_method How to shift the value e.g( +,up,lighter,>) * @param integer $percentage Percentage in range of [0-100] to shift provided hex value by * @return string shifted hex value * @version 1.0 2008-03-28 */ function hex_shift($supplied_hex,$shift_method,$percentage=50) { $shifted_hex_value = null; $valid_shift_option = FALSE; $current_set = 1; // Check Factor } // Check shift method foreach($options as $method) { if($method == $shift_method) { $valid_shift_option = !$valid_shift_option; $shift_method = ($current_set === 1) ? '+' : '-'; break 2; } } ++$current_set; } if(!$valid_shift_option) { } // Check Hex string case 3: '\\1\\1\\2\\2\\3\\3',$supplied_hex); } else { } break; case 6: } break; default: } // Start shifting foreach($RGB_values as $c => $v) { switch($shift_method) { case '-': break; case '+': break; default: } $shifted_hex_value .= $current_value = ( ) ? '0'.$decimal_to_hex : $decimal_to_hex; } return '#'.$shifted_hex_value; } // --------------------------------------------------- // Example. Black to white fade by an increment of 10% // --------------------------------------------------- for ($i=0; $i <= 100; $i+=10) { } ?>
You need to login to post a comment.
