On 2009-11-23 11:51-0800 Alan W. Irwin wrote:
> [...]From this quick tour of the SVG, QT, and cairo cases, I conclude we should
> support a new addition to our API which allows the user to draw a linear
> gradient within a rectangle. The suggested prototype of this API addition
> would look like this;
> void plgradient(PLBOOL itype, PLINT npts, PLFLT *pos, PLFLT *coord1,
> PLFLT *coord2, PLFLT *coord3, PLFLT *coord4, PLBOOL * rev,
> PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT angle);
> where arguments itype through rev have the same meanings as for plscmap1la;
> xmin, ymin, xmax, and ymax specify the rectangle in world coordinates; and
> angle (degrees) represents the direction of the gradient within that
> rectangle. The quadrant of the angle would specify which corners of the
> rectangle would correspond to the minimum and maximum of the gradient.
> [...]Comments are invited. In particular do you think that the proposed
> prototype for plgradient needs any changes?
I have just implemented a first try for plgradient (revision 10632). The
implementation is only of the software fallback (using plshades) at this
time. Thus, the driver work to use native gradients where applicable has
not been done yet.
The new pages 5-8 of example 25 demonstrate plgradient results for a variety
of window ranges.
N.B. I do not yet clip at the polygon boundary (because I am chasing a bug
in that clipping) so this example currently shows the full extent of the
gradient generated by plshades without that clipping.
Because I have decided to use whatever cmap1 has been set previously to
define the gradient and because the clipping limits have been generalized
from a rectangle to a polygon, the API for plgradient has now evolved to
c_plgradient( PLINT n, PLFLT *x, PLFLT *y, PLFLT angle );
where the first 3 arguments define the polygon clipping limit (just like
plfill), and angle is the angle of the linear gradient from the x axis.
For my next steps I plan to get clipping to work at the polygon boundary,
modify example 30 to use plgradient (which should produced identical results
to before for the software fallback case), and then implement use of the
native SVG gradient for the svg device driver (which should greatly improve
example 30 for that device compared to the software fallback method).
Comments on my initial implementation of this new PLplot gradient capability
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project