summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3c9908f)
raw | patch | inline | side by side (parent: 3c9908f)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Fri, 20 Oct 2006 23:34:39 +0000 (23:34 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Fri, 20 Oct 2006 23:34:39 +0000 (23:34 +0000) |
index 324a3d94ba8ae5145f9b8dce5125d60ed2446419..f3cc9b4e094be2b66b78dca52ecbece446a0c06a 100644 (file)
SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone);
double diag = diag_original * t.expansion();
double radius = blur * diag;
- SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius);
+ // 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 diag/2 should work
+ SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, diag/2, diag/2);
sp_style_set_property_url (clone_object, "filter", SP_OBJECT(constructed), false);
}
index 5fe3d58f8d624a7893f706f43a3ad54b1fdb90c6..07b329fb2264ba92bf1df61624447e62e17f8137 100644 (file)
gtk_box_pack_start (GTK_BOX (blur_hb), blur_s, TRUE, TRUE, 4);
gtk_label_set_mnemonic_widget (GTK_LABEL(blur_l), blur_s);
- GtkWidget *blur_sb = gtk_spin_button_new (GTK_ADJUSTMENT (blur_a), 0.01, 3);
+ GtkWidget *blur_sb = gtk_spin_button_new (GTK_ADJUSTMENT (blur_a), 0.01, 1);
gtk_box_pack_start (GTK_BOX (blur_hb), blur_sb, FALSE, FALSE, 0);
gtk_signal_connect ( blur_a, "value_changed",
gtk_box_pack_start (GTK_BOX (vb), o_vb, FALSE, FALSE, 2);
gtk_object_set_data (GTK_OBJECT (dlg), "master_opacity", o_vb);
- GtkWidget *l_hb = gtk_hbox_new (FALSE, 4);
+ GtkWidget *l_hb = gtk_hbox_new (FALSE, 0);
GtkWidget *l = gtk_label_new_with_mnemonic (_("Master _opacity"));
gtk_misc_set_alignment (GTK_MISC (l), 0.0, 1.0);
gtk_box_pack_start (GTK_BOX (l_hb), l, FALSE, FALSE, 4);
GtkWidget *hb = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (o_vb), hb, FALSE, FALSE, 0);
- GtkObject *a = gtk_adjustment_new (1.0, 0.0, 1.0, 0.01, 0.1, 0.0);
+ GtkObject *a = gtk_adjustment_new (1.0, 0.0, 100.0, 1.0, 1.0, 0.0);
gtk_object_set_data(GTK_OBJECT(dlg), "master_opacity_adjustment", a);
GtkWidget *s = gtk_hscale_new (GTK_ADJUSTMENT (a));
gtk_box_pack_start (GTK_BOX (hb), s, TRUE, TRUE, 4);
gtk_label_set_mnemonic_widget (GTK_LABEL(l), s);
- GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.01, 3);
+ GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.01, 1);
gtk_box_pack_start (GTK_BOX (hb), sb, FALSE, FALSE, 0);
gtk_signal_connect ( a, "value_changed",
g_signal_connect ( G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (sp_fillstroke_selection_modified), dlg );
g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_fillstroke_selection_changed), dlg );
- sp_fillstroke_selection_changed(NULL, NULL, NULL);
+ sp_fillstroke_selection_changed(INKSCAPE, sp_desktop_selection(SP_ACTIVE_DESKTOP), NULL);
gtk_widget_show (dlg);
case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently
case QUERY_STYLE_MULTIPLE_SAME:
gtk_widget_set_sensitive (opa, TRUE);
- gtk_adjustment_set_value(a, SP_SCALE24_TO_FLOAT(query->opacity.value));
+ gtk_adjustment_set_value(a, 100 * SP_SCALE24_TO_FLOAT(query->opacity.value));
break;
}
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
case QUERY_STYLE_MULTIPLE_SAME:
+ NR::Rect bbox = selection->bounds();
+ double perimeter = bbox.extent(NR::X) + bbox.extent(NR::Y);
gtk_widget_set_sensitive (b, TRUE);
//update blur widget value
float radius = query->filter_gaussianBlur_deviation.value;
- // TODO: divide by bbox diagonal
- gtk_adjustment_set_value(bluradjustment, radius);
+ float percent = radius * 400 / perimeter; // so that for a square, 100% == half side
+ gtk_adjustment_set_value(bluradjustment, percent);
break;
}
}
static void
-sp_fillstroke_opacity_changed (GtkAdjustment *a, SPWidget *dlg)
+sp_fillstroke_opacity_changed (GtkAdjustment *a, SPWidget *base)
{
if (gtk_object_get_data (GTK_OBJECT (dlg), "blocked"))
return;
SPCSSAttr *css = sp_repr_css_attr_new ();
Inkscape::CSSOStringStream os;
- os << CLAMP (a->value, 0.0, 1.0);
+ os << CLAMP (a->value / 100, 0.0, 1.0);
sp_repr_css_set_property (css, "opacity", os.str().c_str());
sp_desktop_set_style (SP_ACTIVE_DESKTOP, css);
static void
-sp_fillstroke_blur_changed (GtkAdjustment *a, SPWidget *dlg)
+sp_fillstroke_blur_changed (GtkAdjustment *a, SPWidget *base)
{
//if dialog is locked, return
if (gtk_object_get_data (GTK_OBJECT (dlg), "blocked"))
GSList const *items = selection->itemList();
//get current document
SPDocument *document = sp_desktop_document (desktop);
-
- //create new filter with feGaussianBlur primitive
- SPFilter *constructed = new_filter_gaussian_blur(document, a->value);
+ NR::Rect bbox = selection->bounds();
+ double perimeter = bbox.extent(NR::X) + bbox.extent(NR::Y);
+ double radius = a->value * perimeter / 400;
+
//apply created filter to every selected item
for (GSList const *i = items; i != NULL; i = i->next) {
SPStyle *style = SP_OBJECT_STYLE(item);
g_assert(style != NULL);
- if (a->value == 0.0) {
+ if (radius == 0.0) {
remove_filter (item, true);
} else {
+ NR::Rect const r = sp_item_bbox_desktop(item);
+ double width = r.extent(NR::X);
+ double height = r.extent(NR::Y);
+ SPFilter *constructed = new_filter_gaussian_blur(document, radius, width, height);
sp_style_set_property_url (SP_OBJECT(item), "filter", SP_OBJECT(constructed), false);
}
//request update
index 0b374160cb9702a442b32a5dadde227f430bceb4..e18e54ed6e9fca4bd3a70b8d1f4b44d9ee5348f3 100644 (file)
--- a/src/filter-chemistry.cpp
+++ b/src/filter-chemistry.cpp
* Creates a filter with blur primitive of specified stdDeviation
*/
SPFilter *
-new_filter_gaussian_blur (SPDocument *document, gdouble stdDeviation)
+new_filter_gaussian_blur (SPDocument *document, gdouble stdDeviation, double width, double height)
{
g_return_val_if_fail(document != NULL, NULL);
SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
- // create a new private filter
+ // create a new filter
Inkscape::XML::Node *repr;
repr = sp_repr_new("svg:filter");
repr->setAttribute("inkscape:collect", "always");
+ if (width != 0 && height != 0 && (2 * stdDeviation > width * 0.1 || 2 * stdDeviation > 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 * stdDeviation / width;
+ double ymargin = 2 * stdDeviation / height;
+
+ sp_repr_set_svg_double(repr, "x", -xmargin);
+ sp_repr_set_svg_double(repr, "width", 1 + 2 * xmargin);
+ sp_repr_set_svg_double(repr, "y", -ymargin);
+ sp_repr_set_svg_double(repr, "height", 1 + 2 * ymargin);
+ }
+
//create feGaussianBlur node
Inkscape::XML::Node *b_repr;
b_repr = sp_repr_new("svg:feGaussianBlur");
b_repr->setAttribute("inkscape:collect", "always");
//set stdDeviation attribute
- Inkscape::CSSOStringStream os;
- os << stdDeviation;
- b_repr->setAttribute("stdDeviation", os.str().c_str());
+ sp_repr_set_svg_double(b_repr, "stdDeviation", stdDeviation);
//set feGaussianBlur as child of filter node
repr->appendChild(b_repr);
diff --git a/src/filter-chemistry.h b/src/filter-chemistry.h
index 31776323e7499bbdc519dda73fa692cf1bfefcfe..4c6606fc08635073f86326d4c9490d242fa480f0 100644 (file)
--- a/src/filter-chemistry.h
+++ b/src/filter-chemistry.h
#include "forward.h"
#include "sp-filter.h"
-SPFilter *new_filter_gaussian_blur (SPDocument *document, gdouble stdDeviation);
+SPFilter *new_filter_gaussian_blur (SPDocument *document, gdouble stdDeviation, double width, double height);
void remove_filter (SPObject *item, bool recursive);
#endif