Jump to content

Multiple Shapes On One Canvas - GD Library


glenelkins

Recommended Posts

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.gewebsitedevelopment.com/gd2.php


[code]
<?

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

?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.