
Исследователь
 
Профиль
Группа: Участник
Сообщений: 554
Регистрация: 31.7.2007
Где: Россия, Омск
Репутация: нет Всего: 9
|
Доброе время суток. У меня есть 2 файла: один я писал "вручную", а другой - генерил автоматически из другого скрипта. Выполняют одинаковые функции, но второй почему-то не работает, несмотря на то, что основной рабочий код идентичен. Во втором файле переменные заменены своими значениями при записи. Первый скрипт: | Код | <?php $width=150; $length=80; $image = imagecreatetruecolor($width,$length) or die('Cannot create image'); $img2 = imagecreatetruecolor($width,$length) or die('Cannot create image'); imagefill($image,0,0,0xFFFFFF) or die("<h1>Cannot fill</h1>"); $font=array('times','tahoma','pala','GOTHIC','georgia','framd','cour','comic','arial'); $symb=array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); $colors=array(0xEE82EE,0x800000,0xFF0000,0xA52A2A,0xB22222,0x000000,0xDDA0DD,0x708090,0xBEBEBE,0x808080,0x000080,0x6495ED,0x0000FF,0x008080,0x00FF00,0x008000,0x228B22,0x808000,0xD269E1); $c1=$font[array_rand($font)]; $c2=$font[array_rand($font)]; $c3=$font[array_rand($font)]; $c4=$font[array_rand($font)]; $c5=$font[array_rand($font)]; $c6=$font[array_rand($font)]; $c7=$font[array_rand($font)]; $s1=$symb[array_rand($symb)]; $s2=$symb[array_rand($symb)]; $s3=$symb[array_rand($symb)]; $s4=$symb[array_rand($symb)]; $s5=$symb[array_rand($symb)]; $s6=$symb[array_rand($symb)]; $s7=$symb[array_rand($symb)]; $string=$s1.$s2.$s3.$s4.$s5.$s6.$s7; imagettftext($image,28,0,10,50,0x000000,$c1.".ttf",$s1); imagettftext($image,28,0,25,30,0x000000,$c2.".ttf",$s2); imagettftext($image,28,0,40,40,0x000000,$c3.".ttf",$s3); imagettftext($image,28,0,55,50,0x000000,$c4.".ttf",$s4); imagettftext($image,28,0,70,35,0x000000,$c5.".ttf",$s5); imagettftext($image,28,0,85,45,0x000000,$c6.".ttf",$s6); imagettftext($image,28,0,100,50,0x000000,$c7.".ttf",$s7); for($i=0;$i<($width/10)+1;$i++) { $var=20*$i; imageline($image, $var, 0, $var, 80, 0x000000); } for($i=0;$i<($length/10)+1;$i++) { $var=20*$i; imageline($image, 0, $var, 150, $var, 0x000000); }
$rand1 = mt_rand(700000, 1000000) / 15000000; $rand2 = mt_rand(700000, 1000000) / 15000000; $rand3 = mt_rand(700000, 1000000) / 15000000; $rand4 = mt_rand(700000, 1000000) / 15000000;
$rand5 = mt_rand(0, 3141592) / 1000000; $rand6 = mt_rand(0, 3141592) / 1000000; $rand7 = mt_rand(0, 3141592) / 1000000; $rand8 = mt_rand(0, 3141592) / 1000000;
$rand9 = mt_rand(300, 500) / 100; $rand10 = mt_rand(300, 500) / 100; for($x = 0; $x < $width-1; $x++) { for($y = 0; $y < $length-1; $y++) { $sx = $x + (sin($x*$rand1+$rand5) + sin($y*$rand2+$rand6))*$rand9 ; $sy = $y + (sin($x*$rand4+$rand7) + sin($y*$rand3+$rand8))*$rand10 ; if($sx < 0 || $sy < 0 || $sx >= $width - 1 || $sy >= $length - 1) { $color = 255; $color_x = 255; $color_y = 255; $color_xy = 255; } else { $color = (imagecolorat($image, $sx, $sy) >> 16) & 0xFF; $color_x = (imagecolorat($image, $sx + 1, $sy) >> 16) & 0xFF; $color_y = (imagecolorat($image, $sx, $sy + 1) >> 16) & 0xFF; $color_xy = (imagecolorat($image, $sx + 1, $sy + 1) >> 16) & 0xFF; } if($color == $color_x && $color == $color_y && $color == $color_xy) { $newcolor=$color; } else { $frsx = $sx - floor($sx); $frsy = $sy - floor($sy); $frsx1 = 1 - $frsx; $frsy1 = 1 - $frsy;
$newcolor = floor( $color * $frsx1 * $frsy1 + $color_x * $frsx * $frsy1 + $color_y * $frsx1 * $frsy + $color_xy * $frsx * $frsy ); } imagesetpixel($img2, $x, $y, imagecolorallocate($img2, $newcolor, $newcolor, $newcolor)); } } header('Content-type: image/png'); imagepng($img2); imagedestroy($image); imagedestroy($img2); ?>
|
И второй: | Код | <?php $image = imagecreatetruecolor(150,80); $img2 = imagecreatetruecolor(150,80); imagefill($image,0,0,0xFFFFFF); imagettftext($image,28,0,10,50,0x000000,"arial".".ttf","h"); imagettftext($image,28,0,25,30,0x000000,"framd".".ttf","D"); imagettftext($image,28 ,0,40,40,0x000000,"georgia".".ttf","W"); imagettftext($image,28 , 0,55,50,0x000000,"cour".".ttf","f"); imagettftext($image,28,0,70,35,0x000000,"arial".".ttf","A"); imagettftext($image,28,0,85,45,0x000000,"GOTHIC".".ttf","v"); imagettftext($image,28,0,100,50,0x000000,"GOTHIC".".ttf","A"); for($i=0;$i<(150/10)+1;$i++) { $var=20*$i; imageline($image, $var, 0, $var, 80, 0x000000); } for($i=0;$i<(80/10)+1;$i++) { $var=20*$i; imageline($image, 0, $var, 150, $var, 0x000000); } $rand1 = mt_rand(700000, 1000000) / 15000000; $rand2 = mt_rand(700000, 1000000) / 15000000; $rand3 = mt_rand(700000, 1000000) / 15000000; $rand4 = mt_rand(700000, 1000000) / 15000000; $rand5 = mt_rand(0, 3141592) / 1000000; $rand6 = mt_rand(0, 3141592) / 1000000; $rand7 = mt_rand(0, 3141592) / 1000000; $rand8 = mt_rand(0, 3141592) / 1000000; $rand9 = mt_rand(300, 400) / 100; $rand10 = mt_rand(300, 400) / 100; for($x = 0; $x < 149; $x++) { for($y = 0; $y < 79; $y++) { $sx = $x + (sin($x*$rand1+$rand5) + sin($y*$rand2+$rand6))*$rand9 ; $sy = $y + (sin($x*$rand4+$rand7) + sin($y*$rand3+$rand8))*$rand10 ; if($sx < 0 || $sy < 0 || $sx >= 149 || $sy >= 79 ) { $color = 255; $color_x = 255; $color_y = 255; $color_xy = 255; } else { $color = (imagecolorat($image, $sx, $sy) >> 16) & 0xFF; $color_x = (imagecolorat($image, $sx + 1, $sy) >> 16) & 0xFF; $color_y = (imagecolorat($image, $sx, $sy + 1) >> 16) & 0xFF; $color_xy = (imagecolorat($image, $sx + 1, $sy + 1) >> 16) & 0xFF; } if($color == $color_x && $color == $color_y && $color == $color_xy) { $newcolor=$color; } else { $frsx = $sx - floor($sx); //отклонение координат первообраза от целого $frsy = $sy - floor($sy); $frsx1 = 1 - $frsx; $frsy1 = 1 - $frsy;
$newcolor = floor( $color * $frsx1 * $frsy1 + $color_x * $frsx * $frsy1 + $color_y * $frsx1 * $frsy + $color_xy * $frsx * $frsy ); } imagesetpixel($img2, $x, $y, imagecolorallocate($img2, $newcolor, $newcolor, $newcolor)); } } header('Content-type: image/png'); imagepng($img2); imagedestroy($image); imagedestroy($img2); ?>
|
Помогите разобраться, пожалуйста, уже вторые сутки разобраться не могу
--------------------
"Звонким вереском скроются наши следы, и не вспомнят о них. Кто поверит нам, рыцарям павшей звезды из отвергнутых книг? Пусть в узоре времен ни стихов. ни имен, но напомнит забывшим их полуночный крик." Тэм Гринхилл "Ужели суслик твоего коварства нагадит в плов доверья моего?". Л.Филатов
|