function mandel($params) { $image_x = 4 * $params['w']; $image_y = 4 * $params['h']; $image = imagecreatetruecolor($image_x, $image_y); imagefilledrectangle($image, 0, 0, $image_x, $image_y, 0xffffff); $f = imagecolorallocate($image, $params['r'], $params['g'], $params['b']); $color = color($params, $image); for ($x = 0; $x < $image_x; $x++) { for ($y = 0; $y < $image_y; $y++) { $c_r = $x / $params['w'] + -2; $c_i = $y / $params['h'] + -2; $z_r = 0; $z_i = 0; $i = 0; while ($z_r * $z_r + $z_i * $z_i < 4 and $i < $params['n']) { $mod = sqrt($z_r * $z_r + $z_i * $z_i); $arg = atan2($z_i, $z_r); $z_r = pow($mod, $params['k']) * cos($params['k'] * $arg) + $c_r; $z_i = pow($mod, $params['k']) * sin($params['k'] * $arg) + $c_i; $i++; } if ($i == $params['n']) { imagesetpixel($image, $x, $y, $f); } else { imagesetpixel($image, $x, $y, $color[$i]); } } } return send_image($image); }
function display_img_error($str) { global $img_type; $imageW = 560; $imageH = 80; $text_font = 3; $im = imagecreate($imageW, $imageH); $black = imagecolorallocate($im, 0, 0, 0); $gray1 = convertToRGB('EAEAEA'); $gray1 = imagecolorallocate($im, $gray1->red, $gray1->green, $gray1->blue); // // Création du contour noir // imagefill($im, 0, 0, $black); imagefilledrectangle($im, 1, 1, $imageW - 2, $imageH - 2, $gray1); // // titre du graphe // $startW = ($imageW - imagefontwidth($text_font) * strlen($str)) / 2; $startH = ($imageH - imagefontheight($text_font)) / 2; imagestring($im, $text_font, $startW, $startH, $str, $black); send_image('error', $im); }