|
From: Daniel J S. <dan...@ie...> - 2007-02-03 04:49:51
|
Ethan Merritt wrote: > On Friday 02 February 2007 12:38, Hans-Bernhard Bröker wrote: > >>Ethan Merritt wrote: >> >>> gdImageShadedTriangle(gdImagePtr image, gdPoint *vertex, int *color); >> >>>That is, a filled triangle with interpolation of three separate colors >>>specified for the three vertices. >> >>Interpolation is quite a tricky business in color space, because there's >>no clear-cut idea what the curve to draw between two given points in >>colour space should be. To properly specify an interpolation mechanism, >>one needs to specify at least the coordinate system in which the >>interpolated surface in color-space is supposed to be flat. > > > That is an interesting point. > > I noted out in my feature request for libgd that it was unclear what > sort of interpolation could be done with an indexed colormap. The usual > shading interpolation routines assume either RGB or CMY colorspace. > But I think you've answered that question. The gnuplot PM3D grey > scale palette routines define a single scale within which interpolation > of the index value does make sense. The question then becomes, is > this linear ordering of index values maintained internally in libgd? I assume you are interested only in linear interpolation and not higher order approaches like 2D splines. Does gdlib have indexed colormaps? If not, a gradient triangle fill shouldn't be too difficult to implement. If we know the resolution of the PNG/JPEG then it should be straightforward. For this hidden surface thing I was messing around with I wrote some short routines to construct a 2D hyperplane in three dimensions given three points, then simply do a matrix multiply for all the points within the triangle, that gives the interpolated value. Then take that value and lookup the value in the indexed colormap. Then place that value in the PNG/JPEG image with some type of gdImage() routine (I assume). Dan |