summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-07-06 01:59:32 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2011-07-06 01:59:32 +0000
commite65a02ed32b78534739aba24929ece7c44dd967f (patch)
tree13cf022f18f6b5bae46aad4bc339e512f069a514 /src/extension
parentPull 2Geom revision 2013 (extra constructors for Rect). (diff)
parentText edit dialog: Apply button should grab default only after adding to window (diff)
downloadinkscape-e65a02ed32b78534739aba24929ece7c44dd967f.tar.gz
inkscape-e65a02ed32b78534739aba24929ece7c44dd967f.zip
Merge from trunk
(bzr r10347.1.5)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/CMakeLists.txt1
-rw-r--r--src/extension/effect.cpp2
-rwxr-xr-xsrc/extension/internal/filter/experimental.h12
-rwxr-xr-xsrc/extension/internal/filter/filter-all.cpp4
-rw-r--r--src/extension/internal/filter/image.h113
-rw-r--r--src/extension/internal/filter/shadows.h92
6 files changed, 197 insertions, 27 deletions
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
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()) {
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)
"</feMerge>\n"
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1.3 0 \" result=\"color5\" flood-opacity=\"0.56\" />\n"
"<feComposite in=\"%s\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite8\" />\n"
- "</filter>\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());
+ "</filter>\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 */
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..926c56a4d
--- /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) <nicoduf@yahoo.fr>
+ *
+ * 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(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Edge detect, custom (Image)") "</name>\n"
+ "<id>org.inkscape.effect.filter.EdgeDetect</id>\n"
+ "<param name=\"type\" gui-text=\"" N_("Detect:") "\" type=\"enum\" >\n"
+ "<_item value=\"all\">" N_("All") "</_item>\n"
+ "<_item value=\"vertical\">" N_("Vertical lines") "</_item>\n"
+ "<_item value=\"horizontal\">" N_("Horizontal lines") "</_item>\n"
+ "</param>\n"
+ "<param name=\"level\" gui-text=\"" N_("Level:") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10.0\">1.0</param>\n"
+ "<param name=\"inverted\" gui-text=\"" N_("Invert colors") "\" type=\"boolean\" >false</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Detect color edges in object") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\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(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Edge detect, custom\">\n"
+ "<feConvolveMatrix in=\"SourceGraphic\" kernelMatrix=\"%s\" order=\"3 3\" bias=\"%s\" divisor=\"%s\" targetX=\"1\" targetY=\"1\" preserveAlpha=\"true\" result=\"convolve\" />\n"
+ "</filter>\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..bfc6cace6 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) <nicoduf@yahoo.fr>
*
- * 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(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Drop shadow, custom (Shadows and Glows)") "</name>\n"
- "<id>org.inkscape.effect.filter.ColorDropShadow</id>\n"
- "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n"
- "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
- "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
- "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">127</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<name>" N_("Drop shadow, custom (Shadows and Glows)") "</name>\n"
+ "<id>org.inkscape.effect.filter.ColorDropShadow</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n"
+ "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n"
+ "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
+ "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
+ "<param name=\"type\" gui-text=\"" N_("Blur type:") "\" type=\"enum\" >\n"
+ "<_item value=\"outer\">" N_("Outer") "</_item>\n"
+ "<_item value=\"inner\">" N_("Inner") "</_item>\n"
+ "<_item value=\"cutout\">" N_("Cutout") "</_item>\n"
+ "</param>\n"
+ "</page>\n"
+ "<page name=\"coltab\" _gui-text=\"" N_("Blur color") "\">\n"
+ "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">127</param>\n"
+ "<param name=\"objcolor\" gui-text=\"" N_("Use object's color") "\" type=\"boolean\" >false</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Experimental") "\"/>\n"
"</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Colorizable Drop shadow") "</menu-tip>\n"
- "</effect>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Colorizable Drop shadow") "</menu-tip>\n"
+ "</effect>\n"
"</inkscape-extension>\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(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Drop shadow, custom\">\n"
"<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
- "<feComposite in=\"flood\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite1\" />\n"
+ "<feComposite in=\"%s\" in2=\"%s\" operator=\"%s\" result=\"composite1\" />\n"
"<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur\" />\n"
"<feOffset dx=\"%s\" dy=\"%s\" result=\"offset\" />\n"
- "<feComposite in=\"SourceGraphic\" in2=\"offset\" operator=\"over\" result=\"composite2\" />\n"
- "</filter>\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());
+ "<feComposite in=\"%s\" in2=\"%s\" operator=\"%s\" result=\"composite2\" />\n"
+ "</filter>\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;
};