It takes some trigonometry, but it is possible.
I have this function I've take from somewhere and adapted (I would cite if I could) that does this.
function wave_area($img, $x, $y, $width, $height, $amplitude = 10, $period = 10){
// Make a copy of the image twice the size
$height2 = $height * 2;
$width2 = $width * 2;
$img2 = imagecreatetruecolor($width2, $height2);
imagecopyresampled($img2, $img, 0, 0, $x, $y, $width2, $height2, $width, $height);
if($period == 0) $period = 1;
// Wave it
for($i = 0; $i < ($width2); $i += 2)
imagecopy($img2, $img2, $x + $i - 2, $y + sin($i / $period) * $amplitude, $x + $i, $y, 2, $height2);
// Resample it down again
imagecopyresampled($img, $img2, $x, $y, 0, 0, $width, $height, $width2, $height2);
imagedestroy($img2);
}
I honestly cannot explain the trig parts, but other than that is is just basically moving the pixels around on a copied image.
This function waves a certain part of the image. To wave the entire image, you can call it like this.
wave_area($img, 0, 0, imagesx($img), imagesy($img), 10, 10);
Have fun adjusting the amplitude and period until you get a good image; or even randomize them.
Edited by Demonslay, 08 December 2007 - 10:07 PM.