aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libgamma_method.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libgamma_method.py b/src/libgamma_method.py
index ce92adb..b702151 100644
--- a/src/libgamma_method.py
+++ b/src/libgamma_method.py
@@ -713,6 +713,19 @@ class GammaRamps:
if indices < 0:
indices += self.__size
self.__set(self.__ramp, indices, values)
+
+ def map(self, function):
+ '''
+ Modify the entire ramp using a function that
+ maps encoding value to output value.
+
+ @param function:(float)→int|float Function that takes the encoding value as a
+ [0, 1] floating point and returns its output
+ value as the format using in the gamma ramp.
+ '''
+ max_i = self.__size - 1
+ for i in range(self.__size):
+ self.__set(self.__ramp, i, function(i / max_i))
self.red = Ramp(red, red_size, depth)
self.green = Ramp(green, green_size, depth)