Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function getColor($num) {
- $hash = md5('color' . $num);
- return array(hexdec(substr($hash, 0, 2)), hexdec(substr($hash, 2, 2)), hexdec(substr($hash, 4, 2)));
- }
- $nums = range(0, 20);
- $scale = 30;
- $im = imagecreatetruecolor($scale * count($nums), $scale);
- $i = 0;
- foreach ($nums as $num) {
- list($r,$g,$b) = getColor($num);
- $c = imagecolorallocate($im, $r, $g, $b);
- imagefilledrectangle($im, $scale * $i, 0, $scale * ($i + 1), $scale, $c);
- $i++;
- }
- header('Content-Type: image/png');
- imagepng($im);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement