From f27b20896db3242aff94bda448d3c17b3006e918 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 2 Sep 2014 02:04:17 +0200 Subject: add alternative to the libgamma_crtc_set_gamma_ramps_f functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libgamma_method.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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) -- cgit v1.2.3-70-g09d2