code4 Darker color


SUBMITTED BY: phpsnippets

DATE: Oct. 24, 2015, 10:26 a.m.

FORMAT: Text only

SIZE: 418 Bytes

HITS: 1196

  1. function ColorDarken($color, $dif=20){
  2. $color = str_replace('#', '', $color);
  3. if (strlen($color) != 6){ return '000000'; }
  4. $rgb = '';
  5. for ($x=0;$x<3;$x++){
  6. $c = hexdec(substr($color,(2*$x),2)) - $dif;
  7. $c = ($c < 0) ? 0 : dechex($c);
  8. $rgb .= (strlen($c) < 2) ? '0'.$c : $c;
  9. }
  10. return '#'.$rgb;
  11. }

comments powered by Disqus