daily pastebin goal
92%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env php
  2. <?php
  3. $content = file_get_contents($argv[1]);
  4.  
  5. function invert_color($matches) {
  6.   $r = 255 - intval(substr($matches[1], 0, 2), 16);
  7.   $g = 255 - intval(substr($matches[1], 2, 2), 16);
  8.   $b = 255 - intval(substr($matches[1], 4, 2), 16);
  9.   $a = isset($matches[2]) ? $matches[2] : '';
  10.  
  11.   return sprintf("#%02x%02x%02x%s", $r, $g, $b, $a);
  12. }
  13.  
  14. $inverted = preg_replace_callback('@\#([a-f0-9]{6})([a-f0-9]{2})?@i', 'invert_color', $content);
  15. file_put_contents($argv[1] . '.inv', $inverted);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top