gullinbursti

Invert #hex color w/ PHP

Dec 1st, 2014
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.27 KB | None | 0 0
  1. <?php
  2. function InvertColor($hex) {
  3.   return sprintf("%06s",base_convert(($hex ^ 0xFFFFFF),10,16));
  4.   };
  5.  
  6. print '<td bgcolor="BB2222"><font color="'.InvertColor(0xBB2222).'">Blah</font></td>';
  7. // Prints 44dddd as the font color, which is it's opposite on the color wheel
  8. ?>
Advertisement
Add Comment
Please, Sign In to add comment