laziness, impatience, and hubris | |
PerlMonks |
Pretty graphics generationby oakbox (Chaplain) |
on Aug 02, 2004 at 01:37 UTC ( [id://379166]=perlmeditation: print w/replies, xml ) | Need Help?? |
I've spent a lot of frustrating time trying to find the 'best' way to create pretty graphics from data in my perl programs.
Spent a lot of time with GD.pm, it has a lot of easy-to-use modules built around it, but the graphics are always strongly aliased. There are tricks to lessen the aliasing, but nothing is perfect: Always a lot of hassle, no matter how much tweaking you do. At one point, I looked at using POV-Ray files. POV-Ray graphing example Generating the text format file in perl, then doing a not-so-quick system call to ask POV-Ray to render the image for me. This was slow and 3-d only works for a limited range of information graphics. I'm writing this because I'm bursting at the seams with excitement because I HAVE FOUND THE ANSWER: generating SVG files and using ImageMagik to convert those into whatever else you want (png,jpg,pdf,etc). SVG uses XML files and the syntax isn't overly weird. I started out using a WYSIWYG vector graphic program that exports SVG code http://www.sodipodi.com/, then manipulating the code in perl to produce what I was looking for. Mind you, as with most WYSIWYG's, I was able to reduce the auto-generated code by over 80%. But I learn better by having an example and tweaking it. To introduce you to the joys of this format, if you are unfamiliar with it; here's an example graphic produced by running a perl-generated svg file through convert via a system call: http://www.oakbox.com/svg2png.png And here is the svg file: http://www.oakbox.com/svg2png.svg. And I get all this goodness by running
So, to sum up:
Back to
Meditations
|
|