Ellipse with border and fill alpha

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hari-kj
Forum Newbie
Posts: 10
Joined: Mon Jun 05, 2006 7:40 am

Ellipse with border and fill alpha

Post by hari-kj »

I need some help in drawing an ellipse with fill and border, both having different alpha color

The code is,

Code: Select all

 
<?php
 
$img = imageCreateTrueColor( 600, 600);
 
$red   = imagecolorallocatealpha($img, 255,   0,   0,50);
$blue  = imagecolorallocatealpha($img,   0,   0, 255,50);
 
imagefilledellipse  ($img, 300, 300, 400, 400, $red);
imagefilledellipse  ($img, 300, 300, 350, 350, $blue); 
 
header( 'Content-Type: image/png' );
imagePNG( $img );
imagedestroy($img);
 
?>
 
The image that I'm expecting is the test.png that I've attached with this post. But the output that I'm getting now is result.png (as attached)
 
Can anyone please help me with this.
 
Regards,
Hari
Attachments
result.png
result.png (10.08 KiB) Viewed 475 times
test.png
test.png (9.25 KiB) Viewed 475 times
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Ellipse with border and fill alpha

Post by superdezign »

Are you sure that 50 is the right opacity? Try other values to see if you get what you're after. The value is from 0 to 127.
hari-kj
Forum Newbie
Posts: 10
Joined: Mon Jun 05, 2006 7:40 am

Re: Ellipse with border and fill alpha

Post by hari-kj »

The alpha does not matter actually. No matter what alpha I provide the foreground color(blue) will merge with the background red color (stroke). What I'm looking for is to draw the outer border as an unfilled elllipse so that I have a hollow space at the center to fill with another color. I tried imageellipse but the imagesetthickness method does not work to set the stroke width. I even tried using imageellipse and then drawing them in a for loop with reducing the width one step at a time. But the output was not desirable.

Any idea of how I can draw an unfilled antialiased ellipse with an alpha color?
Post Reply