Эффект "мокрого пола"

<?php
/**
 * Эффект "мокрого пола"
 * автор: MYPABEU (http://mypabeu.habrahabr.ru)
 * 30.09.08
 */

//путь к картинке
$img=imagecreatefrompng('c:/qqq.png');

//размер отраженного объекта в % от оригинала
$perc=50;

//максимальная прозрачность
$maxAlpha=120;

$src_height = imagesy($img);
$src_width = imagesx($img);
$dest_height = $src_height + ($src_height / (100/$perc));
$dest_width = $src_width;

$reflected = imagecreatetruecolor($dest_width, $dest_height);
imagealphablending($reflected, false);
imagesavealpha($reflected, true);

imagecopy($reflected, $img, 0, 0, 0, 0, $src_width, $src_height);
$reflection_height = $src_height / 2;
for($y=$src_height; $y<$dest_height; $y++)
{
	$alpha = (($y-$src_height)/($dest_height-$src_height))*$maxAlpha;

	for($x=0; $x<$src_width; $x++)
	{
		$rgba = imagecolorat($img, $x, $src_height - ($y-$src_height+1));
		$rgba = imagecolorsforindex($img, $rgba);
		$rgba = imagecolorallocatealpha($reflected, $rgba['red'], $rgba['green'], $rgba['blue'], $alpha);
		imagesetpixel($reflected, $x, $y, $rgba);
	}
}
$img = $reflected;

header('Content-type:image/png');
imagepng($img);

?>