~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/extension/internal/filter/drop-shadow.h

  • Committer: Ted Gould
  • Date: 2008-11-21 05:24:08 UTC
  • Revision ID: ted@canonical.com-20081121052408-tilucis2pjrrpzxx
MergeĀ fromĀ fe-moved

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
                                "<effect>\n"
42
42
                                        "<object-type>all</object-type>\n"
43
43
                                        "<effects-menu>\n"
44
 
                                                "<submenu name=\"" N_("Filter") "\" />\n"
 
44
                                                "<submenu name=\"" N_("Filters") "\" >\n"
 
45
                                                "<submenu name=\"Shadows and Glows\"/>\n"
 
46
                              "</submenu>\n"
45
47
                                        "</effects-menu>\n"
46
48
                                        "<menu-tip>" N_("Black, blurred drop shadow") "</menu-tip>\n"
47
49
                                "</effect>\n"
61
63
        float y = ext->get_param_float("yoffset");
62
64
 
63
65
        _filter = g_strdup_printf(
64
 
                "<filter>\n"
 
66
                "<filter width=\"1.5\" height=\"1.5\" x=\"-.25\" y=\"-.25\">\n"
65
67
                        "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%f\" result=\"blur\"/>\n"
66
68
                        "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %f 0 \" />\n"
67
69
                        "<feOffset in=\"bluralpha\" dx=\"%f\" dy=\"%f\" result=\"offsetBlur\"/>\n"
74
76
        return _filter;
75
77
};
76
78
 
 
79
class DropGlow : public Inkscape::Extension::Internal::Filter::Filter {
 
80
protected:
 
81
        virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
 
82
 
 
83
public:
 
84
        DropGlow ( ) : Filter() { };
 
85
        virtual ~DropGlow ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
 
86
 
 
87
        static void init (void) {
 
88
                Inkscape::Extension::build_from_mem(
 
89
                        "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
 
90
                                "<name>" N_("Drop Glow") "</name>\n"
 
91
                                "<id>org.inkscape.effect.filter.drop-glow</id>\n"
 
92
                                "<param name=\"blur\" gui-text=\"" N_("Blur radius, px") "\" type=\"float\" min=\"0.0\" max=\"200.0\">2.0</param>\n"
 
93
                                "<param name=\"opacity\" gui-text=\"" N_("Opacity, %") "\" type=\"float\" min=\"0.0\" max=\"100.0\">50</param>\n"                               
 
94
                                "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset, px") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">4.0</param>\n"
 
95
                                "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset, px") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">4.0</param>\n"
 
96
                                "<effect>\n"
 
97
                                        "<object-type>all</object-type>\n"
 
98
                                        "<effects-menu>\n"
 
99
                                                "<submenu name=\"" N_("Filters") "\">\n"
 
100
                                                "<submenu name=\"Shadows and Glows\"/>\n"
 
101
                              "</submenu>\n"
 
102
                                        "</effects-menu>\n"
 
103
                                        "<menu-tip>" N_("White, blurred drop glow") "</menu-tip>\n"
 
104
                                "</effect>\n"
 
105
                        "</inkscape-extension>\n", new DropGlow());
 
106
        };
 
107
 
 
108
};
 
109
 
 
110
gchar const *
 
111
DropGlow::get_filter_text (Inkscape::Extension::Extension * ext)
 
112
{
 
113
        if (_filter != NULL) g_free((void *)_filter);
 
114
 
 
115
        float blur = ext->get_param_float("blur");
 
116
        float opacity = ext->get_param_float("opacity") / 100;
 
117
        float x = ext->get_param_float("xoffset");
 
118
        float y = ext->get_param_float("yoffset");
 
119
 
 
120
        _filter = g_strdup_printf(
 
121
                "<filter width=\"1.5\" height=\"1.5\" x=\"-.25\" y=\"-.25\">\n"
 
122
                        "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%f\" result=\"blur\"/>\n"
 
123
                        "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 %f 0 \" />\n"
 
124
                        "<feOffset in=\"bluralpha\" dx=\"%f\" dy=\"%f\" result=\"offsetBlur\"/>\n"
 
125
                        "<feMerge>\n"
 
126
                                "<feMergeNode in=\"offsetBlur\"/>\n"
 
127
                                "<feMergeNode in=\"SourceGraphic\"/>\n"
 
128
                        "</feMerge>\n"
 
129
                "</filter>\n", blur, opacity, x, y);
 
130
 
 
131
        return _filter;
 
132
};
 
133
 
77
134
}; /* namespace Filter */
78
135
}; /* namespace Internal */
79
136
}; /* namespace Extension */