def clicked(self, widget, event, hexcolor):
        """Callback for each color.
        @widget: Callback gtkwidget.
        @event: Callback gtkevent.
        @hexcolor: hexadecimal color like 57ABFF."""

        rgbcolor = convert.hex_rgb(hexcolor)
        main.color.set_color_from_rgb(rgbcolor)
Exemple #2
0
    def set_color_from_hex(self, hexa):
        """Set the foreground color from an hexadecimal string.
        @hexa: A string of six chars defining a color in hexadecimal format."""

        self.hex = hexa
        self.rgb = convert.hex_rgb(hexa)
        self.hsv = convert.rgb_hsv(self.rgb)
        self.update_external()
Exemple #3
0
    def set_hex(self, hexa):
        """Evaluate an hexadecimal string and set the foreground color.
        @hexa: A valid hexadecimal string of six chars."""

        if not re.search("^[0-9a-fA-F]{6}$", hexa): return
        self.hex = hexa
        rgb = convert.hex_rgb(hexa)
        self.set_color_from_hex(hexa)
    def reevaluate(self):
        
        #get pixbuf array
        pixBufArray = main.documents.active.layers.active.pixbuf.get_pixels_array()
                
        #get pixData
        pixData = main.documents.active.layers.active.pixData
                
        #for each k in range(len(pixel buffer array)) 
        for k in range(len(pixBufArray)):
            #for each j in range(len(k))
            for j in range(len(pixBufArray[k])):
                
                #initialize pixel values to be set to 0
                finalR = finalG = finalB = finalA = 0
                
                #handle for current column
                thisPixel = pixData[k][j]
                
                #initialize final values to that of the first element
                if(len(thisPixel) != 0):
                    finalR,finalG,finalB = convert.hex_rgb(self.palette[thisPixel[0][0]])
                    finalA = thisPixel[0][1]
                    
                
                #for i in range(len(j) - 1)
                for i in range(len(thisPixel) - 1):
                    
#                    #get RBG of next color entry from it's hex value
                    nextR,nextG,nextB = convert.hex_rgb(self.palette[thisPixel[i + 1][0]])
                    
                    #get alpha value of next entry
                    nextA = thisPixel[i + 1][1]
                    
                    #get master alpha value of next entry
                    nextAM = thisPixel[i + 1][2]
                    
                    
                    
                    #final R
                    finalR = self.compositeRGB(finalR,nextR,finalA,nextA,nextAM)
                    #final G
                    finalG = self.compositeRGB(finalG,nextG,finalA,nextA,nextAM)
                    #final B
                    finalB = self.compositeRGB(finalB,nextB,finalA,nextA,nextAM)
                    #final A
                    finalA = core.getOverAlpha(float(finalA),float(thisPixel[i + 1][1]))

                    
            
                    
                #insert into pixBuf Array               
                pixBufArray[k][j][0] = finalR
                pixBufArray[k][j][1] = finalG
                pixBufArray[k][j][2] = finalB
                pixBufArray[k][j][3] = finalA


        
        #new pixBuf from array
        main.documents.active.layers.active.pixbuf = gtk.gdk.pixbuf_new_from_array(pixBufArray, gtk.gdk.COLORSPACE_RGB, 8)
        
        #update pixbuf pointer
        main.documents.active.layers.active.update_pointer()
        
        #redraw expired area
        main.documents.active.canvas.redraw_all()
        main.documents.active.actions.end([0,0,699,699])