From 18726b28d0286640d887d5dfe9e74a0972bc1bd0 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Fri, 20 Dec 2013 15:23:30 +0000 Subject: Fix bucket color - SL #4622 Divide and multiply the color numbers to use them in the different formats needed produce rounding errors and change the color. Store the bucket colors as integer in a separated property. Signed-off-by: Gonzalo Odiard --- diff --git a/Area.py b/Area.py index 3f8b3e0..a0ebf56 100644 --- a/Area.py +++ b/Area.py @@ -169,6 +169,7 @@ class Area(Gtk.DrawingArea): 'fill': True, 'cairo_stroke_color': (0.0, 0.0, 0.0, 1.0), 'cairo_fill_color': (0.0, 0.0, 0.0, 1.0), + 'bucket_color': (0, 0, 0), 'alpha': 1.0, 'vertices': 6.0, 'font_description': 'Sans 12'} @@ -818,13 +819,13 @@ class Area(Gtk.DrawingArea): self.d.clear_control_points() def flood_fill(self, x, y): - stroke_color = self.tool['cairo_stroke_color'] - r, g, b = stroke_color[0], stroke_color[1], stroke_color[2] + bucket_color = self.tool['bucket_color'] + r, g, b = bucket_color[0], bucket_color[1], bucket_color[2] # pack the color in a int as 0xAARRGGBB - fill_color = 0xff000000 + (int(r * 255 * 65536) + - int(g * 255 * 256) + - int(b * 255)) + fill_color = 0xff000000 + (int(r / 255 * 65536) + + int(g / 255 * 256) + + int(b / 255)) logging.error('fill_color %d', fill_color) # load a array with the surface data @@ -1169,6 +1170,8 @@ class Area(Gtk.DrawingArea): red = color.red / 65535.0 green = color.green / 65535.0 blue = color.blue / 65535.0 + # for bucket operation, store the integer values + self.tool['bucket_color'] = (color.red, color.green, color.blue) self.tool['cairo_stroke_color'] = (red, green, blue, alpha) rgba = Gdk.RGBA() rgba.red, rgba.green, rgba.blue, rgba.alpha = red, green, blue, alpha diff --git a/toolbox.py b/toolbox.py index 78cf76c..c0ab27b 100644 --- a/toolbox.py +++ b/toolbox.py @@ -429,8 +429,6 @@ class ToolsToolbarBuilder(): self.set_tool(button, self._selected_tool_name) def _color_button_cb(self, widget, pspec): - logging.error('ToolsToolbarBuilder._color_button_cb') - new_color = widget.get_color() self._activity.area.set_stroke_color(new_color) -- cgit v0.9.1