Jump to content


Multiple Shapes On One Canvas - GD Library

  • Please log in to reply
1 reply to this topic

#1 glenelkins

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

Posted 13 September 2006 - 09:52 PM


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);

ImageFill ($im,$middle_w,$middle_h,$white);



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

#2 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


|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