From be8f9d57bfd58257cd4a41642aa2d4be69610fd0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 23 Jun 2011 19:28:36 +0200 Subject: Filters. Fix for a crash introduced with revision 10313. (bzr r10349) --- src/extension/internal/filter/experimental.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index f60a6b414..96485ad97 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -301,7 +301,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) * Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation) * Dilatation (1.->50., default 6) -> color2 (n-1th value) * Erosion (0.->50., default 2) -> color2 (nth value 0->-50) - * Transluscent (boolean, default false) -> composite 8 (in, true->merge1, false->color5) + * translucent (boolean, default false) -> composite 8 (in, true->merge1, false->color5) * Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation) * Blur dilatation (1.->50., default 6) -> color4 (n-1th value) @@ -379,7 +379,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream smooth; std::ostringstream dilat; std::ostringstream erosion; - std::ostringstream transluscent; + std::ostringstream translucent; std::ostringstream offset; std::ostringstream blur; std::ostringstream bdilat; @@ -401,10 +401,10 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) smooth << ext->get_param_float("smooth"); dilat << ext->get_param_float("dilat"); erosion << (- ext->get_param_float("erosion")); - if (ext->get_param_bool("transluscent")) - transluscent << "merge1"; + if (ext->get_param_bool("translucent")) + translucent << "merge1"; else - transluscent << "color5"; + translucent << "color5"; offset << ext->get_param_int("offset"); blur << ext->get_param_float("blur"); @@ -462,7 +462,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), transluscent.str().c_str()); + "\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), translucent.str().c_str()); return _filter; }; /* Drawing filter */ -- cgit v1.2.3 From dcf765f3dcbff2e65428e0f002bb5ea3648940f0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Jun 2011 15:35:01 +0000 Subject: warning cleanup (no functional changes) - enclose && / || with brackets to avoid ambiguity. - don't cast from booleans to pointers. (bzr r10359) --- src/extension/effect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/extension') diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 51aa42da6..e01eb760a 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -324,7 +324,7 @@ Effect::set_last_effect (Effect * in_effect) Inkscape::XML::Node * Effect::find_menu (Inkscape::XML::Node * menustruct, const gchar *name) { - if (menustruct == NULL) return false; + if (menustruct == NULL) return NULL; for (Inkscape::XML::Node * child = menustruct; child != NULL; child = child->next()) { -- cgit v1.2.3 From 53e7e03e0c4eb66e2664440e093474d27168711b Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 29 Jun 2011 20:45:59 +0200 Subject: Filters. New Edge detect custom filter and new options for the Drop shadow filter. (bzr r10388) --- src/extension/internal/filter/filter-all.cpp | 4 + src/extension/internal/filter/image.h | 113 +++++++++++++++++++++++++++ src/extension/internal/filter/shadows.h | 92 +++++++++++++++++----- 3 files changed, 189 insertions(+), 20 deletions(-) create mode 100644 src/extension/internal/filter/image.h (limited to 'src/extension') diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 280dc9563..6ee849925 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -11,6 +11,7 @@ #include "abc.h" #include "color.h" #include "drop-shadow.h" +#include "image.h" #include "morphology.h" #include "shadows.h" #include "snow.h" @@ -57,6 +58,9 @@ Filter::filters_all (void ) Solarize::init(); Tritone::init(); + // Image + EdgeDetect::init(); + // Morphology Crosssmooth::init(); diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h new file mode 100644 index 000000000..480e836bd --- /dev/null +++ b/src/extension/internal/filter/image.h @@ -0,0 +1,113 @@ +#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ +#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ +/* Change the 'IMAGE' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Image filters + * Edge detect + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Edge detect filter. + + Detect color edges in object. + + Filter's parameters: + * Detection type (enum, default Full) -> convolve (kernelMatrix) + * Level (0.01->10., default 1.) -> convolve (divisor) + * Inverted (boolean, default false) -> convolve (bias) +*/ +class EdgeDetect : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + EdgeDetect ( ) : Filter() { }; + virtual ~EdgeDetect ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Edge detect, custom (Image)") "\n" + "org.inkscape.effect.filter.EdgeDetect\n" + "\n" + "<_item value=\"all\">All\n" + "<_item value=\"vertical\">Vertical lines\n" + "<_item value=\"horizontal\">Horizontal lines\n" + "\n" + "1.0\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Detect color edges in object") "\n" + "\n" + "\n", new EdgeDetect()); + }; + +}; + +gchar const * +EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream matrix; + std::ostringstream inverted; + std::ostringstream level; + + const gchar *type = ext->get_param_enum("type"); + + level << ext->get_param_float("level"); + + if ((g_ascii_strcasecmp("vertical", type) == 0)) { + matrix << "0 0 0 1 -2 1 0 0 0"; + } else if ((g_ascii_strcasecmp("horizontal", type) == 0)) { + matrix << "0 1 0 0 -2 0 0 1 0"; + } else { + matrix << "1 1 1 1 -8 1 1 1 1"; + } + + if (ext->get_param_bool("inverted")) { + inverted << "1"; + } else { + inverted << "0"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str()); + + return _filter; +}; + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'IMAGE' below to be your file name */ +#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ */ diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index e29092ae9..e775d8398 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -7,7 +7,7 @@ * Ivan Louette (filters) * Nicolas Dufour (UI) * - * Color filters + * Shadow filters * Drop shadow * * Released under GNU GPL, read the file 'COPYING' for more information @@ -34,7 +34,12 @@ namespace Filter { * Blur radius (0.->200., default 3) -> blur (stdDeviation) * Horizontal offset (-50.->50., default 6.0) -> offset (dx) * Vertical offset (-50.->50., default 6.0) -> offset (dy) + * Blur type (enum, default outer) -> + outer = composite1 (operator="in"), composite2 (operator="over", in1="SourceGraphic", in2="offset") + inner = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="SourceGraphic") + cutout = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic") * Color (guint, default 0,0,0,127) -> flood (flood-opacity, flood-color) + * Use object's color (boolean, default false) -> composite1 (in1, in2) */ class ColorizableDropShadow : public Inkscape::Extension::Internal::Filter::Filter { protected: @@ -47,21 +52,33 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Drop shadow, custom (Shadows and Glows)") "\n" - "org.inkscape.effect.filter.ColorDropShadow\n" - "3.0\n" - "6.0\n" - "6.0\n" - "127\n" - "\n" - "all\n" - "\n" - "\n" - "\n" + "" N_("Drop shadow, custom (Shadows and Glows)") "\n" + "org.inkscape.effect.filter.ColorDropShadow\n" + "\n" + "\n" + "3.0\n" + "6.0\n" + "6.0\n" + "\n" + "<_item value=\"outer\">Outer\n" + "<_item value=\"inner\">Inner\n" + "<_item value=\"cutout\">Cutout\n" + "\n" + "\n" + "\n" + "127\n" + "false\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" "\n" - "\n" - "" N_("Colorizable Drop shadow") "\n" - "\n" + "\n" + "" N_("Colorizable Drop shadow") "\n" + "\n" "\n", new ColorizableDropShadow()); }; @@ -79,9 +96,15 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream b; std::ostringstream x; std::ostringstream y; - + std::ostringstream comp1in1; + std::ostringstream comp1in2; + std::ostringstream comp1op; + std::ostringstream comp2in1; + std::ostringstream comp2in2; + std::ostringstream comp2op; + + const gchar *type = ext->get_param_enum("type"); guint32 color = ext->get_param_color("color"); - blur << ext->get_param_float("blur"); x << ext->get_param_float("xoffset"); y << ext->get_param_float("yoffset"); @@ -90,14 +113,43 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) g << ((color >> 16) & 0xff); b << ((color >> 8) & 0xff); + if (ext->get_param_bool("objcolor")) { + comp1in1 << "SourceGraphic"; + comp1in2 << "flood"; + } else { + comp1in1 << "flood"; + comp1in2 << "SourceGraphic"; + } + + if ((g_ascii_strcasecmp("outer", type) == 0)) { + comp1op << "in"; + comp2op << "over"; + comp2in1 << "SourceGraphic"; + comp2in2 << "offset"; + } else if ((g_ascii_strcasecmp("inner", type) == 0)) { + comp1op << "out"; + comp2op << "atop"; + comp2in1 << "offset"; + comp2in2 << "SourceGraphic"; + } else { + comp1op << "in"; + comp2op << "out"; + comp2in1 << "offset"; + comp2in2 << "SourceGraphic"; + } + + _filter = g_strdup_printf( "\n" "\n" - "\n" + "\n" "\n" "\n" - "\n" - "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), blur.str().c_str(), x.str().c_str(), y.str().c_str()); + "\n" + "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + comp1in1.str().c_str(), comp1in2.str().c_str(), comp1op.str().c_str(), + blur.str().c_str(), x.str().c_str(), y.str().c_str(), + comp2in1.str().c_str(), comp2in2.str().c_str(), comp2op.str().c_str()); return _filter; }; -- cgit v1.2.3 From 825d19f13b89ee5e2cc93391f6a86adf2bb12fa3 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 29 Jun 2011 21:27:23 +0200 Subject: Filters. Typos in the recently modified and added filters. Translations. POT files and French translation update. (bzr r10389) --- src/extension/internal/filter/image.h | 6 +++--- src/extension/internal/filter/shadows.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index 480e836bd..926c56a4d 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -49,9 +49,9 @@ public: "" N_("Edge detect, custom (Image)") "\n" "org.inkscape.effect.filter.EdgeDetect\n" "\n" - "<_item value=\"all\">All\n" - "<_item value=\"vertical\">Vertical lines\n" - "<_item value=\"horizontal\">Horizontal lines\n" + "<_item value=\"all\">" N_("All") "\n" + "<_item value=\"vertical\">" N_("Vertical lines") "\n" + "<_item value=\"horizontal\">" N_("Horizontal lines") "\n" "\n" "1.0\n" "false\n" diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index e775d8398..bfc6cace6 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -55,17 +55,17 @@ public: "" N_("Drop shadow, custom (Shadows and Glows)") "\n" "org.inkscape.effect.filter.ColorDropShadow\n" "\n" - "\n" + "\n" "3.0\n" "6.0\n" "6.0\n" "\n" - "<_item value=\"outer\">Outer\n" - "<_item value=\"inner\">Inner\n" - "<_item value=\"cutout\">Cutout\n" + "<_item value=\"outer\">" N_("Outer") "\n" + "<_item value=\"inner\">" N_("Inner") "\n" + "<_item value=\"cutout\">" N_("Cutout") "\n" "\n" "\n" - "\n" + "\n" "127\n" "false\n" "\n" -- cgit v1.2.3 From 2045221082a4aed0dcbbd71d36393a2498396a10 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Jul 2011 09:58:37 +0000 Subject: added missing header (bzr r10397) --- src/extension/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src/extension') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 5ccb5c984..c9c466bb0 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -118,6 +118,7 @@ set(extension_SRC internal/filter/drop-shadow.h internal/filter/experimental.h internal/filter/filter.h + internal/filter/image.h internal/filter/morphology.h internal/filter/shadows.h internal/filter/snow.h -- cgit v1.2.3