TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Pie chart w/ Anti-Aliasing (http://www.talkphp.com/advanced-php-programming/3728-pie-chart-w-anti-aliasing.html)

Orc 12-07-2008 01:51 AM

Pie chart w/ Anti-Aliasing
 
Since I'm kinda crud at math, how should I make a pie chart with Anti Aliasing, and by math I mean looping through each pixel to make the circular shape of a slice of pie, or so so.

Wildhoney 12-07-2008 02:38 AM

Our resident GD guru, Rendair -- who I haven't seen in a while and miss dearly, wrote an article on pie charts with the GD library. Hopefully he'll make a return to TalkPHP and tell us all how to make it anti-aliased!

Orc 12-07-2008 09:02 AM

Quote:

Originally Posted by Wildhoney (Post 20312)
Our resident GD guru, Rendair -- who I haven't seen in a while and miss dearly, wrote an article on pie charts with the GD library. Hopefully he'll make a return to TalkPHP and tell us all how to make it anti-aliased!

The problem with your post is, that is a tutorial on bar charts. ;P

Wildhoney 12-07-2008 04:06 PM

You're right. Sorry about that, it was a bit late when I posted.

c-through 12-07-2008 06:58 PM

There is a way using the Google chart API and I found a nice tut on it to :-P
http://www.talkphp.com/general/1695-...chart-api.html
But since we want to make the chart on our own here is what I would suggest to do something like that:

PHP Code:

header('Content-type: image/png');
$handle imagecreate(200,200);
$background=imagecolorallocate($handle,000,000,000);
$red=imagecolorallocate($handle,255,0,0);
$green=imagecolorallocate($handle,0,255,0);
$blue=imagecolorallocate($handle,0,0,255);
imagefilledarc($handle,100,100,200,200,0,90,$greenIMG_ARC_PIE);
imagefilledarc($handle,100,100,200,200,90,240,$redIMG_ARC_PIE);
imagefilledarc($handle,100,100,200,200,240,360,$blueIMG_ARC_PIE);
imagepng($handle); 

Just saw you are looking for an antialiasing solution...
Ok forget the script on top, one way would be supersampling, but creating a aa image from scratch :-/ Don't have an good solution in my mind (Having a serious hangover, and need some sleep). But I do have a script from someone else creating antialiased arcs as far as I remember. Maybe you can use it?!

http://pastebin.com/m6fdecadf

And now I take some Panado and go sleep...


All times are GMT. The time now is 08:32 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0