daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Dec 7th, 2018 59 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. <?php
  2.  
  3. $height = isset($_GET['height']) ? $_GET['height'] : 80;
  4. $width = isset($_GET['width']) ? $_GET['width'] : 80;
  5. // top | left
  6. $dir = isset($_GET['direction']) ? $_GET['direction'] : 'top';
  7. $start = $_GET['start'];
  8. $end = $_GET['end'];
  9.  
  10. list($r, $g, $b) = hex2rgb($start);
  11. list($r2, $g2, $b2) = hex2rgb($end);
  12.  
  13. $img = imagecreatetruecolor($width, $height);
  14. $pixel = $dir == 'top' ? $height : $width;
  15. for($i = 0; $i < $pixel; $i++) {
  16.     $color = imagecolorallocate($img,
  17.         round($r - ($r - $r2)/($pixel-1)*$i),
  18.         round($g - ($g - $g2)/($pixel-1)*$i),
  19.         round($b - ($b - $b2)/($pixel-1)*$i));
  20.     imageline($img,
  21.         $dir == 'top' ? 0 : $i, $dir == 'top' ? $i : 0,
  22.         $dir == 'top' ? $width : $i, $dir == 'top' ? $i : $height,
  23.         $color);
  24. }
  25.  
  26. // output image
  27. header('Content-Type: image/png');
  28. imagepng($img);
  29. imagedestroy($img);
  30.  
  31.  
  32. function hex2rgb($color) {
  33.      return array_map(function($val) {
  34.          return hexdec($val);
  35.      }, str_split($color, 2));
  36. }
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