Jump to content


Photo

Multiple Shapes On One Canvas - GD Library


  • Please log in to reply
1 reply to this topic

#1 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 13 September 2006 - 09:52 PM

Hi

How can i draw multiple shapes on the same canvas, with different fills? The following code i wanted to display the first ellipse as filled with white, the second around the back of the first one in pink, so it looks like the first one has a thick pink border, then i will want to add another one slightly bigger in a different colour..At the moment it seems to display the whole lot filled with pink, but only the outter ellipse is not filled only a pink outline. See what i mean at: http://www.gewebsite...ent.com/gd2.php


<?

header ("Content-type: image/png");

// Second box - ellipse
$height = 400;
$width = 400;
$middle_h = $height / 2;
$middle_w = $width / 2;

$im = ImageCreate($width,$height);

$bck = ImageColorAllocate($im,0,0,0);
$white = ImageColorAllocate($im,255,255,255);
$pink = ImageColorAllocate($im,217,171,161);

ImageEllipse($im,$middle_w,$middle_h,20,20,$white);
ImageFill ($im,$middle_w,$middle_h,$white);
ImageEllipse($im,$middle_w,$middle_h,30,30,$pink);
ImageFill($im,$middle_w,$middle_h,$pink);

ImagePNG($im);

?>

http://thewebsolutionprovider.com - A Solution For Everything Web!

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 13 September 2006 - 11:15 PM

Use imagefilledellipse(). Draw backmost ellipse first, front ellipse last
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users