--- gimp-painter--2.4.6.old/app/paint/gimpmixbrush.c Sat May 31 03:03:28 2008 +++ gimp-painter--2.4.6/app/paint/gimpmixbrush.c Thu Jun 5 07:35:16 2008 @@ -141,6 +141,7 @@ GimpPattern *texture, GimpRGB *paint_color, gdouble opacity, + gboolean fringe, gdouble grain, GimpUpdateFreqOptions *update_freq_options); @@ -161,6 +162,7 @@ gint y, gint drawable_x, gint drawable_y, + gboolean fringe, gdouble grain, const gboolean is_rgb, const gboolean has_alpha, @@ -647,6 +649,7 @@ paste_canvas (paint_core, drawable, texture, last_color, op, + mixbrush_options->texture_options->fringe, grain, paint_options->update_freq_options); } @@ -1015,6 +1018,7 @@ GimpPattern *texture, GimpRGB *paint_color, gdouble opacity, + gboolean fringe, gdouble grain, GimpUpdateFreqOptions *update_freq_options) { @@ -1029,7 +1033,7 @@ if (!brush_mask || !canvas_buf || opacity == 0.0 || - (texture && grain <= -1.0)) + (texture && !fringe && grain <= -1.0)) return; c_x = canvas_buf->x; @@ -1075,6 +1079,7 @@ texture->mask, x, y, dx, dy, + fringe, grain, is_rgb, has_alpha, @@ -1318,6 +1323,7 @@ gint y, gint drawable_x, gint drawable_y, + gboolean fringe, gdouble grain, const gboolean is_rgb, const gboolean has_alpha, @@ -1388,53 +1394,62 @@ texture_op = *(texture_row_data + _texture_off_x * texture_bytes) / 255.0; texture_op = CLAMP (texture_op + grain, 0.0, 1.0); - if (_mask_data[0] && texture_op > 0.0) + if (_mask_data[0]) { mask_op = _mask_data[0] / 255.0; - if (has_alpha && active_components[src_bytes - 1]) + if (fringe) { - src_op = _src_data[src_bytes - 1] / 255.0; - - /* workaround against insufficiency of opacity */ - /*if (paint_color->a > src_op) - op = pow (opacity, 1.0 / 1.5) * mask_op;*/ - gfloat n = paint_color->a - src_op; - guint32 _n = (*(guint32 *) &n) >> 31; - op = (opacity * _n + adjusted_opacity * (1 - _n)) * mask_op * texture_op; - - component = (paint_color->a * op + src_op * (1.0 - op)) * 255.0/* + error.a*/; - _src_data[src_bytes - 1] = component + .5; - /*_error.a += component - _src_data[src_bytes - 1];*/ + gdouble _mask_op = faster_pow (mask_op, 1.5); + texture_op = (texture_op * (1.0 - _mask_op) + _mask_op); } - else - src_op = 1.0; - - op = opacity * mask_op * texture_op; - paint_color_op = paint_color->a * op; - if (paint_color_op > 0.0) + if (texture_op) { - canvas_color_op = (1.0 - paint_color_op) * src_op; + if (has_alpha && active_components[src_bytes - 1]) + { + src_op = _src_data[src_bytes - 1] / 255.0; - factor1 = paint_color_op / (paint_color_op + canvas_color_op); - factor2 = 1.0 - factor1; + /* workaround against insufficiency of opacity */ + /*if (paint_color->a > src_op) + op = pow (opacity, 1.0 / 1.5) * mask_op;*/ + gfloat n = paint_color->a - src_op; + guint32 _n = (*(guint32 *) &n) >> 31; + op = (opacity * _n + adjusted_opacity * (1 - _n)) * mask_op * texture_op; + + component = (paint_color->a * op + src_op * (1.0 - op)) * 255.0/* + error.a*/; + _src_data[src_bytes - 1] = component + .5; + /*_error.a += component - _src_data[src_bytes - 1];*/ + } + else + src_op = 1.0; - component = _paint_color.r * factor1 + _src_data[0] * factor2/* + error.r*/; - _src_data[0] = component + .5; - /*_error.r += component - _src_data[0];*/ - if (is_rgb) + op = opacity * mask_op * texture_op; + paint_color_op = paint_color->a * op; + + if (paint_color_op > 0.0) { - component = _paint_color.g * factor1 + _src_data[1] * factor2/* + error.g*/; - _src_data[1] = component + .5; - /*_error.g += component - _src_data[1];*/ - - component = _paint_color.b * factor1 + _src_data[2] * factor2/* + error.b*/; - _src_data[2] = component + .5; - /*_error.b += component - _src_data[2];*/ + canvas_color_op = (1.0 - paint_color_op) * src_op; + + factor1 = paint_color_op / (paint_color_op + canvas_color_op); + factor2 = 1.0 - factor1; + + component = _paint_color.r * factor1 + _src_data[0] * factor2/* + error.r*/; + _src_data[0] = component + .5; + /*_error.r += component - _src_data[0];*/ + if (is_rgb) + { + component = _paint_color.g * factor1 + _src_data[1] * factor2/* + error.g*/; + _src_data[1] = component + .5; + /*_error.g += component - _src_data[1];*/ + + component = _paint_color.b * factor1 + _src_data[2] * factor2/* + error.b*/; + _src_data[2] = component + .5; + /*_error.b += component - _src_data[2];*/ + } } } - } + } _src_data += src_bytes; _mask_data++; } --- gimp-painter--2.4.6.old/app/paint/gimpmixbrushoptions.c Sat May 31 03:03:28 2008 +++ gimp-painter--2.4.6/app/paint/gimpmixbrushoptions.c Thu Jun 5 07:35:16 2008 @@ -29,6 +29,7 @@ #define MIXBRUSH_DEFAULT_USE_TEXTURE FALSE +#define MIXBRUSH_DEFAULT_TEXTURE_FRINGE FALSE #define MIXBRUSH_DEFAULT_TEXTURE_GRAIN 0.0 #define MIXBRUSH_DEFAULT_MAIN_COLOR_DENSITY 0.5 @@ -57,6 +58,7 @@ { PROP_0, PROP_USE_TEXTURE, + PROP_TEXTURE_FRINGE, PROP_TEXTURE_GRAIN, PROP_TEXTURE_GRAIN_PRESSURE_IN1, PROP_TEXTURE_GRAIN_PRESSURE_IN2, @@ -127,6 +129,11 @@ MIXBRUSH_DEFAULT_USE_TEXTURE, GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TEXTURE_FRINGE, + "texture-fringe", NULL, + MIXBRUSH_DEFAULT_TEXTURE_FRINGE, + GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_TEXTURE_GRAIN, "texture-grain", NULL, -1.0, 1.0, MIXBRUSH_DEFAULT_TEXTURE_GRAIN, @@ -337,6 +344,9 @@ case PROP_USE_TEXTURE: texture_options->use_texture = g_value_get_boolean (value); break; + case PROP_TEXTURE_FRINGE: + texture_options->fringe = g_value_get_boolean (value); + break; case PROP_TEXTURE_GRAIN: texture_options->grain = g_value_get_double (value); break; @@ -461,6 +471,9 @@ { case PROP_USE_TEXTURE: g_value_set_boolean (value, texture_options->use_texture); + break; + case PROP_TEXTURE_FRINGE: + g_value_set_boolean (value, texture_options->fringe); break; case PROP_TEXTURE_GRAIN: g_value_set_double (value, texture_options->grain); --- gimp-painter--2.4.6.old/app/paint/gimpmixbrushoptions.h Sat May 31 03:03:28 2008 +++ gimp-painter--2.4.6/app/paint/gimpmixbrushoptions.h Thu Jun 5 07:35:17 2008 @@ -51,6 +51,7 @@ typedef struct _GimpTextureOptions { gboolean use_texture; + gboolean fringe; gdouble grain; gdouble grain_pressure_in1; gdouble grain_pressure_in2; --- gimp-painter--2.4.6.old/app/tools/gimpmixbrushtool.c Sat May 31 03:03:28 2008 +++ gimp-painter--2.4.6/app/tools/gimpmixbrushtool.c Thu Jun 5 07:36:19 2008 @@ -49,6 +49,7 @@ GIMP_TYPE_MIXBRUSH_OPTIONS, gimp_mixbrush_options_gui, GIMP_PAINT_OPTIONS_CONTEXT_MASK | + GIMP_CONTEXT_PATTERN_MASK | GIMP_CONTEXT_GRADIENT_MASK, "gimp-mixbrush-tool", _("Mixbrush"), @@ -91,7 +92,7 @@ /* Texture configurations */ { - table = gtk_table_new (3, 4, FALSE); + table = gtk_table_new (3, 5, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 2); mixbrush_frame = gimp_prop_expanding_frame_new (config, "use-texture", "Use texture", table, NULL); @@ -103,8 +104,14 @@ 0, 0); gtk_widget_show (mixbrush_box); + mixbrush_button = gimp_prop_check_button_new (config, "texture-fringe", _("Apply fringe")); + gtk_table_attach (GTK_TABLE (table), mixbrush_button, 0, 3, 2, 3, + GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, + 0, 0); + gtk_widget_show (mixbrush_button); + gimp_prop_scale_entry_new (config, "texture-grain", - GTK_TABLE (table), 0, 2, + GTK_TABLE (table), 0, 3, _("Grain:"), 0.01, 0.1, 2, FALSE, -1.0, 1.0); @@ -114,7 +121,7 @@ GtkWidget *inner_table = gtk_table_new (3, 4, FALSE); gtk_container_add (GTK_CONTAINER (expander), inner_table); - gtk_table_attach (GTK_TABLE (table), expander, 0, 3, 3, 4, + gtk_table_attach (GTK_TABLE (table), expander, 0, 3, 4, 5, GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); @@ -389,9 +396,9 @@ gtk_box_pack_start (GTK_BOX (vbox), mixbrush_frame, FALSE, TRUE, 0); gtk_widget_show (mixbrush_frame); - mixbrush_button = gimp_prop_check_button_new (config, "remove-color", _("Remove background color")); + /*mixbrush_button = gimp_prop_check_button_new (config, "remove-color", _("Remove background color")); gtk_box_pack_start (GTK_BOX (vbox), mixbrush_button, FALSE, TRUE, 0); - gtk_widget_show (mixbrush_button); + gtk_widget_show (mixbrush_button);*/ return vbox; }