e0f544c76e061f2827f6408ec3114862053e3406
1 #ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__
2 #define __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__
3 /* Change the 'MORPHOLOGY' above to be your file name */
5 /*
6 * Copyright (C) 2010 Authors:
7 * Ivan Louette (filters)
8 * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
9 *
10 * Released under GNU GPL, read the file 'COPYING' for more information
11 */
12 /* ^^^ Change the copyright to be you and your e-mail address ^^^ */
14 #include "filter.h"
16 #include "extension/internal/clear-n_.h"
17 #include "extension/system.h"
18 #include "extension/extension.h"
20 namespace Inkscape {
21 namespace Extension {
22 namespace Internal {
23 namespace Filter {
25 /**
26 \brief Custom predefined Crosssmooth filter.
28 Smooth the outside of shapes and pictures.
30 Filter's parameters:
31 * Type (enum, default "Smooth edges") ->
32 Smooth edges = composite1 (in="SourceGraphic", in2="blur")
33 Smooth all = composite1 (in="blur", in2="blur")
34 * Blur (0.01->10., default 5.) -> blur (stdDeviation)
35 */
37 class Crosssmooth : public Inkscape::Extension::Internal::Filter::Filter {
38 protected:
39 virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
41 public:
42 Crosssmooth ( ) : Filter() { };
43 virtual ~Crosssmooth ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
45 static void init (void) {
46 Inkscape::Extension::build_from_mem(
47 "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
48 "<name>" N_("Cross-smooth, custom -EXP-") "</name>\n"
49 "<id>org.inkscape.effect.filter.Crosssmooth</id>\n"
50 "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n"
51 "<_item value=\"edges\">Smooth edges</_item>\n"
52 "<_item value=\"all\">Smooth all</_item>\n"
53 "</param>\n"
54 "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" min=\"0.01\" max=\"10\">5</param>\n"
55 "<effect>\n"
56 "<object-type>all</object-type>\n"
57 "<effects-menu>\n"
58 "<submenu name=\"" N_("Filters") "\">\n"
59 "<submenu name=\"" N_("Experimental") "\"/>\n"
60 "</submenu>\n"
61 "</effects-menu>\n"
62 "<menu-tip>" N_("Smooth edges and angles of shapes") "</menu-tip>\n"
63 "</effect>\n"
64 "</inkscape-extension>\n", new Crosssmooth());
65 };
67 };
69 gchar const *
70 Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext)
71 {
72 if (_filter != NULL) g_free((void *)_filter);
74 std::ostringstream blur;
75 std::ostringstream c1in;
77 blur << ext->get_param_float("blur");
79 const gchar *type = ext->get_param_enum("type");
80 if((g_ascii_strcasecmp("all", type) == 0)) {
81 c1in << "blur";
82 } else {
83 c1in << "SourceGraphic";
84 }
86 _filter = g_strdup_printf(
87 "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" y=\"0\" x=\"0\" inkscape:label=\"Cross-smooth, custom -EXP-\">\n"
88 "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
89 "<feComposite in=\"%s\" in2=\"blur\" operator=\"atop\" result=\"composite1\" />\n"
90 "<feComposite in2=\"composite1\" operator=\"in\" result=\"composite2\" />\n"
91 "<feComposite in2=\"composite2\" operator=\"in\" result=\"composite3\" />\n"
92 "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10 \" result=\"colormatrix\" />\n"
93 "</filter>\n", blur.str().c_str(), c1in.str().c_str());
95 return _filter;
96 }; /* Crosssmooth filter */
98 }; /* namespace Filter */
99 }; /* namespace Internal */
100 }; /* namespace Extension */
101 }; /* namespace Inkscape */
103 /* Change the 'COLOR' below to be your file name */
104 #endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ */