Hi,
I'd like to customize the data color in a surface plot using a color
gradient going from a QColor cMax to a QColor cMin (like the one in the
default standard color implementation, going from red to blue).
I've tried to follow the approach from the enrichements example. Using the
following code I only get an uniform green color:
void Graph3D::setColor()
{
Qwt3D::ColorVector cv;
QColor cMax=QColor(green); // color for the max data
QColor cMin=QColor (red); // color for the min data
unsigned int size=255;
double dsize = size;
int r1=cMax.red();
int r2=cMin.red();
double stepR = abs(r1-r2)/dsize;
int g1=cMax.green();
int g2=cMin.green();
double stepG = abs(g1-g2)/dsize;
int b1=cMax.blue();
int b2=cMin.blue();
double stepB = abs(b1-b2)/dsize;
RGBA rgb;
for (unsigned int i=0; i<size; i++)
{
rgb.r = r1-i*stepR;
rgb.g = g1-i*stepG;
rgb.b = b1-i*stepB;
cv.push_back(rgb);
}
StandardColor* col = new StandardColor(sp);
col->setColorVector(cv);
sp->setDataColor(col);
sp->updateData();
sp->updateGL();
}
Could anyone give me a hint, please?
Thanks in advance,
Ion
From: Micha B. <kri...@us...> - 2005-01-01 21:12:48
Saturday, January 1, 2005, 22:03:54, Micha Bieber wrote:
>> double stepR = abs(r1-r2)/dsize;
> ^^^
> This gives an integer division resulting in 0 (r1-r2<255) or 1.
Sorry, dsize is of course a double ...
Micha
--
From: Micha B. <kri...@us...> - 2005-01-01 21:19:10
.. but
> double stepR = abs(r1-r2)/dsize;
is > 0
Later in your loop:
> rgb.r = r1-i*stepR;
sgives value <= 0. These values will be clamped, because a color
component has values 0.0 <= comp_col <= 1.0;
Micha
--