note 89978 modified in function.imagickdraw-ellipse by danbrown

From: Date: Tue, 31 Mar 2009 22:17:27 +0000
Subject: note 89978 modified in function.imagickdraw-ellipse by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152667@lists.php.net to get a copy of this message
<?php /** * Please note that if you use a stroke. ( Imagick::setStrokeWidth( 2 ) ) the * stroke is drawn outside the ellipse dimensions. * * @param float $ox - Offset X, distance from the center of the ellipse till the left border of the image * @param float $oy - Offset Y, distance from the center of the ellipse till the top of the image * @param float $rx - X radius * @param float $ry - Y radius * @param float float $start - Starting angle in degrees. * @param float float $end - End angle in degrees. * */ 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; ?> --was-- <? /** * Please note that if you use a stroke. ( Imagick::setStrokeWidth( 2 ) ) the * stroke is drawn outside the ellipse dimensions. * * @param float $ox - Offset X, distance from the center of the ellipse till the left border of the image * @param float $oy - Offset Y, distance from the center of the ellipse till the top of the image * @param float $rx - X radius * @param float $ry - Y radius * @param float float $start - Starting angle in degrees. * @param float float $end - End angle in degrees. * */ 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; ?> http://php.net/manual/en/function.imagickdraw-ellipse.php

« previous php.notes (#152667) next »