Redfern_89

ddddd.php

Apr 6th, 2023
1,237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <?php
  2.    
  3.     require_once 'data.php';
  4.     $w = 3400;
  5.     $h = 1800;
  6.    
  7.     $img = imagecreatetruecolor($w, $h);
  8.     imagefill($img, 0, 0, 0xffffff);
  9.     imageantialias($img, true);
  10.    
  11.     function imagegradient($img, $x1, $y1, $x2, $y2, $startColor, $endColor) {
  12.         if ($x1 > $x2 || $y1 > $y1) return false;
  13.        
  14.         $steps = $y2 - $y1;
  15.        
  16.         for ($i = 0; $i < $steps; $i++) {
  17.             $r = ((($startColor >> 16) & 0xFF) - ((($startColor >> 16) & 0xFF) - ((($endColor >> 16) & 0xFF)) / $steps) * $i);
  18.             $g = ((($startColor >> 8) & 0xFF) - ((($startColor >> 8) & 0xFF) - ((($endColor >> 8) & 0xFF)) / $steps) * $i);
  19.             $b = (($startColor & 0xFF) - (($startColor & 0xFF) - ($endColor & 0xFF) / $steps) * $i);
  20.             $color = imagecolorallocate($img, $r, $g, $b);
  21.             imageline($img, $x1, ($i) + $y1, $x2, $i + $y1, $color);
  22.         }
  23.     }
  24.    
  25.     function imagelinebold($img, $x1, $y1, $x2, $y2, $tickness=2, $color) {
  26.         for ($i = 0; $i < $tickness; $i++) {
  27.             imageline($img, $x1 + $i, $y1 + $i, $x2 + $i, $y2 + $i, $color);
  28.         }
  29.     }
  30.    
  31.     imagegradient($img, 0, 0, $w, $h, 0x000000, 0x511F25);
  32.    
  33.     $min = min($data);
  34.     $max = max($data);
  35.     $len = count($data);
  36.    
  37.     $x1 = 0;
  38.     $y1 = 0;
  39.     $x2 = 0;
  40.     $y2 = 0;
  41.    
  42.     $xy = array();
  43.    
  44.     $dh = $h;//($h / 2);
  45.    
  46.     for ($i = 0; $i < $len; $i++) {
  47.         $val = $data[$i];
  48.         $x1 = (int)(($w / ($len -1)) * $i);
  49.         $y1 = (int)($dh) - (int)(($val - $min) * ($dh - 10) / ($max - $min) + 50);
  50.        
  51.         $points = array(
  52.             $x1, $y1+1,
  53.             $x2, $y2+1,
  54.             $x2, $dh,
  55.             $x1, $dh
  56.         );
  57.         imagefilledpolygon($img, $points, 4, 0x161818);
  58.        
  59.         imagelinebold($img, $x1, $y1, $x2, $y2, 2, 0xf74557);
  60.         $y2 = $y1;
  61.         $x2 = $x1;
  62.     }
  63.    
  64.     header('Content-Type: image/png');
  65.     imagepng($img);
  66.     imagedestroy($img);
  67.  
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment