~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/extension/internal/filter/snow.h

  • Committer: JazzyNico
  • Date: 2011-08-29 20:25:30 UTC
  • Revision ID: nicoduf@yahoo.fr-20110829202530-6deuoz11q90usldv
Code refactoring and merging with trunk (revision 10599).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__
2
 
#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__
3
 
/* Change the 'SNOW' above to be your file name */
4
 
 
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 ^^^ */
12
 
 
13
 
#include "filter.h"
14
 
 
15
 
namespace Inkscape {
16
 
namespace Extension {
17
 
namespace Internal {
18
 
namespace Filter {
19
 
 
20
 
class Snow : public Inkscape::Extension::Internal::Filter::Filter {
21
 
protected:
22
 
        virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
23
 
 
24
 
public:
25
 
        Snow ( ) : Filter() { };
26
 
        virtual ~Snow ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
27
 
 
28
 
public:
29
 
        static void init (void) {
30
 
                Inkscape::Extension::build_from_mem(
31
 
                        "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
32
 
                                "<name>" N_("Snow crest") "</name>\n"
33
 
                                "<id>org.inkscape.effect.filter.snow</id>\n"
34
 
                                "<param name=\"drift\" gui-text=\"" N_("Drift Size") "\" type=\"float\" min=\"0.0\" max=\"20.0\">3.5</param>\n"
35
 
                                "<effect>\n"
36
 
                                        "<object-type>all</object-type>\n"
37
 
                                        "<effects-menu>\n"
38
 
                                                "<submenu name=\"" N_("Filters") "\">\n"
39
 
                                                "<submenu name=\"Protrusions\"/>\n"
40
 
                              "</submenu>\n"
41
 
                                        "</effects-menu>\n"
42
 
                                        "<menu-tip>" N_("Snow has fallen on object") "</menu-tip>\n"
43
 
                                "</effect>\n"
44
 
                        "</inkscape-extension>\n", new Snow());
45
 
        };
46
 
 
47
 
};
48
 
 
49
 
gchar const *
50
 
Snow::get_filter_text (Inkscape::Extension::Extension * ext)
51
 
{
52
 
        if (_filter != NULL) g_free((void *)_filter);
53
 
 
54
 
        float drift = ext->get_param_float("drift");
55
 
 
56
 
        _filter = g_strdup_printf(
57
 
                                "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Snow\">\n"
58
 
                                        "<feConvolveMatrix order=\"3 3\" kernelMatrix=\"1 1 1 0 0 0 -1 -1 -1\" preserveAlpha=\"false\" divisor=\"3\"/>\n"
59
 
                                        "<feMorphology operator=\"dilate\" radius=\"1 %f\"/>\n"
60
 
                                        "<feGaussianBlur stdDeviation=\"1.6270889487870621\" result=\"result0\"/>\n"
61
 
                                        "<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"
62
 
                                        "<feOffset dx=\"0\" dy=\"1\" result=\"result5\"/>\n"
63
 
                                        "<feDiffuseLighting in=\"result0\" diffuseConstant=\"2.2613065326633168\" surfaceScale=\"1\">\n"
64
 
                                          "<feDistantLight azimuth=\"225\" elevation=\"32\"/>\n"
65
 
                                        "</feDiffuseLighting>\n"
66
 
                                        "<feComposite in2=\"result1\" operator=\"in\" result=\"result2\"/>\n"
67
 
                                        "<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"
68
 
                                        "<feComposite in2=\"result5\" in=\"result4\"/>\n"
69
 
                                        "<feComposite in2=\"SourceGraphic\"/>\n"
70
 
                                "</filter>\n", drift);
71
 
 
72
 
        return _filter;
73
 
};
74
 
 
75
 
}; /* namespace Filter */
76
 
}; /* namespace Internal */
77
 
}; /* namespace Extension */
78
 
}; /* namespace Inkscape */
79
 
 
80
 
/* Change the 'SNOW' below to be your file name */
81
 
#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ */