Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. <?php
  2.  
  3. global $color;
  4. $color = '000000';
  5.  
  6. function color_inverse($color){
  7. $color = str_replace('#', '', $color);
  8. if (strlen($color) != 6){ return '000000'; }
  9. $rgb = '';
  10. for ($x=0;$x<3;$x++){
  11. $c = 255 - hexdec(substr($color,(2*$x),2));
  12. $c = ($c < 0) ? 0 : dechex($c);
  13. $rgb .= (strlen($c) < 2) ? '0'.$c : $c;
  14. }
  15. return '#'.$rgb;
  16. }
  17.  
  18. echo color_inverse($color);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement