def addSlice(self, fields):
        """Add a slice to this image"""
        
        # Returns a tuple of adjusted r, g, b integers given tuple of integers.
        def computeRgbValues(rgb, saturation, brightness):
            return map((lambda x:
                        adjustColorComponent(x, saturation, brightness)), rgb)
        
        # Returns an integer value for the given component, adjusted for
        # brightness and saturation.
        def adjustColorComponent(component, saturation, brightness):
            answer = component * saturation + brightness * 255.0 * \
                     (1 - saturation)
            return int(round(answer))
        
        width = fields["width"]
        height = fields["height"]
        
        saturation = fields["saturation"]
        brightness = fields["brightness"]
        
        upperHeight = int(round(height - (height * fields["lowerSize"])))
        
        tl = (self.__xOffset, upperHeight + 1)
        br = (self.__xOffset + width, height)
        lowerColor = self.__image.colorAllocate(
            computeRgbValues(fields["lowerColor"],  saturation, brightness))
        self.__image.filledRectangle(tl, br, lowerColor)
        
        tl = (self.__xOffset, upperHeight)
        br = (self.__xOffset + width, upperHeight + 1)
        dividerColor = self.__image.colorAllocate(
            computeRgbValues(fields["dividerColor"], saturation, brightness))
        self.__image.filledRectangle(tl, br, dividerColor)
        
        tl = (self.__xOffset, 0)
        br = (self.__xOffset + width, upperHeight)
        upperColor = self.__image.colorAllocate(
            computeRgbValues(fields["upperColor"],  saturation, brightness))
        self.__image.filledRectangle(tl, br, upperColor)
        
        self.__xOffset += width
        
        return
dataset/ETHPy150Open longnow/longview/sliceMaker.py/SlicedImage.addSlice/original