summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2008-04-24 06:36:02 +0000
committergouldtj <gouldtj@users.sourceforge.net>2008-04-24 06:36:02 +0000
commita5c0c189031f17ee3dbf3bd53efed8c3f8089e7e (patch)
tree9b153bb56da99d530135c8b6382cc9232270990a /src
parentPatch for Win32 bug 176750 - Envelope and Perspective scripts report "empty s... (diff)
downloadinkscape-a5c0c189031f17ee3dbf3bd53efed8c3f8089e7e.tar.gz
inkscape-a5c0c189031f17ee3dbf3bd53efed8c3f8089e7e.zip
r19125@shi: ted | 2008-04-23 23:32:56 -0700
Cleaning up a couple things. Making sure we don't leak memory through the destructor (rarely used in reality, but we should be clean about these things, that's what destructors are for). r19126@shi: ted | 2008-04-23 23:33:30 -0700 Making it so that snow has a parameter for drift size. It seems like that is what most people would want to change on this relatively complex filter. (bzr r5506)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/filter/drop-shadow.h3
-rw-r--r--src/extension/internal/filter/snow.h68
2 files changed, 48 insertions, 23 deletions
diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h
index b19adffa2..7516bacf9 100644
--- a/src/extension/internal/filter/drop-shadow.h
+++ b/src/extension/internal/filter/drop-shadow.h
@@ -22,13 +22,12 @@ namespace Internal {
namespace Filter {
class DropShadow : public Inkscape::Extension::Internal::Filter::Filter {
- int myvar;
protected:
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
public:
DropShadow ( ) : Filter() { };
- //virtual ~DropShadow ( ) { if (_filter != NULL) g_free(_filter); return; }
+ virtual ~DropShadow ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
static void init (void) {
Inkscape::Extension::build_from_mem(
diff --git a/src/extension/internal/filter/snow.h b/src/extension/internal/filter/snow.h
index 0b99cbc86..366bdcf1f 100644
--- a/src/extension/internal/filter/snow.h
+++ b/src/extension/internal/filter/snow.h
@@ -18,30 +18,56 @@ namespace Internal {
namespace Filter {
class Snow : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Snow ( ) : Filter() { };
+ virtual ~Snow ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
public:
static void init (void) {
- filter_init("snow", /* ID -- should be unique */
- N_("Snow"), /* Name in the menus, should have a N_() around it for translation */
- N_("When the weather outside is frightening..."),
- /* Menu tooltip to help users understand the name. Should also have a N_() */
- "<filter>\n"
- "<feConvolveMatrix order=\"3 3\" kernelMatrix=\"1 1 1 0 0 0 -1 -1 -1\" preserveAlpha=\"false\" divisor=\"3\"/>\n"
- "<feMorphology operator=\"dilate\" radius=\"1 3.2345013477088949\"/>\n"
- "<feGaussianBlur stdDeviation=\"1.6270889487870621\" result=\"result0\"/>\n"
- "<feColorMatrix values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0\" result=\"result1\"/>\n"
- "<feOffset dx=\"0\" dy=\"1\" result=\"result5\"/>\n"
- "<feDiffuseLighting in=\"result0\" diffuseConstant=\"2.2613065326633168\" surfaceScale=\"1\">\n"
- "<feDistantLight azimuth=\"225\" elevation=\"32\"/>\n"
- "</feDiffuseLighting>\n"
- "<feComposite in2=\"result1\" operator=\"in\" result=\"result2\"/>\n"
- "<feColorMatrix values=\"0.4 0 0 0 0.6 0 0.4 0 0 0.6 0 0 0 0 1 0 0 0 1 0\" result=\"result4\"/>\n"
- "<feComposite in2=\"result5\" in=\"result4\"/>\n"
- "<feComposite in2=\"SourceGraphic\"/>\n"
- "</filter>\n");
- /* The XML of the filter that should be added. There
- * should be a <svg:filter> surrounding what you'd like
- * to be added with this effect. */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Snow") "</name>\n"
+ "<id>org.inkscape.effect.filter.snow</id>\n"
+ "<param name=\"drift\" gui-text=\"" N_("Drift Size") "\" type=\"float\" min=\"0.0\" max=\"20.0\">3.5</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filter") "\" />\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("When the weather outside is frightening...") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Snow());
};
+
+};
+
+gchar const *
+Snow::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ float drift = ext->get_param_float("drift");
+
+ _filter = g_strdup_printf(
+ "<filter>\n"
+ "<feConvolveMatrix order=\"3 3\" kernelMatrix=\"1 1 1 0 0 0 -1 -1 -1\" preserveAlpha=\"false\" divisor=\"3\"/>\n"
+ "<feMorphology operator=\"dilate\" radius=\"1 %f\"/>\n"
+ "<feGaussianBlur stdDeviation=\"1.6270889487870621\" result=\"result0\"/>\n"
+ "<feColorMatrix values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0\" result=\"result1\"/>\n"
+ "<feOffset dx=\"0\" dy=\"1\" result=\"result5\"/>\n"
+ "<feDiffuseLighting in=\"result0\" diffuseConstant=\"2.2613065326633168\" surfaceScale=\"1\">\n"
+ "<feDistantLight azimuth=\"225\" elevation=\"32\"/>\n"
+ "</feDiffuseLighting>\n"
+ "<feComposite in2=\"result1\" operator=\"in\" result=\"result2\"/>\n"
+ "<feColorMatrix values=\"0.4 0 0 0 0.6 0 0.4 0 0 0.6 0 0 0 0 1 0 0 0 1 0\" result=\"result4\"/>\n"
+ "<feComposite in2=\"result5\" in=\"result4\"/>\n"
+ "<feComposite in2=\"SourceGraphic\"/>\n"
+ "</filter>\n", drift);
+
+ return _filter;
};
}; /* namespace Filter */