DJ Mike's Tutorials: PHP

Imagemagick Functions


^

ImagickDraw::circle

Description:
bool ImagickDraw::circle ( float $cx , float $cy , float $px , float $py )

Draws a circle on the image.
Parameters
cx
Center x coordinate
cy
Center y coordinate
px
perimeter x coordinate
py
perimeter y coordinate
Return Values
No value is returned.

Example


<?php

$r 
150# radius of first circle
$w 245# image width
$h 365# image height
$x $w/2+40# width offset
$y  $h/2+90# height offset
$alpha .03# transparency of rainbow

$image = new imagick"needleclimbing.jpg" ); 

# define some color objects
$none = new imagickpixel"transparent" );
$purple = new imagickpixel"purple" );
$red = new imagickpixel"red" );
$orange = new imagickpixel"orange" );
$yellow = new imagickpixel"yellow" );
$green = new imagickpixel"green" );
$blue = new imagickpixel"blue" );
$violet = new imagickpixel"violet" );

## Purple circle
$circle_purple = new ImagickDraw;
$circle_purple->setfillcolor($none);
$circle_purple->setstrokecolor($purple);
$circle_purple->setstrokewidth(6);
$circle_purple->setFillOpacity(.3);
$circle_purple->setStrokeAlpha($alpha);
$circle_purple->circle$x$y$x+$r$y+$r);
$image->drawimage($circle_purple);

$r $r+4# increase radius
$circle_red $circle_purple->clone(); # clone color object
$circle_red->setstrokecolor($red); # change color
$circle_red->setStrokeAlpha($alpha);
$circle_red->circle$x$y$x+$r$y+$r);
$image->drawimage($circle_red);

$r $r+4# increase radius
$circle_orange $circle_red->clone(); # clone color object
$circle_orange->setstrokecolor($orange); # change color
$circle_orange->setStrokeAlpha($alpha);
$circle_orange->circle$x$y$x+$r$y+$r);
$image->drawimage($circle_orange);

$r $r+4# increase radius
$circle_yellow $circle_orange->clone();
$circle_yellow->setstrokecolor($yellow);
$circle_yellow->setStrokeAlpha($alpha);
$circle_yellow->circle$x$y$x+$r$y+$r);
$image->drawimage($circle_yellow);

$r $r+4# increase radius
$alpha $alpha*1.5# decrease transparency
$circle_green $circle_yellow->clone();
$circle_green->setstrokecolor($green);
$circle_green->setStrokeAlpha($alpha);
$circle_green->circle$x$y$x+$r$y+$r);
$image->drawimage($circle_green);

$r $r+4# increase radius
$alpha $alpha*1.5# decrease transparency
$circle_blue $circle_green->clone();
$circle_blue->setstrokecolor($blue);
$circle_blue->setStrokeAlpha($alpha);
$circle_blue->circle$x$y$x+$r$y+$r);
$image->drawimage($circle_blue);

$r $r+4# increase radius
$alpha $alpha*1.5# decrease transparency
$circle_violet $circle_blue->clone();
$circle_violet->setstrokecolor($violet);
$circle_violet->setStrokeAlpha($alpha);
$circle_blue->circle$x$y$x+$r$y+$r);
$image->drawimage($circle_violet);

header"Content-Type: image/jpeg" ); 
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>