views:

55

answers:

1

I'm able to draw a circle on a transparent background, but it's pixelated around the edges.

I can also get an anti-aliased circle on a non-transparent background with http://mierendo.com/software/antialiased_arcs/.

So, how do I get both?

A: 

The trouble with transparent images is that the half-transparent pixels at the border will be partly colored with the color you specified as the transparent color, if you can live with that then you can use the antialiased arcs library you specified, just put the following at the beginning of their example (I used the optimized version) :

include ("./imageSmoothArc_optimized.php");

$img = imageCreateTrueColor( 648, 800 );
imagealphablending($img,true);
$color = imageColorAllocate( $img, 255, 255, 255);
$transparent_color = imageColorAllocate( $img, 0, 0, 0);
imagefill( $img, 5, 5, $transparent_color );
imagecolortransparent($img, $transparent_color);

This will give you a transparent PNG image. Since I specified black as the transparent color, the circles will go to black near the edge, and you will only be able to use this on a dark background.

wimvds