All pastes #214244 Raw Edit

Miscellany

public text v1 · immutable
#214244 ·published 2006-10-21 22:43 UTC
rendered paste body
<?php

	$colors = explode(';', $_POST['colors']);

	$x = 0;
	$y = 0;
	$w = 20;
	$h = 20;
	
	$im = imagecreatetruecolor($w, $h);
	
	foreach($colors as $c)
	{
		
		$color = explode(',', $c);
		
		$col = imagecolorallocate($im, $color[0], $color[1], $color[2]);
		
		imagesetpixel($im, $x, $y, $col);
		
		if ($x == $w)
		{
			$y++;
			$x = 0;
		}
		
		$x++;
		
		if ($y == $h)
		{
			$y = 0;
		}
	}
	
	imagejpeg($im, dirname(__FILE__) . '/im.jpg', 100);	
?>