Возникла проблема-нужно сделать волновое искажение для изображения,нашла готовый пример,но там вылазят черные полуволны,почему так?
header("Content-type: image/png");
$xx = 300;
$yy = 100;
$img=imagecreatetruecolor($xx, $yy) or die('Cannot create image');
$img2=imagecreatetruecolor($xx, $yy) or die('Cannot create image');
//imagefill($img2, 0, 0, 255);
imagefill($img, 0, 0, 0xf3febd);
$x=-20;
$i = 1;
$sum = "";
$number = 9;
$font = "cour.ttf";
$font_size = rand(16,32);
$x=20;
for ($i=0;$i<5;$i++){
imagettftext($img, $font_size, rand(16,32), $x=$x+rand(40,56),rand(40,56),imagecolorallocate($img, rand(0,255), rand(0,255), rand(0,255)), $font, $number);
}
for($x=0;$x<=$xx;$x++) {
$new_y = 22*sin($x/10);
for($y=0;$y<=$yy;$y++) {
$rgb = imagecolorat($img, $x, $y+$new_y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;//var_dump($r, $g, $b);
$color = imagecolorallocate($img2, $r, $g, $b);
imagesetpixel($img2, $x, $y, $color);
}
}
imagepng($img2);
imagedestroy($img);
imagedestroy($img2);
Помогите от них избавиться