Page 1 of 1

Ellipse with border and fill alpha

Posted: Wed Mar 03, 2010 7:51 am
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

Re: Ellipse with border and fill alpha

Posted: Wed Mar 03, 2010 8:57 am
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.

Re: Ellipse with border and fill alpha

Posted: Wed Mar 03, 2010 11:18 am
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?