From 262f61c365788f89a49e4218865c3dc737512555 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Tue, 16 Jan 2007 17:05:03 +0000 Subject: [PATCH] fix filter area clipping when blurring a squeezed object --- src/dialogs/clonetiler.cpp | 2 +- src/filter-chemistry.cpp | 13 ++++++++----- src/filter-chemistry.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 172f4f677..c0acea533 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1307,7 +1307,7 @@ clonetiler_apply (GtkWidget *widget, void *) // it's hard to figure out exact width/height of the tile without having an object // that we can take bbox of; however here we only need a lower bound so that blur // margins are not too small, and the perimeter should work - SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, t.expansion(), perimeter, perimeter); + SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, t.expansion(), t.expansionX(), t.expansionY(), perimeter, perimeter); sp_style_set_property_url (clone_object, "filter", SP_OBJECT(constructed), false); } diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 3c27b6edc..100caefbe 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -27,7 +27,7 @@ * Creates a filter with blur primitive of specified radius for an item with the given matrix expansion, width and height */ SPFilter * -new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion, double width, double height) +new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion, double expansionX, double expansionY, double width, double height) { g_return_val_if_fail(document != NULL, NULL); @@ -38,11 +38,14 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion repr = sp_repr_new("svg:filter"); repr->setAttribute("inkscape:collect", "always"); - if (width != 0 && height != 0 && (2 * radius > width * 0.1 || 2 * radius > height * 0.1)) { + double rx = radius * (expansion / expansionY); + double ry = radius * (expansion / expansionX); + + if (width != 0 && height != 0 && (2 * rx > width * 0.1 || 2 * ry > height * 0.1)) { // If not within the default 10% margin (see // http://www.w3.org/TR/SVG11/filters.html#FilterEffectsRegion), specify margins - double xmargin = 2 * radius / width; - double ymargin = 2 * radius / height; + double xmargin = 2 * (rx) / width; + double ymargin = 2 * (ry) / height; // TODO: set it in UserSpaceOnUse instead? sp_repr_set_svg_double(repr, "x", -xmargin); @@ -95,7 +98,7 @@ new_filter_gaussian_blur_from_item (SPDocument *document, SPItem *item, gdouble NR::Matrix i2d = sp_item_i2d_affine (item); - return (new_filter_gaussian_blur (document, radius, i2d.expansion(), width, height)); + return (new_filter_gaussian_blur (document, radius, i2d.expansion(), i2d.expansionX(), i2d.expansionY(), width, height)); } void remove_filter (SPObject *item, bool recursive) diff --git a/src/filter-chemistry.h b/src/filter-chemistry.h index d575b7f1e..22ae9aecd 100644 --- a/src/filter-chemistry.h +++ b/src/filter-chemistry.h @@ -16,7 +16,7 @@ #include "forward.h" #include "sp-filter.h" -SPFilter *new_filter_gaussian_blur (SPDocument *document, gdouble stdDeviation, double expansion, double width, double height); +SPFilter *new_filter_gaussian_blur (SPDocument *document, gdouble stdDeviation, double expansion, double expansionX, double expansionY, double width, double height); SPFilter *new_filter_gaussian_blur_from_item (SPDocument *document, SPItem *item, gdouble stdDeviation); void remove_filter (SPObject *item, bool recursive); -- 2.30.2