[gimp/gimp-2-10] app: add "line-art-max-grow" property to the bucket fill options.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add "line-art-max-grow" property to the bucket fill options.
- Date: Wed, 19 Dec 2018 15:44:49 +0000 (UTC)
commit b00580d4b1e69588176fa872f2df5b47739c8911
Author: Jehan <jehan girinstud io>
Date: Thu Nov 22 18:13:58 2018 +0100
app: add "line-art-max-grow" property to the bucket fill options.
When flooding the line art, we may overflood it in sample merge (which
would use color in the line art computation). And if having all colors
on the same layer, this would go over other colors (making the wrong
impression that the line art leaked).
This new option is mostly to keep some control over the mask growth.
Usually a few pixels is enough for most styles of drawing (though we
could technically allow for very wide strokes).
(cherry picked from commit eb042e6c8769c7938fc18a7bc6b872969650089d)
app/core/gimpchannel-select.c | 2 +-
app/core/gimpdrawable-bucket-fill.c | 8 +++-
app/core/gimpdrawable-bucket-fill.h | 6 ++-
app/core/gimppickable-contiguous-region.c | 68 +++++++++++++++++--------------
app/core/gimppickable-contiguous-region.h | 7 ++--
app/pdb/drawable-edit-cmds.c | 2 +-
app/tools/gimpbucketfilloptions.c | 24 +++++++++++
app/tools/gimpbucketfilloptions.h | 1 +
app/tools/gimpbucketfilltool.c | 1 +
app/tools/gimpfuzzyselecttool.c | 2 +-
pdb/groups/drawable_edit.pdb | 2 +-
11 files changed, 82 insertions(+), 41 deletions(-)
---
diff --git a/app/core/gimpchannel-select.c b/app/core/gimpchannel-select.c
index 6abe01f960..af7f2e1bfa 100644
--- a/app/core/gimpchannel-select.c
+++ b/app/core/gimpchannel-select.c
@@ -522,7 +522,7 @@ gimp_channel_select_fuzzy (GimpChannel *channel,
select_transparent,
select_criterion,
diagonal_neighbors,
- 0.92, /* TODO */
+ 0.92, 3, /* TODO */
x, y);
if (! sample_merged)
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index 7025018ff8..6be89c59e8 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -58,7 +58,8 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
gdouble threshold,
gboolean sample_merged,
gboolean diagonal_neighbors,
- gfloat stroke_threshold,
+ gfloat line_art_stroke_threshold,
+ gint line_art_max_grow,
gdouble seed_x,
gdouble seed_y)
{
@@ -79,7 +80,8 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
fill_transparent, fill_criterion,
threshold, sample_merged,
diagonal_neighbors,
- stroke_threshold,
+ line_art_stroke_threshold,
+ line_art_max_grow,
seed_x, seed_y, NULL,
&mask_x, &mask_y, &width, &height);
@@ -146,6 +148,7 @@ gimp_drawable_get_bucket_fill_buffer (GimpDrawable *drawable,
gboolean sample_merged,
gboolean diagonal_neighbors,
gfloat stroke_threshold,
+ gint max_grow,
gdouble seed_x,
gdouble seed_y,
GeglBuffer **mask_buffer,
@@ -208,6 +211,7 @@ gimp_drawable_get_bucket_fill_buffer (GimpDrawable *drawable,
fill_criterion,
diagonal_neighbors,
stroke_threshold,
+ max_grow,
(gint) seed_x,
(gint) seed_y);
if (mask_buffer && *mask_buffer)
diff --git a/app/core/gimpdrawable-bucket-fill.h b/app/core/gimpdrawable-bucket-fill.h
index 7b6cae9888..9163d3ce87 100644
--- a/app/core/gimpdrawable-bucket-fill.h
+++ b/app/core/gimpdrawable-bucket-fill.h
@@ -29,7 +29,8 @@ void gimp_drawable_bucket_fill (GimpDrawable *drawabl
gdouble threshold,
gboolean sample_merged,
gboolean diagonal_neighbors,
- gfloat stroke_threshold,
+ gfloat line_art_stroke_threshold,
+ gint line_art_max_grow,
gdouble x,
gdouble y);
GeglBuffer * gimp_drawable_get_bucket_fill_buffer (GimpDrawable *drawable,
@@ -42,7 +43,8 @@ GeglBuffer * gimp_drawable_get_bucket_fill_buffer (GimpDrawable *drawabl
gdouble threshold,
gboolean sample_merged,
gboolean diagonal_neighbors,
- gfloat stroke_threshold,
+ gfloat line_art_stroke_threshold,
+ gint line_art_max_grow,
gdouble seed_x,
gdouble seed_y,
GeglBuffer **mask_buffer,
diff --git a/app/core/gimppickable-contiguous-region.c b/app/core/gimppickable-contiguous-region.c
index a56b4b8e48..097a495dd5 100644
--- a/app/core/gimppickable-contiguous-region.c
+++ b/app/core/gimppickable-contiguous-region.c
@@ -49,7 +49,8 @@ typedef struct
{
gint x;
gint y;
- gfloat dist;
+ gfloat radius;
+ gint level;
} BorderPixel;
@@ -125,7 +126,8 @@ static void line_art_result_free (GimpPickableLineArtAsyncResult
static void line_art_queue_pixel (GQueue *queue,
gint x,
gint y,
- gfloat dist);
+ gfloat radius,
+ gint level);
/* public functions */
@@ -310,6 +312,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
GimpSelectCriterion select_criterion,
gboolean diagonal_neighbors,
gfloat stroke_threshold,
+ gint flooding_max,
gint x,
gint y)
{
@@ -448,14 +451,14 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y - 1;
if (mask[nx + ny * width] != 0.0)
{
- line_art_queue_pixel (queue, x, y, thickness);
+ line_art_queue_pixel (queue, x, y, thickness, 1);
continue;
}
}
ny = y;
if (mask[nx + ny * width] != 0.0)
{
- line_art_queue_pixel (queue, x, y, thickness);
+ line_art_queue_pixel (queue, x, y, thickness, 1);
continue;
}
if (y < height - 1)
@@ -463,7 +466,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y + 1;
if (mask[nx + ny * width] != 0.0)
{
- line_art_queue_pixel (queue, x, y, thickness);
+ line_art_queue_pixel (queue, x, y, thickness, 1);
continue;
}
}
@@ -476,14 +479,14 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y - 1;
if (mask[nx + ny * width] != 0.0)
{
- line_art_queue_pixel (queue, x, y, thickness);
+ line_art_queue_pixel (queue, x, y, thickness, 1);
continue;
}
}
ny = y;
if (mask[nx + ny * width] != 0.0)
{
- line_art_queue_pixel (queue, x, y, thickness);
+ line_art_queue_pixel (queue, x, y, thickness, 1);
continue;
}
if (y < height - 1)
@@ -491,7 +494,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y + 1;
if (mask[nx + ny * width] != 0.0)
{
- line_art_queue_pixel (queue, x, y, thickness);
+ line_art_queue_pixel (queue, x, y, thickness, 1);
continue;
}
}
@@ -502,7 +505,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y - 1;
if (mask[nx + ny * width] != 0.0)
{
- line_art_queue_pixel (queue, x, y, thickness);
+ line_art_queue_pixel (queue, x, y, thickness, 1);
continue;
}
}
@@ -511,7 +514,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y + 1;
if (mask[nx + ny * width] != 0.0)
{
- line_art_queue_pixel (queue, x, y, thickness);
+ line_art_queue_pixel (queue, x, y, thickness, 1);
continue;
}
}
@@ -525,6 +528,9 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
if (mask[c->x + c->y * width] != 1.0)
{
mask[c->x + c->y * width] = 1.0;
+ if (c->level >= flooding_max)
+ /* Do not overflood under line arts. */
+ continue;
if (c->x > 0)
{
nx = c->x - 1;
@@ -533,21 +539,21 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
- distmap[nx + ny * width] < c->dist)
- line_art_queue_pixel (queue, nx, ny, c->dist);
+ distmap[nx + ny * width] < c->radius)
+ line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
}
ny = c->y;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
- distmap[nx + ny * width] < c->dist)
- line_art_queue_pixel (queue, nx, ny, c->dist);
+ distmap[nx + ny * width] < c->radius)
+ line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
if (c->y < height - 1)
{
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
- distmap[nx + ny * width] < c->dist)
- line_art_queue_pixel (queue, nx, ny, c->dist);
+ distmap[nx + ny * width] < c->radius)
+ line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
}
}
if (c->x < width - 1)
@@ -558,21 +564,21 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
- distmap[nx + ny * width] < c->dist)
- line_art_queue_pixel (queue, nx, ny, c->dist);
+ distmap[nx + ny * width] < c->radius)
+ line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
}
ny = c->y;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
- distmap[nx + ny * width] < c->dist)
- line_art_queue_pixel (queue, nx, ny, c->dist);
+ distmap[nx + ny * width] < c->radius)
+ line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
if (c->y < height - 1)
{
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
- distmap[nx + ny * width] < c->dist)
- line_art_queue_pixel (queue, nx, ny, c->dist);
+ distmap[nx + ny * width] < c->radius)
+ line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
}
}
nx = c->x;
@@ -581,16 +587,16 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
- distmap[nx + ny * width] < c->dist)
- line_art_queue_pixel (queue, nx, ny, c->dist);
+ distmap[nx + ny * width] < c->radius)
+ line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
}
if (c->y < height - 1)
{
ny = c->y + 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
- distmap[nx + ny * width] < c->dist)
- line_art_queue_pixel (queue, nx, ny, c->dist);
+ distmap[nx + ny * width] < c->radius)
+ line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
}
}
g_free (c);
@@ -1204,13 +1210,15 @@ static void
line_art_queue_pixel (GQueue *queue,
gint x,
gint y,
- gfloat dist)
+ gfloat radius,
+ gint level)
{
BorderPixel *p = g_new (BorderPixel, 1);
- p->x = x;
- p->y = y;
- p->dist = dist;
+ p->x = x;
+ p->y = y;
+ p->radius = radius;
+ p->level = level;
g_queue_push_head (queue, p);
}
diff --git a/app/core/gimppickable-contiguous-region.h b/app/core/gimppickable-contiguous-region.h
index 8c2f61e82d..8fd50ec80a 100644
--- a/app/core/gimppickable-contiguous-region.h
+++ b/app/core/gimppickable-contiguous-region.h
@@ -37,14 +37,15 @@ GimpAsync * gimp_pickable_contiguous_region_prepare_line_art_async (GimpPickabl
GeglBuffer * gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
GeglBuffer *line_art,
- gfloat *distmap,
- gfloat *thickmap,
+ gfloat *line_art_distmap,
+ gfloat *line_art_thickmap,
gboolean antialias,
gfloat threshold,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
gboolean diagonal_neighbors,
- gfloat stroke_threshold,
+ gfloat
line_art_stroke_threshold,
+ gint line_art_max_grow,
gint x,
gint y);
diff --git a/app/pdb/drawable-edit-cmds.c b/app/pdb/drawable-edit-cmds.c
index 5a88a1deb4..bc3f1095fd 100644
--- a/app/pdb/drawable-edit-cmds.c
+++ b/app/pdb/drawable-edit-cmds.c
@@ -171,7 +171,7 @@ drawable_edit_bucket_fill_invoker (GimpProcedure *procedure,
GIMP_PDB_CONTEXT (context)->sample_threshold,
GIMP_PDB_CONTEXT (context)->sample_merged,
GIMP_PDB_CONTEXT (context)->diagonal_neighbors,
- 0.92, /* TODO */
+ 0.92, 3, /* TODO */
x, y);
}
else
diff --git a/app/tools/gimpbucketfilloptions.c b/app/tools/gimpbucketfilloptions.c
index d6a4bf6e5d..8221c04ed5 100644
--- a/app/tools/gimpbucketfilloptions.c
+++ b/app/tools/gimpbucketfilloptions.c
@@ -54,6 +54,7 @@ enum
PROP_ANTIALIAS,
PROP_THRESHOLD,
PROP_LINE_ART_THRESHOLD,
+ PROP_LINE_ART_MAX_GROW,
PROP_FILL_CRITERION
};
@@ -64,6 +65,7 @@ struct _GimpBucketFillOptionsPrivate
GtkWidget *threshold_scale;
GtkWidget *line_art_threshold_scale;
+ GtkWidget *line_art_grow_scale;
};
static void gimp_bucket_fill_options_config_iface_init (GimpConfigInterface *config_iface);
@@ -162,6 +164,13 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
0.0, 1.0, 0.92,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_INT (object_class, PROP_LINE_ART_MAX_GROW,
+ "line-art-max-grow",
+ _("Maximum growing size"),
+ _("Maximum number of pixels grown under the line art"),
+ 1, 100, 3,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_ENUM (object_class, PROP_FILL_CRITERION,
"fill-criterion",
_("Fill by"),
@@ -219,6 +228,9 @@ gimp_bucket_fill_options_set_property (GObject *object,
case PROP_LINE_ART_THRESHOLD:
options->line_art_threshold = g_value_get_double (value);
break;
+ case PROP_LINE_ART_MAX_GROW:
+ options->line_art_max_grow = g_value_get_int (value);
+ break;
case PROP_FILL_CRITERION:
options->fill_criterion = g_value_get_enum (value);
gimp_bucket_fill_options_update_criterion (options);
@@ -264,6 +276,9 @@ gimp_bucket_fill_options_get_property (GObject *object,
case PROP_LINE_ART_THRESHOLD:
g_value_set_double (value, options->line_art_threshold);
break;
+ case PROP_LINE_ART_MAX_GROW:
+ g_value_set_int (value, options->line_art_max_grow);
+ break;
case PROP_FILL_CRITERION:
g_value_set_enum (value, options->fill_criterion);
break;
@@ -305,9 +320,11 @@ gimp_bucket_fill_options_update_criterion (GimpBucketFillOptions *options)
gtk_widget_hide (options->priv->threshold_scale);
gtk_widget_show (options->priv->line_art_threshold_scale);
+ gtk_widget_show (options->priv->line_art_grow_scale);
break;
default:
gtk_widget_hide (options->priv->line_art_threshold_scale);
+ gtk_widget_hide (options->priv->line_art_grow_scale);
gtk_widget_show (options->priv->antialias_checkbox);
gtk_widget_show (options->priv->diagonal_neighbors_checkbox);
@@ -404,6 +421,13 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
options->priv->threshold_scale = scale;
gtk_widget_show (scale);
+ /* Line Art: max growing size */
+ scale = gimp_prop_spin_scale_new (config, "line-art-max-grow", NULL,
+ 1, 5, 0);
+ gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
+ options->priv->line_art_grow_scale = scale;
+ gtk_widget_show (scale);
+
/* Line Art: stroke threshold */
scale = gimp_prop_spin_scale_new (config, "line-art-threshold", NULL,
0.05, 0.1, 2);
diff --git a/app/tools/gimpbucketfilloptions.h b/app/tools/gimpbucketfilloptions.h
index 00fe5cfac2..43fa265b02 100644
--- a/app/tools/gimpbucketfilloptions.h
+++ b/app/tools/gimpbucketfilloptions.h
@@ -47,6 +47,7 @@ struct _GimpBucketFillOptions
gdouble threshold;
gdouble line_art_threshold;
+ gint line_art_max_grow;
GimpSelectCriterion fill_criterion;
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index 8aaafaca08..b9da9903ee 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -401,6 +401,7 @@ gimp_bucket_fill_tool_preview (GimpBucketFillTool *tool,
options->sample_merged,
options->diagonal_neighbors,
options->line_art_threshold,
+ options->line_art_max_grow,
x, y, &tool->priv->fill_mask,
&x, &y, NULL, NULL);
if (line_art)
diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c
index e28dc71f47..4647f46972 100644
--- a/app/tools/gimpfuzzyselecttool.c
+++ b/app/tools/gimpfuzzyselecttool.c
@@ -128,6 +128,6 @@ gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
options->select_transparent,
options->select_criterion,
options->diagonal_neighbors,
- 0.92, /* TODO */
+ 0.92, 3, /* TODO */
x, y);
}
diff --git a/pdb/groups/drawable_edit.pdb b/pdb/groups/drawable_edit.pdb
index 193a735ec0..87dcba1ffa 100644
--- a/pdb/groups/drawable_edit.pdb
+++ b/pdb/groups/drawable_edit.pdb
@@ -175,7 +175,7 @@ HELP
GIMP_PDB_CONTEXT (context)->sample_threshold,
GIMP_PDB_CONTEXT (context)->sample_merged,
GIMP_PDB_CONTEXT (context)->diagonal_neighbors,
- 0.92, /* TODO */
+ 0.92, 3, /* TODO */
x, y);
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]