Code

r19125@shi: ted | 2008-04-23 23:32:56 -0700
[inkscape.git] / src / extension / internal / filter / drop-shadow.h
1 #ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__
2 #define __INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__
3 /* Change the 'DROP_SHADOW' above to be your file name */
5 /*
6  * Copyright (C) 2008 Authors:
7  *   Ted Gould <ted@gould.cx>
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
11 /* ^^^ Change the copyright to be you and your e-mail address ^^^ */
13 #include "filter.h"
15 #include "extension/internal/clear-n_.h"
16 #include "extension/system.h"
17 #include "extension/extension.h"
19 namespace Inkscape {
20 namespace Extension {
21 namespace Internal {
22 namespace Filter {
24 class DropShadow : public Inkscape::Extension::Internal::Filter::Filter {
25 protected:
26         virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
28 public:
29         DropShadow ( ) : Filter() { };
30         virtual ~DropShadow ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
32         static void init (void) {
33                 Inkscape::Extension::build_from_mem(
34                         "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
35                                 "<name>" N_("Drop Shadow") "</name>\n"
36                                 "<id>org.inkscape.effect.filter.drop-shadow</id>\n"
37                                 "<param name=\"blur\" gui-text=\"" N_("Amount of Blur") "\" type=\"float\" min=\"0.0\" max=\"50.0\">2.0</param>\n"
38                                 "<param name=\"xoffset\" gui-text=\"" N_("Horizontal Offset") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">4.0</param>\n"
39                                 "<param name=\"yoffset\" gui-text=\"" N_("Vertical Offset") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">4.0</param>\n"
40                                 "<effect>\n"
41                                         "<object-type>all</object-type>\n"
42                                         "<effects-menu>\n"
43                                                 "<submenu name=\"" N_("Filter") "\" />\n"
44                                         "</effects-menu>\n"
45                                         "<menu-tip>" N_("I hate text") "</menu-tip>\n"
46                                 "</effect>\n"
47                         "</inkscape-extension>\n", new DropShadow());
48         };
50 };
52 gchar const *
53 DropShadow::get_filter_text (Inkscape::Extension::Extension * ext)
54 {
55         if (_filter != NULL) g_free((void *)_filter);
57         float blur = ext->get_param_float("blur");
58         float x = ext->get_param_float("xoffset");
59         float y = ext->get_param_float("yoffset");
61         _filter = g_strdup_printf(
62                 "<filter>\n"
63                         "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%f\" result=\"blur\"/>\n"
64                         "<feOffset in=\"blur\" dx=\"%f\" dy=\"%f\" result=\"offsetBlur\"/>\n"
65                         "<feMerge>\n"
66                                 "<feMergeNode in=\"offsetBlur\"/>\n"
67                                 "<feMergeNode in=\"SourceGraphic\"/>\n"
68                         "</feMerge>\n"
69                 "</filter>\n", blur, x, y);
71         return _filter;
72 };
74 }; /* namespace Filter */
75 }; /* namespace Internal */
76 }; /* namespace Extension */
77 }; /* namespace Inkscape */
79 /* Change the 'DROP_SHADOW' below to be your file name */
80 #endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ */