aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-09-02 02:04:17 +0200
committerMattias Andrée <maandree@operamail.com>2014-09-02 02:04:17 +0200
commitf27b20896db3242aff94bda448d3c17b3006e918 (patch)
treedea2359517b2c32fde3e4de2bc4c132261ce3e98
parentadd class gamma ramps (diff)
downloadpylibgamma-f27b20896db3242aff94bda448d3c17b3006e918.tar.gz
pylibgamma-f27b20896db3242aff94bda448d3c17b3006e918.tar.bz2
pylibgamma-f27b20896db3242aff94bda448d3c17b3006e918.tar.xz
add alternative to the libgamma_crtc_set_gamma_ramps_f functions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-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)