summaryrefslogtreecommitdiff
path: root/color
diff options
context:
space:
mode:
authorAnthony LaTorre <tlatorre9@gmail.com>2011-08-10 00:20:23 -0400
committerAnthony LaTorre <tlatorre9@gmail.com>2011-08-10 00:20:23 -0400
commitea5cc8e4e0e9bd1d1a1e5e7140c0022a8bd2a59d (patch)
tree9f56dc3201743d33f4ca2f0d5a9446a3e4597fa9 /color
parent0f0028484c3b8168d54c4c8b0f490cc573a6190e (diff)
downloadchroma-ea5cc8e4e0e9bd1d1a1e5e7140c0022a8bd2a59d.tar.gz
chroma-ea5cc8e4e0e9bd1d1a1e5e7140c0022a8bd2a59d.tar.bz2
chroma-ea5cc8e4e0e9bd1d1a1e5e7140c0022a8bd2a59d.zip
add the ability to cache a geometry along with its bounding volume hierarchy. cached files are stored in $HOME/.chroma. fixed the timeit() decorator so that the decorated function is still able to pass back a return value.
Diffstat (limited to 'color')
-rw-r--r--color/colormap.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/color/colormap.py b/color/colormap.py
index e5bd73e..6f3e056 100644
--- a/color/colormap.py
+++ b/color/colormap.py
@@ -1,13 +1,20 @@
import numpy as np
import matplotlib.cm as cm
-def map_to_color(a, range=None, map=cm.hsv):
+def map_to_color(a, range=None, map=cm.hsv, weights=None):
a = np.asarray(a)
if range is None:
range = (a.min(), a.max())
ax = (a - range[0])/(range[1]-range[0])
- rgba = (map(ax)*255).astype(np.uint32)
+ frgba = map(ax)
+
+ if weights is not None:
+ frgba[:,0] *= weights
+ frgba[:,1] *= weights
+ frgba[:,2] *= weights
+
+ rgba = (frgba*255).astype(np.uint32)
return rgba[:,0] << 16 | rgba[:,1] << 8 | rgba[:,2]