[GRASS-SVN] r68608 - in grass-addons/grass7/raster: r.colors.cubehelix r.colors.matplotlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jun 4 13:46:53 PDT 2016
Author: wenzeslaus
Date: 2016-06-04 13:46:53 -0700 (Sat, 04 Jun 2016)
New Revision: 68608
Modified:
grass-addons/grass7/raster/r.colors.cubehelix/r.colors.cubehelix.py
grass-addons/grass7/raster/r.colors.matplotlib/r.colors.matplotlib.py
Log:
r.colors.matplotlib and r.colors.cubehelix: multiply by >255 to get 255 as in color_rules.c
Modified: grass-addons/grass7/raster/r.colors.cubehelix/r.colors.cubehelix.py
===================================================================
--- grass-addons/grass7/raster/r.colors.cubehelix/r.colors.cubehelix.py 2016-06-04 20:38:14 UTC (rev 68607)
+++ grass-addons/grass7/raster/r.colors.cubehelix/r.colors.cubehelix.py 2016-06-04 20:46:53 UTC (rev 68608)
@@ -169,10 +169,12 @@
v1 = 100 * (crange - (cmax - v1)) / float(crange)
if discrete:
v2 = 100 * (crange - (cmax - v2)) / float(crange)
-
- r1 = int(r1 * 255)
- g1 = int(g1 * 255)
- b1 = int(b1 * 255)
+ # multiply to get 255 after integer
+ # assuming nobody uses smaller faction than 0.001
+ # taken from color_rules.c
+ r1 = int(r1 * 255.999)
+ g1 = int(g1 * 255.999)
+ b1 = int(b1 * 255.999)
rules.append(values_to_rule(value=v1, red=r1, green=g1,
blue=b1, percent=True))
if discrete:
Modified: grass-addons/grass7/raster/r.colors.matplotlib/r.colors.matplotlib.py
===================================================================
--- grass-addons/grass7/raster/r.colors.matplotlib/r.colors.matplotlib.py 2016-06-04 20:38:14 UTC (rev 68607)
+++ grass-addons/grass7/raster/r.colors.matplotlib/r.colors.matplotlib.py 2016-06-04 20:46:53 UTC (rev 68608)
@@ -119,10 +119,12 @@
v1 = 100 * (crange - (cmax - v1)) / float(crange)
if discrete:
v2 = 100 * (crange - (cmax - v2)) / float(crange)
-
- r1 = int(r1 * 255)
- g1 = int(g1 * 255)
- b1 = int(b1 * 255)
+ # multiply to get 255 after integer
+ # assuming nobody uses smaller faction than 0.001
+ # taken from color_rules.c
+ r1 = int(r1 * 255.999)
+ g1 = int(g1 * 255.999)
+ b1 = int(b1 * 255.999)
rules.append(values_to_rule(value=v1, red=r1, green=g1,
blue=b1, percent=True))
if discrete:
More information about the grass-commit
mailing list