|
|
 |
imageellipse (PHP 4 >= 4.0.6, PHP 5) imageellipse -- Draw an ellipse Descriptionint imageellipse ( resource image, int cx, int cy, int w, int h, int color )
imageellipse() draws an ellipse centered at
cx, cy (top left is
0, 0) in the image represented by image.
W and h specifies the
ellipse's width and height respectively. The color of the ellipse is
specified by color.
Example 1. imageellipse() example |
<?php
$image = imagecreate(400, 300);
$bg = imagecolorallocate($image, 0, 0, 0);
$col_ellipse = imagecolorallocate($image, 255, 255, 255);
imageellipse($image, 200, 150, 300, 200, $col_ellipse);
header("Content-type: image/png");
imagepng($image);
?>
|
|
See also imagefilledellipse() and
imagearc().
User Contributed Notes
imageellipse
julian
16-Jan-2005 08:23
if you want to display an ellipse in the upper left corner of an image, you can easily calculate the corresponding cx and cy values. this example will draw an ellipse having the same width and height as the image.
<?php
$ellipse_width = 100;
$ellipse_height = 200;
$ellipse_cx = ($ellipse_width / 2);
$ellipse_cy = ($ellipse_height / 2);
$img_x = $ellipse_width;
$img_y = $ellipse_height;
$img = imagecreate($img_x, $img_y);
$bg = imagecolorallocate($img, 255,255,255);
$ellipse_color = imagecolorallocate($img, 0, 0, 0);
imageellipse($img, $ellipse_cx, $ellipse_cy, $ellipse_width, $ellipse_height, $ellipse_color);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
?>
agentyoungsoo at hanmail dot net
04-Dec-2002 10:56
When you wana use "ImageEllipse" function
in under GD 2.0.2 version, you can use "ImageArc" like bellow
----------------------------------------------------
$file_name = "test.png";
$screen_x = 300;
$screen_y = 200;
$x1 = $screen_x / 2;
$y1 = $screen_y / 2;
$radius = 30;
$image = ImageCreate($screen_x, $screen_y);
$black = ImageColorAllocate($image, 0,0,0);
ImageArc($image, $x1, $y1, $radius , $radius , 0, 360, $black);
ImagePng($image, $file_name);
ImageDestroy($image);
----------------------------------------------------
| |