|
From: <hez...@us...> - 2011-04-17 22:00:59
|
Revision: 11709
http://plplot.svn.sourceforge.net/plplot/?rev=11709&view=rev
Author: hezekiahcarty
Date: 2011-04-17 22:00:53 +0000 (Sun, 17 Apr 2011)
Log Message:
-----------
The plshades and plimage families now support color ranges
These functions and their relatives (plimagefr, plfshades, etc.) now
respect the color map 1 range specified by plscmap1_range.
plgradient still needs to be updated, but it will be somewhat more tricky
because it involves adjustments to plot device code.
Modified Paths:
--------------
trunk/src/plimage.c
trunk/src/plshade.c
Modified: trunk/src/plimage.c
===================================================================
--- trunk/src/plimage.c 2011-04-17 22:00:13 UTC (rev 11708)
+++ trunk/src/plimage.c 2011-04-17 22:00:53 UTC (rev 11709)
@@ -215,6 +215,8 @@
PLFLT datum;
// Color palette 0 color in use before the plimage* call
PLINT init_color;
+ // Color range
+ PLFLT color_min, color_max, color_range;
if ( plsc->level < 3 )
{
@@ -244,6 +246,11 @@
idataops->minmax( idatap, nx, ny, &zmin, &zmax );
}
+ // Calculate the size of the color range to use
+ color_min = plsc->cmap1_min;
+ color_max = plsc->cmap1_max;
+ color_range = color_max - color_min;
+
// Go through the image values and scale them to fit in
// the COLOR_MIN to COLOR_MAX range.
// Any values greater than valuemax are set to valuemax,
@@ -257,7 +264,7 @@
if ( valuemin == valuemax )
{
// If valuemin == valuemax, avoid dividing by zero.
- z[ix * ny + iy] = ( COLOR_MAX + COLOR_MIN ) / 2.0;
+ z[ix * ny + iy] = ( color_max + color_min ) / 2.0;
}
else
{
@@ -277,9 +284,9 @@
{
datum = valuemax;
}
- // Set to a value scaled between COLOR_MIN and COLOR_MAX.
+ // Set to a value scaled between color_min and color_max.
z[ix * ny + iy] =
- ( datum - valuemin + COLOR_MIN ) / ( valuemax - valuemin ) * COLOR_MAX;
+ color_min + ( datum - valuemin + COLOR_MIN ) / ( valuemax - valuemin ) * COLOR_MAX * color_range;
}
}
}
Modified: trunk/src/plshade.c
===================================================================
--- trunk/src/plshade.c 2011-04-17 22:00:13 UTC (rev 11708)
+++ trunk/src/plshade.c 2011-04-17 22:00:53 UTC (rev 11709)
@@ -248,12 +248,18 @@
{
PLFLT shade_min, shade_max, shade_color;
PLINT i, init_color, init_width;
+ PLFLT color_min, color_max, color_range;
+ // Color range to use
+ color_min = plsc->cmap1_min;
+ color_max = plsc->cmap1_max;
+ color_range = color_max - color_min;
+
for ( i = 0; i < nlevel - 1; i++ )
{
shade_min = clevel[i];
shade_max = clevel[i + 1];
- shade_color = i / (PLFLT) ( nlevel - 2 );
+ shade_color = color_min + i / (PLFLT) ( nlevel - 2 ) * color_range;
// The constants in order mean
// (1) color map1,
// (0, 0, 0, 0) all edge effects will be done with plcont rather
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|