Advertisement
Guest User

Untitled

a guest
Feb 7th, 2012
6,469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. <?php
  2.  
  3. function getColor($num) {
  4.     $hash = md5('color' . $num);
  5.     return array(hexdec(substr($hash, 0, 2)), hexdec(substr($hash, 2, 2)), hexdec(substr($hash, 4, 2)));
  6. }
  7.  
  8. $nums = range(0, 20);
  9. $scale = 30;
  10. $im = imagecreatetruecolor($scale * count($nums), $scale);
  11. $i = 0;
  12. foreach ($nums as $num) {
  13.     list($r,$g,$b) = getColor($num);
  14.     $c = imagecolorallocate($im, $r, $g, $b);
  15.     imagefilledrectangle($im, $scale * $i, 0, $scale * ($i + 1), $scale, $c);
  16.     $i++;
  17. }
  18.  
  19. header('Content-Type: image/png');
  20. imagepng($im);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement