Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: What would you guys recommend for generating graphic-based output?

by FrankRizzo (Acolyte)
on Jan 25, 2005 at 20:14 UTC ( #425028=note: print w/replies, xml ) Need Help??


in reply to Re: What would you guys recommend for generating graphic-based output?
in thread What would you guys recommend for generating graphic-based output?

OK, the more important question, does anyone have any links to examples? I'm a "string in, string out" kinda guy, trying to get by with as little graphics work as I possibly can, as this is the LAST ITEM on the project plan, and I'm ready to be done! Thanks Guys! Frank
  • Comment on Re^2: What would you guys recommend for generating graphic-based output?

Replies are listed 'Best First'.
Re^3: What would you guys recommend for generating graphic-based output?
by sleepingsquirrel (Hermit) on Jan 25, 2005 at 22:29 UTC
    Needs ghostscript installed, produces a file "tmp.png".
    #!/usr/bin/perl -w %stats = (Foo => 14, Bar => 10, Baz => 5, Box => 8); $title = "Widgets, Inc"; $ps_preamble = <<PS_END; %!PS-Adobe-2.0 /big /Helvetica findfont 20 scalefont def /tiny /Helvetica findfont 9 scalefont def /box { newpath moveto lineto lineto lineto closepath } def 0 setgray big setfont 612 ($title) stringwidth pop sub 2 div 648 moveto ($title) show 1 setlinewidth 72 72 72 720 540 720 540 72 box stroke tiny setfont PS_END open (GS, "|gs -dSAFER -dBATCH -dNOPAUSE -q -r80 -sDEVICE=png16m". " -sOutputFile=tmp.png - ") or die "Can't start Ghostscript" +; print GS $ps_preamble; my $n = keys %stats; my $w = 396/$n; my $i=0; for (keys %stats) { my $x = $i*$w+126; my $y = $stats{$_} * 30 + 108; print GS "$x 90 moveto\n($_) show\n"; print GS "0.5 0 0.8 setrgbcolor\n"; print GS "$x 108 ", "$x $y ", $x+$w/2, " $y ", $x+$w/2, " 108 box fill\n"; print GS "0 setgray\n"; $i++; } print GS "showpage\n"; close(GS);


    -- All code is 100% tested and functional unless otherwise noted.
      This is what the output looks like for the above program.
Re^3: What would you guys recommend for generating graphic-based output?
by zentara (Archbishop) on Jan 26, 2005 at 11:55 UTC
    I'll post a little tk snippet later today, which exports a canvas full of text to png. (I'll have to make one up :-) ) Also I just noticed a new version of "pngwriter" was just announced on freshmeat.

    About: The PNGwriter library, which requires libpng, allows you to plot to a 48-bit PNG file, saving it directly to disk. Plotting is as easy as specifying the red, green, and blue values and the x, y coordinates of the pixel. It includes functions for plotting simple geometric shapes (circle, rect, line), plotting text (UTF-8 support for Asian languages), reading the colour of a pixel, reading in a whole PNG file (great for image analysis), plotting and reading in HSV colourspace, and many others that might come in handy.

    pngwriter


    I'm not really a human, but I play one on earth. flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://425028]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2022-09-24 22:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (116 votes). Check out past polls.

    Notices?