©
本文档使用
php.cn手册 发布
(PECL imagick 2.0.0)
ImagickDraw::ellipse — Draws an ellipse on the image
$ox
, float $oy
, float $rx
, float $ry
, float $start
, float $end
)本函数还未编写文档,仅有参数列表。
Draws an ellipse on the image.
ox
oy
rx
ry
start
end
没有返回值。
Example #1 ImagickDraw::ellipse()
<?php
function ellipse ( $strokeColor , $fillColor , $backgroundColor ) {
$draw = new \ ImagickDraw ();
$draw -> setStrokeColor ( $strokeColor );
$draw -> setFillColor ( $fillColor );
$draw -> setStrokeWidth ( 2 );
$draw -> setFontSize ( 72 );
$draw -> ellipse ( 125 , 70 , 100 , 50 , 0 , 360 );
$draw -> ellipse ( 350 , 70 , 100 , 50 , 0 , 315 );
$draw -> push ();
$draw -> translate ( 125 , 250 );
$draw -> rotate ( 30 );
$draw -> ellipse ( 0 , 0 , 100 , 50 , 0 , 360 );
$draw -> pop ();
$draw -> push ();
$draw -> translate ( 350 , 250 );
$draw -> rotate ( 30 );
$draw -> ellipse ( 0 , 0 , 100 , 50 , 0 , 315 );
$draw -> pop ();
$imagick = new \ Imagick ();
$imagick -> newImage ( 500 , 500 , $backgroundColor );
$imagick -> setImageFormat ( "png" );
$imagick -> drawImage ( $draw );
header ( "Content-Type: image/png" );
echo $imagick -> getImageBlob ();
}
?>
[#1] Axeia [2009-03-31 14:10:52]
<?php
ImagickDraw::ellipse( float $ox , float $oy , float $rx , float $ry , float $start , float $end );
?>
Example of drawing a full ellipse (from 0, 360) and outputting it as a PNG.
Do note, that this is by default anti-aliased unlike the GD functions which only support it on lines that aren't on a transparent background.
<?php
$width = 200;
$height = 100;
$border = 2;
$img = new Imagick();
$img->newImage( $width, $height, new ImagickPixel( 'transparent' ) );
$draw = new ImagickDraw();
$draw->setStrokeColor( new ImagickPixel( 'black' ) );
$draw->setStrokeWidth( 2 );
$draw->setFillColor( new ImagickPixel( 'transparent' ) );
//Substract the border from the radius so it doesn't fall outside the screen.
$draw->ellipse( $width/2, $height/2, ($width/2)-$border, ($height/2)-$border, 0, 360 );
$img->drawImage( $draw );
$img->setImageFormat( "png" );
header( "Content-Type: image/png" );
echo $img;
?>