DJ Mike's Tutorials: PHP

Imagemagick Functions


^

ImagickDraw::roundRectangle

Description:
bool ImagickDraw::roundRectangle ( float $x1 , float $y1 , float $x2 , float $y2 , float $rx , float $ry )

Draws a rounded rectangle given two coordinates, x & y corner radiuses and using the current stroke, stroke width, and fill settings.
Parameters
x1
x coordinate of the top left corner
y1
y coordinate of the top left corner
x2
x coordinate of the bottom right corner
y2
y coordinate of the bottom right corner
rx
x rounding
ry
y rounding
Return Values
No value is returned.

Example


<?
######################################
# make a palette to draw on
$type "png";
$image = new imagick();
$image->newimage200200"#123456" );
$image->setimageformat("$type");
######################################
# make some colors to draw with
$color_01 = new imagickpixel("#880000");
$color_02 = new imagickpixel("#008800");
######################################

############## Rectangle ##############
# make a draw object
$rectangle = new imagickdraw();
# set fill color
$rectangle->setfillcolor($color_01);
# describe rectangle 
$rectangle->rectangle20208080 );
# draw rectangle
$image->drawimage($rectangle);
######################################

############ Roundrectangle ############
# make another draw object
$roundrectangle_01 =  new imagickdraw();
# set fill color
$roundrectangle_01->setfillcolor($color_02);
# describe round rectangle
$roundrectangle_01->roundrectangle100,20180,8010,10 );
# draw round rectangle
$image->drawimage($roundrectangle_01);
####################################

############## Gradient ##############
# Make new object & inital color and corner settings
$roundrectangle_02 =  new imagickdraw();
$blue 5;
$red_green 0;
$x1 10;
$y1 90;
$x2 190;
$y2 190;
$r 20;
# begin loop
for ( $count=1$count<10$count++ )
{
# increment size settings
$x1 $x1+$count;
$y1 $y1+$count;
$x2 $x2-$count;
$y2 $y2-$count;
$r $r-$count;
# increment color settings
$blue $blue+($count*25);
$roundrectangle_02->setfillcolor("rgb($red$red_green$blue)");
# describe round rectangle
$roundrectangle_02->roundrectangle$x1,$y1$x2,$y220,20 );
# draw round rectangle
$image->drawimage($roundrectangle_02);
# end loop
# output to browser
header("Content-type: image/$type");
echo 
$image;
?>



^

Created by DJ Mike from Santa Barbara

DJ Mike


Dance Away Santa Barbara's Home Page
<a href="http://www.statcounter.com/" target="_blank"> <img src="http://c5.statcounter.com/counter.php?sc_project=1321035&java=0&security=da2193dc" alt="counter free hit invisible" border="0" /></a>