Forum OpenACS Development: Nsgd -- new version (finally)

Collapse
Posted by Matthew Burke on

Nsgd is a module for AOLserver that allows you to create graphics on the fly via a Tcl binding to Tom Boutell's Gd library. There is a new version of nsgd in the CVS repository at [1]. So you could have something like the URL http://example.com/smiley invoke the following script:


set img [gd create 300 300]
set black [gd color new $img 0 0 0]
set red [gd color new $img 255 0 0]
set blue [gd color new $img 0 0 255]

gd filledarc $img $blue 150 150 300 300 0 360
gd filledarc $img $red 100 100 50 50 0 360
gd filledarc $img $red 200 100 50 50 0 260
gd arc $img $red 150 0 300 300 90 180

gd returnPNG $img

gd destroy $img

would yield a PNG of a smiley face (more or less)

I'd like to thank Richard Kotal for sending me a number of bug fixes and implementations of missing functionality. That spurred me on to some additional coding and I can now report that nsgd supports roughly 95% of the functionality of gd version 2.0.33.

There are a few things on which I would appreciate some feedback:

  1. The current API is a jumble. Mostly I just went with the "style" inherited from gdtclft. Thoughts on a more logical organizing of the API are appreciated, particularly thoughts on using sub-commands versus commands with tediously long names.

    For example:

    • gd color new vs. gd newColor
    • gd filledpoygon, gd polygon, gd openpolygon vs. gd polygon open, gd polygon fill, gd polygon (or maybe something like gd polygon -fill)

  2. Thoughts on how to code things so that images can be put into nsv's. I haven't looked at it in depth, so maybe it's simple, but I think it would be an important addition.

A few other random things from the TODO file: integrating with nsgdchart (ok, you can "integrate" now---nsgdchart writes graphs to files and then you can use nsgd commands to read the files in and manipulate them further), autoconf the makefile, configuring font path (and other things?) via ns_section/ns_param, ...

Matt

P.S. The on-line demos mentioned in the documentation aren't on-line. As soon as I have a chance to put together something moderately impressive, I will get it on-line and update the docs.

[1] http://cvs.sourceforge.net/viewcvs.py/aolserver/nsgd/
Collapse
Posted by Nima Mazloumi on
This sounds nice. I am looking for a library to create reports just like JasperReports or JFreeChart allows for Java. The nice thing there is that you can render either HTML or PDF.

Has anyone found something similiar for tcl or the aolserver?

Collapse
Posted by Nick Carroll on
Matthew,

With respect to your API, I'd prefer using "gd polygon -fill".

The module looks great though! Certainly useful until SVG becomes mainstream.

Cheers,
Nick.