From 929f61c316838dd4a8823399df845aa699b9d4e9 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 6 Aug 2011 22:11:25 +0200 Subject: Filters. Global custom predefined filters reorganization. (bzr r10530) --- src/extension/internal/filter/abc.h | 819 --------------------------- src/extension/internal/filter/blurs.h | 133 ++++- src/extension/internal/filter/bumps.h | 256 ++++++++- src/extension/internal/filter/color.h | 126 ++--- src/extension/internal/filter/distort.h | 112 ++++ src/extension/internal/filter/drop-shadow.h | 150 ----- src/extension/internal/filter/experimental.h | 782 ------------------------- src/extension/internal/filter/filter-all.cpp | 64 ++- src/extension/internal/filter/image.h | 6 +- src/extension/internal/filter/morphology.h | 98 +++- src/extension/internal/filter/overlays.h | 147 +++++ src/extension/internal/filter/paint.h | 782 +++++++++++++++++++++++++ src/extension/internal/filter/protrusions.h | 99 ++++ src/extension/internal/filter/shadows.h | 8 +- src/extension/internal/filter/snow.h | 82 --- src/extension/internal/filter/transparency.h | 192 +++++++ 16 files changed, 1890 insertions(+), 1966 deletions(-) delete mode 100755 src/extension/internal/filter/abc.h mode change 100755 => 100644 src/extension/internal/filter/color.h create mode 100644 src/extension/internal/filter/distort.h delete mode 100644 src/extension/internal/filter/drop-shadow.h delete mode 100755 src/extension/internal/filter/experimental.h create mode 100644 src/extension/internal/filter/overlays.h create mode 100644 src/extension/internal/filter/paint.h create mode 100644 src/extension/internal/filter/protrusions.h delete mode 100644 src/extension/internal/filter/snow.h create mode 100644 src/extension/internal/filter/transparency.h diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h deleted file mode 100755 index 832fb90c2..000000000 --- a/src/extension/internal/filter/abc.h +++ /dev/null @@ -1,819 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ -/* Change the 'ABC' above to be your file name */ - -/* - * Copyright (C) 2011 Authors: - * Ivan Louette (filters) - * Nicolas Dufour (UI) - * - * Basic filters - * Clean edges - * Color shift - * Diffuse light - * Feather - * Matte jelly - * Noise fill - * Outline - * Roughen - * Silhouette - * Specular light - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -#include "extension/internal/clear-n_.h" -#include "extension/system.h" -#include "extension/extension.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { -namespace Filter { - -/** - \brief Custom predefined Clean edges filter. - - Removes or decreases glows and jaggeries around objects edges after applying some filters - - Filter's parameters: - * Strength (0.01->2., default 0.4) -> blur (stdDeviation) -*/ - -class CleanEdges : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - CleanEdges ( ) : Filter() { }; - virtual ~CleanEdges ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Clean edges, custom (ABCs)") "\n" - "org.inkscape.effect.filter.CleanEdges\n" - "0.4\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Removes or decreases glows and jaggeries around objects edges after applying some filters") "\n" - "\n" - "\n", new CleanEdges()); - }; - -}; - -gchar const * -CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - - blur << ext->get_param_float("blur"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str()); - - return _filter; -}; /* CleanEdges filter */ - - -/** - \brief Custom predefined Color shift filter. - - Rotate and desaturate hue - - Filter's parameters: - * Shift (0->360, default 330) -> color1 (values) - * Saturation (0.->1., default 0.6) -> color2 (values) -*/ - -class ColorShift : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - ColorShift ( ) : Filter() { }; - virtual ~ColorShift ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Color shift, custom (ABCs)") "\n" - "org.inkscape.effect.filter.ColorShift\n" - "330\n" - "0.6\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Rotate and desaturate hue") "\n" - "\n" - "\n", new ColorShift()); - }; - -}; - -gchar const * -ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream shift; - std::ostringstream sat; - - shift << ext->get_param_int("shift"); - sat << ext->get_param_float("sat"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n", shift.str().c_str(), sat.str().c_str()); - - return _filter; -}; /* ColorShift filter */ - -/** - \brief Custom predefined Diffuse light filter. - - Basic diffuse bevel to use for building textures - - Filter's parameters: - * Smoothness (0.->10., default 6.) -> blur (stdDeviation) - * Elevation (0->360, default 25) -> feDistantLight (elevation) - * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color) -*/ - -class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DiffuseLight ( ) : Filter() { }; - virtual ~DiffuseLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Diffuse light, custom (ABCs)") "\n" - "org.inkscape.effect.filter.DiffuseLight\n" - "6\n" - "25\n" - "235\n" - "-1\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Basic diffuse bevel to use for building textures") "\n" - "\n" - "\n", new DiffuseLight()); - }; - -}; - -gchar const * -DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* DiffuseLight filter */ - -/** - \brief Custom predefined Feather filter. - - Blurred mask on the edge without altering the contents - - Filter's parameters: - * Strength (0.01->100., default 5) -> blur (stdDeviation) -*/ - -class Feather : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Feather ( ) : Filter() { }; - virtual ~Feather ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Feather, custom (ABCs)") "\n" - "org.inkscape.effect.filter.Feather\n" - "5\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Blurred mask on the edge without altering the contents") "\n" - "\n" - "\n", new Feather()); - }; - -}; - -gchar const * -Feather::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - - blur << ext->get_param_float("blur"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str()); - - return _filter; -}; /* Feather filter */ - -/** - \brief Custom predefined Matte jelly filter. - - Bulging, matte jelly covering - - Filter's parameters: - * Smoothness (0.0->10., default 7.) -> blur (stdDeviation) - * Brightness (0.0->5., default .9) -> specular (specularConstant) - * Elevation (0->360, default 60) -> feDistantLight (elevation) - * Azimuth (0->360, default 225) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> specular (lighting-color) -*/ - -class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - MatteJelly ( ) : Filter() { }; - virtual ~MatteJelly ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Matte jelly, custom (ABCs)") "\n" - "org.inkscape.effect.filter.MatteJelly\n" - "7\n" - "0.9\n" - "60\n" - "225\n" - "-1\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Bulging, matte jelly covering") "\n" - "\n" - "\n", new MatteJelly()); - }; - -}; - -gchar const * -MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream bright; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - bright << ext->get_param_float("bright"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* MatteJelly filter */ - -/** - \brief Custom predefined Noise fill filter. - - Basic noise fill and transparency texture - - Filter's parameters: - * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (*1000) (0.01->10000., default 20) -> turbulence (baseFrequency [/1000]) - * Vertical frequency (*1000) (0.01->10000., default 40) -> turbulence (baseFrequency [/1000]) - * Complexity (1->5, default 5) -> turbulence (numOctaves) - * Variation (1->360, default 1) -> turbulence (seed) - * Dilatation (1.->50., default 3) -> color (n-1th value) - * Erosion (0.->50., default 1) -> color (nth value 0->-50) - * Color (guint, default 148,115,39,255) -> flood (flood-color, flood-opacity) - * Inverted (boolean, default false) -> composite1 (operator, true="in", false="out") -*/ - -class NoiseFill : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - NoiseFill ( ) : Filter() { }; - virtual ~NoiseFill ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Noise fill, custom (ABCs)") "\n" - "org.inkscape.effect.filter.NoiseFill\n" - "\n" - "\n" - "\n" - "<_item value=\"fractalNoise\">Fractal noise\n" - "<_item value=\"turbulence\">Turbulence\n" - "\n" - "20\n" - "40\n" - "5\n" - "0\n" - "3\n" - "1\n" - "false\n" - "\n" - "\n" - "354957823\n" - "\n" - "\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Basic noise fill and transparency texture") "\n" - "\n" - "\n", new NoiseFill()); - }; - -}; - -gchar const * -NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream type; - std::ostringstream hfreq; - std::ostringstream vfreq; - std::ostringstream complexity; - std::ostringstream variation; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - std::ostringstream inverted; - - type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 1000); - vfreq << (ext->get_param_float("vfreq") / 1000); - complexity << ext->get_param_int("complexity"); - variation << ext->get_param_int("variation"); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - if (ext->get_param_bool("inverted")) - inverted << "out"; - else - inverted << "in"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), inverted.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); - - return _filter; -}; /* NoiseFill filter */ - -/** - \brief Custom predefined Outline filter. - - Adds a colorizable outline - - Filter's parameters: - * Width (0.01->50., default 5) -> blur1 (stdDeviation) - * Melt (0.01->50., default 2) -> blur2 (stdDeviation) - * Dilatation (1.->50., default 8) -> color2 (n-1th value) - * Erosion (0.->50., default 5) -> color2 (nth value 0->-50) - * Color (guint, default 156,102,102,255) -> flood (flood-color, flood-opacity) - * Blend (enum, default Normal) -> blend (mode) -*/ - -class Outline : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Outline ( ) : Filter() { }; - virtual ~Outline ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Outline, custom (ABCs)") "\n" - "org.inkscape.effect.filter.Outline\n" - "\n" - "\n" - "5\n" - "2\n" - "8\n" - "5\n" - "\n" - "\n" - "1029214207\n" - "\n" - "\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Adds a colorizable outline") "\n" - "\n" - "\n", new Outline()); - }; - -}; - -gchar const * -Outline::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream width; - std::ostringstream melt; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - std::ostringstream blend; - - width << ext->get_param_float("width"); - melt << ext->get_param_float("melt"); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); - - return _filter; -}; /* Outline filter */ - -/** - \brief Custom predefined Roughen filter. - - Small-scale roughening to edges and content - - Filter's parameters: - * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) - * Vertical frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) - * Complexity (1->5, default 5) -> turbulence (numOctaves) - * Variation (1->360, default 1) -> turbulence (seed) - * Intensity (0.0->50., default 6.6) -> displacement (scale) -*/ - -class Roughen : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Roughen ( ) : Filter() { }; - virtual ~Roughen ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Roughen, custom (ABCs)") "\n" - "org.inkscape.effect.filter.Roughen\n" - "\n" - "<_item value=\"fractalNoise\">Fractal noise\n" - "<_item value=\"turbulence\">Turbulence\n" - "\n" - "13\n" - "13\n" - "5\n" - "0\n" - "6.6\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Small-scale roughening to edges and content") "\n" - "\n" - "\n", new Roughen()); - }; - -}; - -gchar const * -Roughen::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream type; - std::ostringstream hfreq; - std::ostringstream vfreq; - std::ostringstream complexity; - std::ostringstream variation; - std::ostringstream intensity; - - type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 1000); - vfreq << (ext->get_param_float("vfreq") / 1000); - complexity << ext->get_param_int("complexity"); - variation << ext->get_param_int("variation"); - intensity << ext->get_param_float("intensity"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str()); - - return _filter; -}; /* Roughen filter */ - -/** - \brief Custom predefined Silhouette filter. - - Repaint anything visible monochrome - - Filter's parameters: - * Blur (0.01->50., default 0.01) -> blur (stdDeviation) - * Cutout (boolean, default False) -> composite (false=in, true=out) - * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity) -*/ - -class Silhouette : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Silhouette ( ) : Filter() { }; - virtual ~Silhouette ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Silhouette, custom (ABCs)") "\n" - "org.inkscape.effect.filter.Silhouette\n" - "0.01\n" - "false\n" - "255\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Repaint anything visible monochrome") "\n" - "\n" - "\n", new Silhouette()); - }; - -}; - -gchar const * -Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream a; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream cutout; - std::ostringstream blur; - - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - if (ext->get_param_bool("cutout")) - cutout << "out"; - else - cutout << "in"; - blur << ext->get_param_float("blur"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), cutout.str().c_str(), blur.str().c_str()); - - return _filter; -}; /* Silhouette filter */ - -/** - \brief Custom predefined Specular light filter. - - Basic specular bevel to use for building textures - - Filter's parameters: - * Smoothness (0.0->10., default 6.) -> blur (stdDeviation) - * Brightness (0.0->5., default 1.) -> specular (specularConstant) - * Elevation (0->360, default 45) -> feDistantLight (elevation) - * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> specular (lighting-color) -*/ - -class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - SpecularLight ( ) : Filter() { }; - virtual ~SpecularLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Specular light, custom (ABCs)") "\n" - "org.inkscape.effect.filter.SpecularLight\n" - "6\n" - "1\n" - "45\n" - "235\n" - "-1\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Basic specular bevel to use for building textures") "\n" - "\n" - "\n", new SpecularLight()); - }; - -}; - -gchar const * -SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream bright; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - bright << ext->get_param_float("bright"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* SpecularLight filter */ - - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'ABC' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ */ diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 0fa15dfe6..d6f9a79e6 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -9,7 +9,9 @@ * * Blur filters * Blur + * Clean edges * Cross blur + * Feather * Image blur * * Released under GNU GPL, read the file 'COPYING' for more information @@ -48,7 +50,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Blur, custom (Blurs)") "\n" + "" N_("Blur") "\n" "org.inkscape.effect.filter.Blur\n" "2\n" "2\n" @@ -56,7 +58,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Simple vertical and horizontal blur effect") "\n" @@ -78,13 +80,68 @@ Blur::get_filter_text (Inkscape::Extension::Extension * ext) vblur << ext->get_param_float("vblur"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", hblur.str().c_str(), vblur.str().c_str()); return _filter; }; /* Blur filter */ +/** + \brief Custom predefined Clean edges filter. + + Removes or decreases glows and jaggeries around objects edges after applying some filters + + Filter's parameters: + * Strength (0.01->2., default 0.4) -> blur (stdDeviation) +*/ + +class CleanEdges : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + CleanEdges ( ) : Filter() { }; + virtual ~CleanEdges ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Clean edges") "\n" + "org.inkscape.effect.filter.CleanEdges\n" + "0.4\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Removes or decreases glows and jaggeries around objects edges after applying some filters") "\n" + "\n" + "\n", new CleanEdges()); + }; + +}; + +gchar const * +CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + + blur << ext->get_param_float("blur"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n", blur.str().c_str()); + + return _filter; +}; /* CleanEdges filter */ /** \brief Custom predefined Cross blur filter. @@ -110,7 +167,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Cross blur, custom (Blurs)") "\n" + "" N_("Cross blur") "\n" "org.inkscape.effect.filter.CrossBlur\n" "0\n" "0\n" @@ -126,7 +183,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Combine vertical and horizontal blur") "\n" @@ -154,7 +211,7 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) blend << ext->get_param_enum("blend"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -165,6 +222,62 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Cross blur filter */ +/** + \brief Custom predefined Feather filter. + + Blurred mask on the edge without altering the contents + + Filter's parameters: + * Strength (0.01->100., default 5) -> blur (stdDeviation) +*/ + +class Feather : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Feather ( ) : Filter() { }; + virtual ~Feather ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Feather") "\n" + "org.inkscape.effect.filter.Feather\n" + "5\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Blurred mask on the edge without altering the contents") "\n" + "\n" + "\n", new Feather()); + }; + +}; + +gchar const * +Feather::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + + blur << ext->get_param_float("blur"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", blur.str().c_str()); + + return _filter; +}; /* Feather filter */ /** \brief Custom predefined Image blur filter. @@ -194,7 +307,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Image blur, custom (Blurs)") "\n" + "" N_("Image blur") "\n" "org.inkscape.effect.filter.ImageBlur\n" "\n" "\n" @@ -220,7 +333,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Blur eroded by white or transparency") "\n" @@ -267,7 +380,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -282,8 +395,6 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Image blur filter */ - - }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index b52581844..596d1547f 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -9,6 +9,9 @@ * * Bump filters * Bump + * Diffuse light + * Matte jelly + * Specular light * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -76,7 +79,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Bump, custom (Bumps)") "\n" + "" N_("Bump") "\n" "org.inkscape.effect.filter.Bump\n" "\n" "\n" @@ -138,7 +141,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("All purposes bump filter") "\n" @@ -241,7 +244,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -262,8 +265,253 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; -}; /* Cross blur filter */ +}; /* Bump filter */ +/** + \brief Custom predefined Diffuse light filter. + + Basic diffuse bevel to use for building textures + + Filter's parameters: + * Smoothness (0.->10., default 6.) -> blur (stdDeviation) + * Elevation (0->360, default 25) -> feDistantLight (elevation) + * Azimuth (0->360, default 235) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color) +*/ + +class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + DiffuseLight ( ) : Filter() { }; + virtual ~DiffuseLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Diffuse light") "\n" + "org.inkscape.effect.filter.DiffuseLight\n" + "6\n" + "25\n" + "235\n" + "-1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Basic diffuse bevel to use for building textures") "\n" + "\n" + "\n", new DiffuseLight()); + }; + +}; + +gchar const * +DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* DiffuseLight filter */ + +/** + \brief Custom predefined Matte jelly filter. + + Bulging, matte jelly covering + + Filter's parameters: + * Smoothness (0.0->10., default 7.) -> blur (stdDeviation) + * Brightness (0.0->5., default .9) -> specular (specularConstant) + * Elevation (0->360, default 60) -> feDistantLight (elevation) + * Azimuth (0->360, default 225) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) +*/ + +class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + MatteJelly ( ) : Filter() { }; + virtual ~MatteJelly ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Matte jelly") "\n" + "org.inkscape.effect.filter.MatteJelly\n" + "7\n" + "0.9\n" + "60\n" + "225\n" + "-1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Bulging, matte jelly covering") "\n" + "\n" + "\n", new MatteJelly()); + }; + +}; + +gchar const * +MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream bright; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + bright << ext->get_param_float("bright"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* MatteJelly filter */ + +/** + \brief Custom predefined Specular light filter. + + Basic specular bevel to use for building textures + + Filter's parameters: + * Smoothness (0.0->10., default 6.) -> blur (stdDeviation) + * Brightness (0.0->5., default 1.) -> specular (specularConstant) + * Elevation (0->360, default 45) -> feDistantLight (elevation) + * Azimuth (0->360, default 235) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) +*/ + +class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + SpecularLight ( ) : Filter() { }; + virtual ~SpecularLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Specular light") "\n" + "org.inkscape.effect.filter.SpecularLight\n" + "6\n" + "1\n" + "45\n" + "235\n" + "-1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Basic specular bevel to use for building textures") "\n" + "\n" + "\n", new SpecularLight()); + }; + +}; + +gchar const * +SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream bright; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + bright << ext->get_param_float("bright"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* SpecularLight filter */ }; /* namespace Filter */ }; /* namespace Internal */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h old mode 100755 new mode 100644 index 7be675bec..e8de022b9 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -10,7 +10,7 @@ * Color filters * Brightness * Channel painting - * Channel transparency + * Color shift * Colorize * Duochrome * Electrize @@ -63,7 +63,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Brightness, custom (Color)") "\n" + "" N_("Brightness") "\n" "org.inkscape.effect.filter.Brightness\n" "2\n" "0.5\n" @@ -73,7 +73,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Brightness filter") "\n" @@ -112,7 +112,6 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Brightness filter */ - /** \brief Custom predefined Channel Painting filter. @@ -144,7 +143,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Channel painting, custom (Color)") "\n" + "" N_("Channel painting") "\n" "org.inkscape.effect.filter.ChannelPaint\n" "\n" "\n" @@ -163,7 +162,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Replace RGB by any color") "\n" @@ -225,90 +224,64 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Channel Painting filter */ - /** - \brief Custom predefined Channel transparency filter. + \brief Custom predefined Color shift filter. - Channel transparency filter. + Rotate and desaturate hue Filter's parameters: - * Saturation (0.->1., default 1.) -> colormatrix1 (values) - * Red (-10.->10., default -1.) -> colormatrix2 (values) - * Green (-10.->10., default 0.5) -> colormatrix2 (values) - * Blue (-10.->10., default 0.5) -> colormatrix2 (values) - * Alpha (-10.->10., default 1.) -> colormatrix2 (values) - * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color) - * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out') - - Matrix: - 1 0 0 0 0 - 0 1 0 0 0 - 0 0 1 0 0 - R G B A 0 + * Shift (0->360, default 330) -> color1 (values) + * Saturation (0.->1., default 0.6) -> color2 (values) */ -class ChannelTransparency : public Inkscape::Extension::Internal::Filter::Filter { + +class ColorShift : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); public: - ChannelTransparency ( ) : Filter() { }; - virtual ~ChannelTransparency ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - + ColorShift ( ) : Filter() { }; + virtual ~ColorShift ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Channel transparency, custom (Color)") "\n" - "org.inkscape.effect.filter.ChannelTransparency\n" - "-1\n" - "0.5\n" - "0.5\n" - "1\n" - "false\n" + "" N_("Color shift") "\n" + "org.inkscape.effect.filter.ColorShift\n" + "330\n" + "0.6\n" "\n" "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" - "" N_("Replace RGB by transparency") "\n" + "" N_("Rotate and desaturate hue") "\n" "\n" - "\n", new ChannelTransparency()); + "\n", new ColorShift()); }; + }; gchar const * -ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) +ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); - std::ostringstream red; - std::ostringstream green; - std::ostringstream blue; - std::ostringstream alpha; - std::ostringstream invert; + std::ostringstream shift; + std::ostringstream sat; - red << ext->get_param_float("red"); - green << ext->get_param_float("green"); - blue << ext->get_param_float("blue"); - alpha << ext->get_param_float("alpha"); + shift << ext->get_param_int("shift"); + sat << ext->get_param_float("sat"); - if (!ext->get_param_bool("invert")) { - invert << "in"; - } else { - invert << "xor"; - } - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), - invert.str().c_str()); + "\n" + "\n" + "\n" + "\n", shift.str().c_str(), sat.str().c_str()); return _filter; -}; /* Channel Transparency filter */ - +}; /* ColorShift filter */ /** \brief Custom predefined Colorize filter. @@ -335,7 +308,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Colorize, custom (Color)") "\n" + "" N_("Colorize") "\n" "org.inkscape.effect.filter.Colorize\n" "\n" "\n" @@ -365,7 +338,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Blend image or object with a flood color") "\n" @@ -420,7 +393,6 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Colorize filter */ - /** \brief Custom predefined Duochrome filter. @@ -444,7 +416,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Duochrome, custom (Color)") "\n" + "" N_("Duochrome") "\n" "org.inkscape.effect.filter.Duochrome\n" "\n" "\n" @@ -467,7 +439,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Convert luminance values to a duochrome palette") "\n" @@ -567,7 +539,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Electrize, custom (Color)") "\n" + "" N_("Electrize") "\n" "org.inkscape.effect.filter.Electrize\n" "2.0\n" "\n" @@ -580,7 +552,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Electro solarization effects") "\n" @@ -661,7 +633,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Greyscale, custom (Color)") "\n" + "" N_("Greyscale") "\n" "org.inkscape.effect.filter.Greyscale\n" "0.21\n" "0.72\n" @@ -672,7 +644,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Customize greyscale components") "\n" @@ -743,7 +715,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Lightness, custom (Color)") "\n" + "" N_("Lightness") "\n" "org.inkscape.effect.filter.Lightness\n" "1\n" "1\n" @@ -752,7 +724,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Modify lights and shadows separately") "\n" @@ -812,7 +784,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Quadritone fantasy, custom (Color)") "\n" + "" N_("Quadritone fantasy") "\n" "org.inkscape.effect.filter.Quadritone\n" "280\n" "100\n" @@ -833,7 +805,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Replace hue by two colors") "\n" @@ -874,7 +846,6 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Quadritone filter */ - /** \brief Custom predefined Solarize filter. @@ -899,7 +870,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Solarize, custom (Color)") "\n" + "" N_("Solarize") "\n" "org.inkscape.effect.filter.Solarize\n" "0\n" "\n" @@ -910,7 +881,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Classic photographic solarization effect") "\n" @@ -954,7 +925,6 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Solarize filter */ - /** \brief Custom predefined Tritone filter. @@ -986,7 +956,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Tritone, custom (Color)") "\n" + "" N_("Tritone") "\n" "org.inkscape.effect.filter.Tritone\n" "\n" "\n" @@ -1020,7 +990,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Create a custom tritone palette with additional glow, blend modes and hue moving") "\n" diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h new file mode 100644 index 000000000..7157722d7 --- /dev/null +++ b/src/extension/internal/filter/distort.h @@ -0,0 +1,112 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ +/* Change the 'DISTORT' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Distort filters + * Roughen + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Roughen filter. + + Small-scale roughening to edges and content + + Filter's parameters: + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Horizontal frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) + * Vertical frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) + * Complexity (1->5, default 5) -> turbulence (numOctaves) + * Variation (1->360, default 1) -> turbulence (seed) + * Intensity (0.0->50., default 6.6) -> displacement (scale) +*/ + +class Roughen : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Roughen ( ) : Filter() { }; + virtual ~Roughen ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Roughen") "\n" + "org.inkscape.effect.filter.Roughen\n" + "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" + "\n" + "13\n" + "13\n" + "5\n" + "0\n" + "6.6\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Small-scale roughening to edges and content") "\n" + "\n" + "\n", new Roughen()); + }; + +}; + +gchar const * +Roughen::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + std::ostringstream hfreq; + std::ostringstream vfreq; + std::ostringstream complexity; + std::ostringstream variation; + std::ostringstream intensity; + + type << ext->get_param_enum("type"); + hfreq << (ext->get_param_float("hfreq") / 1000); + vfreq << (ext->get_param_float("vfreq") / 1000); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + intensity << ext->get_param_float("intensity"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str()); + + return _filter; +}; /* Roughen filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'DISTORT' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ */ diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h deleted file mode 100644 index c2338d194..000000000 --- a/src/extension/internal/filter/drop-shadow.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ -/* Change the 'DROP_SHADOW' above to be your file name */ - -/* - * Copyright (C) 2008 Authors: - * Ted Gould - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -#include "extension/internal/clear-n_.h" -#include "extension/system.h" -#include "extension/extension.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { -namespace Filter { - -class DropShadow : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DropShadow ( ) : Filter() { }; - virtual ~DropShadow ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Drop Shadow") "\n" - "org.inkscape.effect.filter.drop-shadow\n" - "2.0\n" - "50\n" - "4.0\n" - "4.0\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Black, blurred drop shadow") "\n" - "\n" - "\n", new DropShadow()); - }; - -}; - -gchar const * -DropShadow::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - std::ostringstream opacity; - std::ostringstream x; - std::ostringstream y; - - blur << ext->get_param_float("blur"); - opacity << ext->get_param_float("opacity") / 100; - x << ext->get_param_float("xoffset"); - y << ext->get_param_float("yoffset"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str()); - - return _filter; -}; - -class DropGlow : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DropGlow ( ) : Filter() { }; - virtual ~DropGlow ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Drop Glow") "\n" - "org.inkscape.effect.filter.drop-glow\n" - "2.0\n" - "50\n" - "4.0\n" - "4.0\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("White, blurred drop glow") "\n" - "\n" - "\n", new DropGlow()); - }; - -}; - -gchar const * -DropGlow::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - std::ostringstream opacity; - std::ostringstream x; - std::ostringstream y; - - blur << ext->get_param_float("blur"); - opacity << ext->get_param_float("opacity") / 100; - x << ext->get_param_float("xoffset"); - y << ext->get_param_float("yoffset"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str()); - - return _filter; -}; - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'DROP_SHADOW' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ */ diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h deleted file mode 100755 index 2032cb513..000000000 --- a/src/extension/internal/filter/experimental.h +++ /dev/null @@ -1,782 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ -/* Change the 'EXPERIMENTAL' above to be your file name */ - -/* - * Copyright (C) 2011 Authors: - * Ivan Louette (filters) - * Nicolas Dufour (UI) - * - * Experimental filters (no assigned menu) - * Chromolitho - * Cross engraving - * Drawing - * Neon draw - * Posterize - * Posterize basic - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -#include "extension/internal/clear-n_.h" -#include "extension/system.h" -#include "extension/extension.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { -namespace Filter { - -/** - \brief Custom predefined Chromolitho filter. - - Chromo effect with customizable edge drawing and graininess - - Filter's parameters: - * Drawing (boolean, default checked) -> Checked = blend1 (in="convolve1"), unchecked = blend1 (in="composite1") - * Transparent (boolean, default unchecked) -> Checked = colormatrix5 (in="colormatrix4"), Unchecked = colormatrix5 (in="component1") - * Invert (boolean, default false) -> component1 (tableValues) [adds a trailing 0] - * Dented (boolean, default false) -> component1 (tableValues) [adds intermediate 0s] - * Lightness (0.->10., default 0.) -> composite1 (k1) - * Saturation (0.->1., default 1.) -> colormatrix3 (values) - * Noise reduction (1->1000, default 20) -> convolve (kernelMatrix, central value -1001->-2000, default -1020) - * Drawing blend (enum, default Normal) -> blend1 (mode) - * Smoothness (0.01->10, default 1) -> blur1 (stdDeviation) - * Grain (boolean, default unchecked) -> Checked = blend2 (in="colormatrix2"), Unchecked = blend2 (in="blur1") - * Grain x frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, first value) - * Grain y frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, second value) - * Grain complexity (1->5, default 1) -> turbulence1 (numOctaves) - * Grain variation (0->1000, default 0) -> turbulence1 (seed) - * Grain expansion (1.->50., default 1.) -> colormatrix1 (n-1 value) - * Grain erosion (0.->40., default 0.) -> colormatrix1 (nth value) [inverted] - * Grain color (boolean, default true) -> colormatrix2 (values) - * Grain blend (enum, default Normal) -> blend2 (mode) -*/ -class Chromolitho : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Chromolitho ( ) : Filter() { }; - virtual ~Chromolitho ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Chromolitho, custom") "\n" - "org.inkscape.effect.filter.Chromolitho\n" - "\n" - "\n" - "true\n" - "\n" - "<_item value=\"darken\">Darken\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"multiply\">Multiply\n" - "<_item value=\"screen\">Screen\n" - "<_item value=\"lighten\">Lighten\n" - "\n" - "false\n" - "false\n" - "false\n" - "0\n" - "1\n" - "10\n" - "1\n" - "\n" - "\n" - "true\n" - "1000\n" - "1000\n" - "1\n" - "0\n" - "1\n" - "0\n" - "true\n" - "\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"multiply\">Multiply\n" - "<_item value=\"screen\">Screen\n" - "<_item value=\"lighten\">Lighten\n" - "<_item value=\"darken\">Darken\n" - "\n" - "\n" - "\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Chromo effect with customizable edge drawing and graininess") "\n" - "\n" - "\n", new Chromolitho()); - }; -}; - -gchar const * -Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream b1in; - std::ostringstream b2in; - std::ostringstream col3in; - std::ostringstream transf; - std::ostringstream light; - std::ostringstream saturation; - std::ostringstream noise; - std::ostringstream dblend; - std::ostringstream smooth; - std::ostringstream grain; - std::ostringstream grainxf; - std::ostringstream grainyf; - std::ostringstream grainc; - std::ostringstream grainv; - std::ostringstream gblend; - std::ostringstream grainexp; - std::ostringstream grainero; - std::ostringstream graincol; - - if (ext->get_param_bool("drawing")) - b1in << "convolve1"; - else - b1in << "composite1"; - - if (ext->get_param_bool("transparent")) - col3in << "colormatrix4"; - else - col3in << "component1"; - light << ext->get_param_float("light"); - saturation << ext->get_param_float("saturation"); - noise << (-1000 - ext->get_param_int("noise")); - dblend << ext->get_param_enum("dblend"); - smooth << ext->get_param_float("smooth"); - - if (ext->get_param_bool("dented")) { - transf << "0 1 0 1"; - } else { - transf << "0 1 1"; - } - if (ext->get_param_bool("inverted")) - transf << " 0"; - - if (ext->get_param_bool("grain")) - b2in << "colormatrix2"; - else - b2in << "blur1"; - grainxf << (ext->get_param_float("grainxf") / 1000); - grainyf << (ext->get_param_float("grainyf") / 1000); - grainc << ext->get_param_int("grainc"); - grainv << ext->get_param_int("grainv"); - gblend << ext->get_param_enum("gblend"); - grainexp << ext->get_param_float("grainexp"); - grainero << (-ext->get_param_float("grainero")); - if (ext->get_param_bool("graincol")) - graincol << "1"; - else - graincol << "0"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", light.str().c_str(), noise.str().c_str(), b1in.str().c_str(), dblend.str().c_str(), smooth.str().c_str(), grainxf.str().c_str(), grainyf.str().c_str(), grainc.str().c_str(), grainv.str().c_str(), grainexp.str().c_str(), grainero.str().c_str(), graincol.str().c_str(), b2in.str().c_str(), gblend.str().c_str(), saturation.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str(), col3in.str().c_str()); - - return _filter; -}; /* Chromolitho filter */ - -/** - \brief Custom predefined Cross engraving filter. - - Convert image to an engraving made of vertical and horizontal lines - - Filter's parameters: - * Clean-up (1->500, default 30) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1030) - * Dilatation (1.->50., default 1) -> color2 (n-1th value) - * Erosion (0.->50., default 0) -> color2 (nth value 0->-50) - * Strength (0.->10., default 0.5) -> composite2 (k2) - * Length (0.5->20, default 4) -> blur1 (stdDeviation x), blur2 (stdDeviation y) - * Transparent (boolean, default false) -> composite 4 (in, true->composite3, false->blend) -*/ -class CrossEngraving : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - CrossEngraving ( ) : Filter() { }; - virtual ~CrossEngraving ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Cross engraving, custom") "\n" - "org.inkscape.effect.filter.CrossEngraving\n" - "30\n" - "1\n" - "0\n" - "0.5\n" - "4\n" - "false\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Convert image to an engraving made of vertical and horizontal lines") "\n" - "\n" - "\n", new CrossEngraving()); - }; -}; - -gchar const * -CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream clean; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream strength; - std::ostringstream length; - std::ostringstream trans; - - clean << (-1000 - ext->get_param_int("clean")); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - strength << ext->get_param_float("strength"); - length << ext->get_param_float("length"); - if (ext->get_param_bool("trans")) - trans << "composite3"; - else - trans << "blend"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", clean.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), strength.str().c_str(), length.str().c_str(), length.str().c_str(), trans.str().c_str()); - - return _filter; -}; /* CrossEngraving filter */ - -/** - \brief Custom predefined Drawing filter. - - Convert images to duochrome drawings. - - Filter's parameters: - * Simplification strength (0.01->20, default 0.6) -> blur1 (stdDeviation) - * Clean-up (1->500, default 10) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1010) - * Erase (0.->6., default 0) -> composite1 (k4) - * Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation) - * Dilatation (1.->50., default 6) -> color2 (n-1th value) - * Erosion (0.->50., default 2) -> color2 (nth value 0->-50) - * translucent (boolean, default false) -> composite 8 (in, true->merge1, false->color5) - - * Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation) - * Blur dilatation (1.->50., default 6) -> color4 (n-1th value) - * Blur erosion (0.->50., default 2) -> color4 (nth value 0->-50) - - * Stroke color (guint, default 64,64,64,255) -> flood2 (flood-color), composite3 (k2) - * Image on stroke (boolean, default false) -> composite2 (in="flood2" true-> in="SourceGraphic") - * Offset (-100->100, default 0) -> offset (val) - - * Fill color (guint, default 200,200,200,255) -> flood3 (flood-opacity), composite5 (k2) - * Image on fill (boolean, default false) -> composite4 (in="flood3" true-> in="SourceGraphic") - -*/ - -class Drawing : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Drawing ( ) : Filter() { }; - virtual ~Drawing ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Drawing, custom") "\n" - "org.inkscape.effect.filter.Drawing\n" - "\n" - "\n" - "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">Simplify\n" - "0.6\n" - "10\n" - "0\n" - "false\n" - "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness\n" - "0.6\n" - "6\n" - "2\n" - "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">Melt\n" - "1\n" - "6\n" - "2\n" - "\n" - "\n" - "-1515870721\n" - "false\n" - "\n" - "\n" - "589505535\n" - "false\n" - "0\n" - "\n" - "\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Convert images to duochrome drawings") "\n" - "\n" - "\n", new Drawing()); - }; -}; - -gchar const * -Drawing::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream simply; - std::ostringstream clean; - std::ostringstream erase; - std::ostringstream smooth; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream translucent; - std::ostringstream offset; - std::ostringstream blur; - std::ostringstream bdilat; - std::ostringstream berosion; - std::ostringstream strokea; - std::ostringstream stroker; - std::ostringstream strokeg; - std::ostringstream strokeb; - std::ostringstream ios; - std::ostringstream filla; - std::ostringstream fillr; - std::ostringstream fillg; - std::ostringstream fillb; - std::ostringstream iof; - - simply << ext->get_param_float("simply"); - clean << (-1000 - ext->get_param_int("clean")); - erase << (ext->get_param_float("erase") / 10); - smooth << ext->get_param_float("smooth"); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - if (ext->get_param_bool("translucent")) - translucent << "merge1"; - else - translucent << "color5"; - offset << ext->get_param_int("offset"); - - blur << ext->get_param_float("blur"); - bdilat << ext->get_param_float("bdilat"); - berosion << (- ext->get_param_float("berosion")); - - guint32 fcolor = ext->get_param_color("fcolor"); - fillr << ((fcolor >> 24) & 0xff); - fillg << ((fcolor >> 16) & 0xff); - fillb << ((fcolor >> 8) & 0xff); - filla << (fcolor & 0xff) / 255.0F; - if (ext->get_param_bool("iof")) - iof << "SourceGraphic"; - else - iof << "flood3"; - - guint32 scolor = ext->get_param_color("scolor"); - stroker << ((scolor >> 24) & 0xff); - strokeg << ((scolor >> 16) & 0xff); - strokeb << ((scolor >> 8) & 0xff); - strokea << (scolor & 0xff) / 255.0F; - if (ext->get_param_bool("ios")) - ios << "SourceGraphic"; - else - ios << "flood2"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), translucent.str().c_str()); - - return _filter; -}; /* Drawing filter */ - - -/** - \brief Custom predefined Neon draw filter. - - Posterize and draw smooth lines around color shapes - - Filter's parameters: - * Lines type (enum, default smooth) -> - smooth = component1 (type="table"), component2 (type="table"), composite1 (in2="blur2") - hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1") - * Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation) - * Line width (0.01->20., default 1.5) -> blur2 (stdDeviation) - * Lightness (0.->10., default 0.5) -> composite1 (k3) - * Blend (enum [normal, multiply, screen], default normal) -> blend (mode) - * Dark mode (boolean, default false) -> composite1 (true: in2="component2") -*/ -class NeonDraw : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - NeonDraw ( ) : Filter() { }; - virtual ~NeonDraw ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Neon draw, custom") "\n" - "org.inkscape.effect.filter.NeonDraw\n" - "\n" - "<_item value=\"table\">Smoothed\n" - "<_item value=\"discrete\">Contrasted\n" - "\n" - "1.5\n" - "1.5\n" - "0.5\n" - "\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"multiply\">Multiply\n" - "<_item value=\"screen\">Screen\n" - "\n" - "false\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Posterize and draw smooth lines around color shapes") "\n" - "\n" - "\n", new NeonDraw()); - }; -}; - -gchar const * -NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blend; - std::ostringstream simply; - std::ostringstream width; - std::ostringstream lightness; - std::ostringstream type; - std::ostringstream dark; - - type << ext->get_param_enum("type"); - blend << ext->get_param_enum("blend"); - simply << ext->get_param_float("simply"); - width << ext->get_param_float("width"); - lightness << ext->get_param_float("lightness"); - - const gchar *typestr = ext->get_param_enum("type"); - if (ext->get_param_bool("dark")) - dark << "component2"; - else if ((g_ascii_strcasecmp("table", typestr) == 0)) - dark << "blur2"; - else - dark << "component1"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), dark.str().c_str(), lightness.str().c_str()); - - return _filter; -}; /* NeonDraw filter */ - -/** - \brief Custom predefined Poster paint filter. - - Poster and painting effects. - - Filter's parameters: - * Effect type (enum, default "Normal") -> - Normal = feComponentTransfer - Dented = Normal + intermediate values - * Transfer type (enum, default "descrete") -> component (type) - * Levels (0->15, default 5) -> component (tableValues) - * Blend mode (enum, default "Lighten") -> blend (mode) - * Primary simplify (0.01->100., default 4.) -> blur1 (stdDeviation) - * Secondary simplify (0.01->100., default 0.5) -> blur2 (stdDeviation) - * Pre-saturation (0.->1., default 1.) -> color1 (values) - * Post-saturation (0.->1., default 1.) -> color2 (values) - * Simulate antialiasing (boolean, default false) -> blur3 (true->stdDeviation=0.5, false->stdDeviation=0.01) -*/ -class Posterize : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Posterize ( ) : Filter() { }; - virtual ~Posterize ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Poster paint, custom") "\n" - "org.inkscape.effect.filter.Posterize\n" - "\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"dented\">Dented\n" - "\n" - "\n" - "<_item value=\"discrete\">Poster\n" - "<_item value=\"table\">Painting\n" - "\n" - "5\n" - "\n" - "<_item value=\"lighten\">Lighten\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"darken\">Darken\n" - "<_item value=\"multiply\">Multiply\n" - "<_item value=\"screen\">Screen\n" - "\n" - "4.0\n" - "0.5\n" - "1.00\n" - "1.00\n" - "false\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Poster and painting effects") "\n" - "\n" - "\n", new Posterize()); - }; -}; - -gchar const * -Posterize::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream table; - std::ostringstream blendmode; - std::ostringstream blur1; - std::ostringstream blur2; - std::ostringstream presat; - std::ostringstream postsat; - std::ostringstream transf; - std::ostringstream antialias; - - table << ext->get_param_enum("table"); - blendmode << ext->get_param_enum("blend"); - blur1 << ext->get_param_float("blur1"); - blur2 << ext->get_param_float("blur2"); - presat << ext->get_param_float("presaturation"); - postsat << ext->get_param_float("postsaturation"); - - // TransfertComponent table values are calculated based on the poster type. - transf << "0"; - int levels = ext->get_param_int("levels") + 1; - const gchar *effecttype = ext->get_param_enum("type"); - float val = 0.0; - if (levels == 1) { - if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { - transf << " 1 0 1"; - } else { - transf << " 1"; - } - } else { - for ( int step = 1 ; step <= levels ; step++ ) { - val = (float) step / levels; - transf << " " << val; - if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { - transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels))); - } - } - } - transf << " 1"; - - if (ext->get_param_bool("antialiasing")) - antialias << "0.5"; - else - antialias << "0.01"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur1.str().c_str(), blur2.str().c_str(), blendmode.str().c_str(), presat.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), postsat.str().c_str(), antialias.str().c_str()); - - return _filter; -}; /* Posterize filter */ - -/** - \brief Custom predefined Posterize basic filter. - - Simple posterizing effect - - Filter's parameters: - * Levels (0->20, default 5) -> component1 (tableValues) - * Blur (0.01->20., default 4.) -> blur1 (stdDeviation) -*/ -class PosterizeBasic : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - PosterizeBasic ( ) : Filter() { }; - virtual ~PosterizeBasic ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Posterize basic, custom") "\n" - "org.inkscape.effect.filter.PosterizeBasic\n" - "5\n" - "4.0\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Simple posterizing effect") "\n" - "\n" - "\n", new PosterizeBasic()); - }; -}; - -gchar const * -PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - std::ostringstream transf; - - blur << ext->get_param_float("blur"); - - transf << "0"; - int levels = ext->get_param_int("levels") + 1; - float val = 0.0; - for ( int step = 1 ; step <= levels ; step++ ) { - val = (float) step / levels; - transf << " " << val; - } - transf << " 1"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str()); - - return _filter; -}; /* PosterizeBasic filter */ - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'EXPERIMENTAL' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ */ diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index b451ac619..ffac97e0c 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -8,17 +8,17 @@ #include "filter.h" /* Put your filter here */ -#include "abc.h" #include "blurs.h" #include "bumps.h" #include "color.h" -#include "drop-shadow.h" +#include "distort.h" #include "image.h" #include "morphology.h" +#include "overlays.h" +#include "paint.h" +#include "protrusions.h" #include "shadows.h" -#include "snow.h" - -#include "experimental.h" +#include "transparency.h" namespace Inkscape { namespace Extension { @@ -30,36 +30,26 @@ void Filter::filters_all (void ) { // Here come the filters which are coded in C++ in order to present a parameters dialog - DropShadow::init(); - DropGlow::init(); - Snow::init(); /* Experimental custom predefined filters */ - // ABC - CleanEdges::init(); - ColorShift::init(); - DiffuseLight::init(); - Feather::init(); - MatteJelly::init(); - NoiseFill::init(); - Outline::init(); - Roughen::init(); - Silhouette::init(); - SpecularLight::init(); - // Blurs Blur::init(); + CleanEdges::init(); CrossBlur::init(); + Feather::init(); ImageBlur::init(); // Bumps Bump::init(); - + DiffuseLight::init(); + MatteJelly::init(); + SpecularLight::init(); + // Color Brightness::init(); ChannelPaint::init(); - ChannelTransparency::init(); + ColorShift::init(); Colorize::init(); Duochrome::init(); Electrize::init(); @@ -69,16 +59,13 @@ Filter::filters_all (void ) Solarize::init(); Tritone::init(); - // Image - EdgeDetect::init(); - - // Morphology - Crosssmooth::init(); + // Distort + Roughen::init(); - // Shadows and glows - ColorizableDropShadow::init(); + // Image effect + EdgeDetect::init(); - // TDB + // Image paint and draw Chromolitho::init(); CrossEngraving::init(); Drawing::init(); @@ -86,6 +73,23 @@ Filter::filters_all (void ) Posterize::init(); PosterizeBasic::init(); + // Morphology + Crosssmooth::init(); + Outline::init(); + + // Overlays + NoiseFill::init(); + + // Protrusions + Snow::init(); + + // Shadows and glows + ColorizableDropShadow::init(); + + // Fill and transparency + ChannelTransparency::init(); + Silhouette::init(); + // Here come the rest of the filters that are read from SVG files in share/filters and // .config/Inkscape/filters /* This should always be last, don't put stuff below this diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index bc052bfc0..3f1a33055 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -46,7 +46,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Edge detect, custom (Image)") "\n" + "" N_("Edge detect") "\n" "org.inkscape.effect.filter.EdgeDetect\n" "\n" "<_item value=\"all\">" N_("All") "\n" @@ -59,7 +59,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Detect color edges in object") "\n" @@ -97,7 +97,7 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str()); diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 25cef0fca..59c33f586 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -9,6 +9,7 @@ * * Morphology filters * Cross-smooth + * Outline * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -48,7 +49,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Cross-smooth, custom (Morphology)") "\n" + "" N_("Cross-smooth") "\n" "org.inkscape.effect.filter.crosssmooth\n" "\n" "<_item value=\"edges\">Smooth edges\n" @@ -59,7 +60,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Smooth edges and angles of shapes") "\n" @@ -87,7 +88,7 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -98,6 +99,97 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Crosssmooth filter */ +/** + \brief Custom predefined Outline filter. + + Adds a colorizable outline + + Filter's parameters: + * Width (0.01->50., default 5) -> blur1 (stdDeviation) + * Melt (0.01->50., default 2) -> blur2 (stdDeviation) + * Dilatation (1.->50., default 8) -> color2 (n-1th value) + * Erosion (0.->50., default 5) -> color2 (nth value 0->-50) + * Color (guint, default 156,102,102,255) -> flood (flood-color, flood-opacity) + * Blend (enum, default Normal) -> blend (mode) +*/ + +class Outline : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Outline ( ) : Filter() { }; + virtual ~Outline ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Outline") "\n" + "org.inkscape.effect.filter.Outline\n" + "\n" + "\n" + "5\n" + "2\n" + "8\n" + "5\n" + "\n" + "\n" + "1029214207\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Adds a colorizable outline") "\n" + "\n" + "\n", new Outline()); + }; + +}; + +gchar const * +Outline::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream width; + std::ostringstream melt; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + std::ostringstream blend; + + width << ext->get_param_float("width"); + melt << ext->get_param_float("melt"); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); + + return _filter; +}; /* Outline filter */ + }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h new file mode 100644 index 000000000..4c59b553b --- /dev/null +++ b/src/extension/internal/filter/overlays.h @@ -0,0 +1,147 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ +/* Change the 'OVERLAYS' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Overlays filters + * Noise fill + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Noise fill filter. + + Basic noise fill and transparency texture + + Filter's parameters: + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Horizontal frequency (*1000) (0.01->10000., default 20) -> turbulence (baseFrequency [/1000]) + * Vertical frequency (*1000) (0.01->10000., default 40) -> turbulence (baseFrequency [/1000]) + * Complexity (1->5, default 5) -> turbulence (numOctaves) + * Variation (1->360, default 1) -> turbulence (seed) + * Dilatation (1.->50., default 3) -> color (n-1th value) + * Erosion (0.->50., default 1) -> color (nth value 0->-50) + * Color (guint, default 148,115,39,255) -> flood (flood-color, flood-opacity) + * Inverted (boolean, default false) -> composite1 (operator, true="in", false="out") +*/ + +class NoiseFill : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + NoiseFill ( ) : Filter() { }; + virtual ~NoiseFill ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Noise fill") "\n" + "org.inkscape.effect.filter.NoiseFill\n" + "\n" + "\n" + "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" + "\n" + "20\n" + "40\n" + "5\n" + "0\n" + "3\n" + "1\n" + "false\n" + "\n" + "\n" + "354957823\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Basic noise fill and transparency texture") "\n" + "\n" + "\n", new NoiseFill()); + }; + +}; + +gchar const * +NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + std::ostringstream hfreq; + std::ostringstream vfreq; + std::ostringstream complexity; + std::ostringstream variation; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + std::ostringstream inverted; + + type << ext->get_param_enum("type"); + hfreq << (ext->get_param_float("hfreq") / 1000); + vfreq << (ext->get_param_float("vfreq") / 1000); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + if (ext->get_param_bool("inverted")) + inverted << "out"; + else + inverted << "in"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), inverted.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); + + return _filter; +}; /* NoiseFill filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'OVERLAYS' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ */ diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h new file mode 100644 index 000000000..7a1cc6046 --- /dev/null +++ b/src/extension/internal/filter/paint.h @@ -0,0 +1,782 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ +/* Change the 'PAINT' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Image paint and draw filters + * Chromolitho + * Cross engraving + * Drawing + * Neon draw + * Posterize + * Posterize basic + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Chromolitho filter. + + Chromo effect with customizable edge drawing and graininess + + Filter's parameters: + * Drawing (boolean, default checked) -> Checked = blend1 (in="convolve1"), unchecked = blend1 (in="composite1") + * Transparent (boolean, default unchecked) -> Checked = colormatrix5 (in="colormatrix4"), Unchecked = colormatrix5 (in="component1") + * Invert (boolean, default false) -> component1 (tableValues) [adds a trailing 0] + * Dented (boolean, default false) -> component1 (tableValues) [adds intermediate 0s] + * Lightness (0.->10., default 0.) -> composite1 (k1) + * Saturation (0.->1., default 1.) -> colormatrix3 (values) + * Noise reduction (1->1000, default 20) -> convolve (kernelMatrix, central value -1001->-2000, default -1020) + * Drawing blend (enum, default Normal) -> blend1 (mode) + * Smoothness (0.01->10, default 1) -> blur1 (stdDeviation) + * Grain (boolean, default unchecked) -> Checked = blend2 (in="colormatrix2"), Unchecked = blend2 (in="blur1") + * Grain x frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, first value) + * Grain y frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, second value) + * Grain complexity (1->5, default 1) -> turbulence1 (numOctaves) + * Grain variation (0->1000, default 0) -> turbulence1 (seed) + * Grain expansion (1.->50., default 1.) -> colormatrix1 (n-1 value) + * Grain erosion (0.->40., default 0.) -> colormatrix1 (nth value) [inverted] + * Grain color (boolean, default true) -> colormatrix2 (values) + * Grain blend (enum, default Normal) -> blend2 (mode) +*/ +class Chromolitho : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Chromolitho ( ) : Filter() { }; + virtual ~Chromolitho ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Chromolitho") "\n" + "org.inkscape.effect.filter.Chromolitho\n" + "\n" + "\n" + "true\n" + "\n" + "<_item value=\"darken\">Darken\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "<_item value=\"lighten\">Lighten\n" + "\n" + "false\n" + "false\n" + "false\n" + "0\n" + "1\n" + "10\n" + "1\n" + "\n" + "\n" + "true\n" + "1000\n" + "1000\n" + "1\n" + "0\n" + "1\n" + "0\n" + "true\n" + "\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "<_item value=\"lighten\">Lighten\n" + "<_item value=\"darken\">Darken\n" + "\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Chromo effect with customizable edge drawing and graininess") "\n" + "\n" + "\n", new Chromolitho()); + }; +}; + +gchar const * +Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream b1in; + std::ostringstream b2in; + std::ostringstream col3in; + std::ostringstream transf; + std::ostringstream light; + std::ostringstream saturation; + std::ostringstream noise; + std::ostringstream dblend; + std::ostringstream smooth; + std::ostringstream grain; + std::ostringstream grainxf; + std::ostringstream grainyf; + std::ostringstream grainc; + std::ostringstream grainv; + std::ostringstream gblend; + std::ostringstream grainexp; + std::ostringstream grainero; + std::ostringstream graincol; + + if (ext->get_param_bool("drawing")) + b1in << "convolve1"; + else + b1in << "composite1"; + + if (ext->get_param_bool("transparent")) + col3in << "colormatrix4"; + else + col3in << "component1"; + light << ext->get_param_float("light"); + saturation << ext->get_param_float("saturation"); + noise << (-1000 - ext->get_param_int("noise")); + dblend << ext->get_param_enum("dblend"); + smooth << ext->get_param_float("smooth"); + + if (ext->get_param_bool("dented")) { + transf << "0 1 0 1"; + } else { + transf << "0 1 1"; + } + if (ext->get_param_bool("inverted")) + transf << " 0"; + + if (ext->get_param_bool("grain")) + b2in << "colormatrix2"; + else + b2in << "blur1"; + grainxf << (ext->get_param_float("grainxf") / 1000); + grainyf << (ext->get_param_float("grainyf") / 1000); + grainc << ext->get_param_int("grainc"); + grainv << ext->get_param_int("grainv"); + gblend << ext->get_param_enum("gblend"); + grainexp << ext->get_param_float("grainexp"); + grainero << (-ext->get_param_float("grainero")); + if (ext->get_param_bool("graincol")) + graincol << "1"; + else + graincol << "0"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", light.str().c_str(), noise.str().c_str(), b1in.str().c_str(), dblend.str().c_str(), smooth.str().c_str(), grainxf.str().c_str(), grainyf.str().c_str(), grainc.str().c_str(), grainv.str().c_str(), grainexp.str().c_str(), grainero.str().c_str(), graincol.str().c_str(), b2in.str().c_str(), gblend.str().c_str(), saturation.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str(), col3in.str().c_str()); + + return _filter; +}; /* Chromolitho filter */ + +/** + \brief Custom predefined Cross engraving filter. + + Convert image to an engraving made of vertical and horizontal lines + + Filter's parameters: + * Clean-up (1->500, default 30) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1030) + * Dilatation (1.->50., default 1) -> color2 (n-1th value) + * Erosion (0.->50., default 0) -> color2 (nth value 0->-50) + * Strength (0.->10., default 0.5) -> composite2 (k2) + * Length (0.5->20, default 4) -> blur1 (stdDeviation x), blur2 (stdDeviation y) + * Transparent (boolean, default false) -> composite 4 (in, true->composite3, false->blend) +*/ +class CrossEngraving : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + CrossEngraving ( ) : Filter() { }; + virtual ~CrossEngraving ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Cross engraving") "\n" + "org.inkscape.effect.filter.CrossEngraving\n" + "30\n" + "1\n" + "0\n" + "0.5\n" + "4\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Convert image to an engraving made of vertical and horizontal lines") "\n" + "\n" + "\n", new CrossEngraving()); + }; +}; + +gchar const * +CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream clean; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream strength; + std::ostringstream length; + std::ostringstream trans; + + clean << (-1000 - ext->get_param_int("clean")); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + strength << ext->get_param_float("strength"); + length << ext->get_param_float("length"); + if (ext->get_param_bool("trans")) + trans << "composite3"; + else + trans << "blend"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", clean.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), strength.str().c_str(), length.str().c_str(), length.str().c_str(), trans.str().c_str()); + + return _filter; +}; /* CrossEngraving filter */ + +/** + \brief Custom predefined Drawing filter. + + Convert images to duochrome drawings. + + Filter's parameters: + * Simplification strength (0.01->20, default 0.6) -> blur1 (stdDeviation) + * Clean-up (1->500, default 10) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1010) + * Erase (0.->6., default 0) -> composite1 (k4) + * Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation) + * Dilatation (1.->50., default 6) -> color2 (n-1th value) + * Erosion (0.->50., default 2) -> color2 (nth value 0->-50) + * translucent (boolean, default false) -> composite 8 (in, true->merge1, false->color5) + + * Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation) + * Blur dilatation (1.->50., default 6) -> color4 (n-1th value) + * Blur erosion (0.->50., default 2) -> color4 (nth value 0->-50) + + * Stroke color (guint, default 64,64,64,255) -> flood2 (flood-color), composite3 (k2) + * Image on stroke (boolean, default false) -> composite2 (in="flood2" true-> in="SourceGraphic") + * Offset (-100->100, default 0) -> offset (val) + + * Fill color (guint, default 200,200,200,255) -> flood3 (flood-opacity), composite5 (k2) + * Image on fill (boolean, default false) -> composite4 (in="flood3" true-> in="SourceGraphic") + +*/ + +class Drawing : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Drawing ( ) : Filter() { }; + virtual ~Drawing ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Drawing") "\n" + "org.inkscape.effect.filter.Drawing\n" + "\n" + "\n" + "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">Simplify\n" + "0.6\n" + "10\n" + "0\n" + "false\n" + "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness\n" + "0.6\n" + "6\n" + "2\n" + "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">Melt\n" + "1\n" + "6\n" + "2\n" + "\n" + "\n" + "-1515870721\n" + "false\n" + "\n" + "\n" + "589505535\n" + "false\n" + "0\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Convert images to duochrome drawings") "\n" + "\n" + "\n", new Drawing()); + }; +}; + +gchar const * +Drawing::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream simply; + std::ostringstream clean; + std::ostringstream erase; + std::ostringstream smooth; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream translucent; + std::ostringstream offset; + std::ostringstream blur; + std::ostringstream bdilat; + std::ostringstream berosion; + std::ostringstream strokea; + std::ostringstream stroker; + std::ostringstream strokeg; + std::ostringstream strokeb; + std::ostringstream ios; + std::ostringstream filla; + std::ostringstream fillr; + std::ostringstream fillg; + std::ostringstream fillb; + std::ostringstream iof; + + simply << ext->get_param_float("simply"); + clean << (-1000 - ext->get_param_int("clean")); + erase << (ext->get_param_float("erase") / 10); + smooth << ext->get_param_float("smooth"); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + if (ext->get_param_bool("translucent")) + translucent << "merge1"; + else + translucent << "color5"; + offset << ext->get_param_int("offset"); + + blur << ext->get_param_float("blur"); + bdilat << ext->get_param_float("bdilat"); + berosion << (- ext->get_param_float("berosion")); + + guint32 fcolor = ext->get_param_color("fcolor"); + fillr << ((fcolor >> 24) & 0xff); + fillg << ((fcolor >> 16) & 0xff); + fillb << ((fcolor >> 8) & 0xff); + filla << (fcolor & 0xff) / 255.0F; + if (ext->get_param_bool("iof")) + iof << "SourceGraphic"; + else + iof << "flood3"; + + guint32 scolor = ext->get_param_color("scolor"); + stroker << ((scolor >> 24) & 0xff); + strokeg << ((scolor >> 16) & 0xff); + strokeb << ((scolor >> 8) & 0xff); + strokea << (scolor & 0xff) / 255.0F; + if (ext->get_param_bool("ios")) + ios << "SourceGraphic"; + else + ios << "flood2"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), translucent.str().c_str()); + + return _filter; +}; /* Drawing filter */ + + +/** + \brief Custom predefined Neon draw filter. + + Posterize and draw smooth lines around color shapes + + Filter's parameters: + * Lines type (enum, default smooth) -> + smooth = component1 (type="table"), component2 (type="table"), composite1 (in2="blur2") + hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1") + * Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation) + * Line width (0.01->20., default 1.5) -> blur2 (stdDeviation) + * Lightness (0.->10., default 0.5) -> composite1 (k3) + * Blend (enum [normal, multiply, screen], default normal) -> blend (mode) + * Dark mode (boolean, default false) -> composite1 (true: in2="component2") +*/ +class NeonDraw : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + NeonDraw ( ) : Filter() { }; + virtual ~NeonDraw ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Neon draw") "\n" + "org.inkscape.effect.filter.NeonDraw\n" + "\n" + "<_item value=\"table\">Smoothed\n" + "<_item value=\"discrete\">Contrasted\n" + "\n" + "1.5\n" + "1.5\n" + "0.5\n" + "\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Posterize and draw smooth lines around color shapes") "\n" + "\n" + "\n", new NeonDraw()); + }; +}; + +gchar const * +NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blend; + std::ostringstream simply; + std::ostringstream width; + std::ostringstream lightness; + std::ostringstream type; + std::ostringstream dark; + + type << ext->get_param_enum("type"); + blend << ext->get_param_enum("blend"); + simply << ext->get_param_float("simply"); + width << ext->get_param_float("width"); + lightness << ext->get_param_float("lightness"); + + const gchar *typestr = ext->get_param_enum("type"); + if (ext->get_param_bool("dark")) + dark << "component2"; + else if ((g_ascii_strcasecmp("table", typestr) == 0)) + dark << "blur2"; + else + dark << "component1"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), dark.str().c_str(), lightness.str().c_str()); + + return _filter; +}; /* NeonDraw filter */ + +/** + \brief Custom predefined Poster paint filter. + + Poster and painting effects. + + Filter's parameters: + * Effect type (enum, default "Normal") -> + Normal = feComponentTransfer + Dented = Normal + intermediate values + * Transfer type (enum, default "descrete") -> component (type) + * Levels (0->15, default 5) -> component (tableValues) + * Blend mode (enum, default "Lighten") -> blend (mode) + * Primary simplify (0.01->100., default 4.) -> blur1 (stdDeviation) + * Secondary simplify (0.01->100., default 0.5) -> blur2 (stdDeviation) + * Pre-saturation (0.->1., default 1.) -> color1 (values) + * Post-saturation (0.->1., default 1.) -> color2 (values) + * Simulate antialiasing (boolean, default false) -> blur3 (true->stdDeviation=0.5, false->stdDeviation=0.01) +*/ +class Posterize : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Posterize ( ) : Filter() { }; + virtual ~Posterize ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Poster paint") "\n" + "org.inkscape.effect.filter.Posterize\n" + "\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"dented\">Dented\n" + "\n" + "\n" + "<_item value=\"discrete\">Poster\n" + "<_item value=\"table\">Painting\n" + "\n" + "5\n" + "\n" + "<_item value=\"lighten\">Lighten\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"darken\">Darken\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "\n" + "4.0\n" + "0.5\n" + "1.00\n" + "1.00\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Poster and painting effects") "\n" + "\n" + "\n", new Posterize()); + }; +}; + +gchar const * +Posterize::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream table; + std::ostringstream blendmode; + std::ostringstream blur1; + std::ostringstream blur2; + std::ostringstream presat; + std::ostringstream postsat; + std::ostringstream transf; + std::ostringstream antialias; + + table << ext->get_param_enum("table"); + blendmode << ext->get_param_enum("blend"); + blur1 << ext->get_param_float("blur1"); + blur2 << ext->get_param_float("blur2"); + presat << ext->get_param_float("presaturation"); + postsat << ext->get_param_float("postsaturation"); + + // TransfertComponent table values are calculated based on the poster type. + transf << "0"; + int levels = ext->get_param_int("levels") + 1; + const gchar *effecttype = ext->get_param_enum("type"); + float val = 0.0; + if (levels == 1) { + if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { + transf << " 1 0 1"; + } else { + transf << " 1"; + } + } else { + for ( int step = 1 ; step <= levels ; step++ ) { + val = (float) step / levels; + transf << " " << val; + if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { + transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels))); + } + } + } + transf << " 1"; + + if (ext->get_param_bool("antialiasing")) + antialias << "0.5"; + else + antialias << "0.01"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", blur1.str().c_str(), blur2.str().c_str(), blendmode.str().c_str(), presat.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), postsat.str().c_str(), antialias.str().c_str()); + + return _filter; +}; /* Posterize filter */ + +/** + \brief Custom predefined Posterize basic filter. + + Simple posterizing effect + + Filter's parameters: + * Levels (0->20, default 5) -> component1 (tableValues) + * Blur (0.01->20., default 4.) -> blur1 (stdDeviation) +*/ +class PosterizeBasic : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + PosterizeBasic ( ) : Filter() { }; + virtual ~PosterizeBasic ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Posterize basic") "\n" + "org.inkscape.effect.filter.PosterizeBasic\n" + "5\n" + "4.0\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Simple posterizing effect") "\n" + "\n" + "\n", new PosterizeBasic()); + }; +}; + +gchar const * +PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + std::ostringstream transf; + + blur << ext->get_param_float("blur"); + + transf << "0"; + int levels = ext->get_param_int("levels") + 1; + float val = 0.0; + for ( int step = 1 ; step <= levels ; step++ ) { + val = (float) step / levels; + transf << " " << val; + } + transf << " 1"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", blur.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str()); + + return _filter; +}; /* PosterizeBasic filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'PAINT' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ */ diff --git a/src/extension/internal/filter/protrusions.h b/src/extension/internal/filter/protrusions.h new file mode 100644 index 000000000..9103bdc11 --- /dev/null +++ b/src/extension/internal/filter/protrusions.h @@ -0,0 +1,99 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ +/* Change the 'PROTRUSIONS' above to be your file name */ + +/* + * Copyright (C) 2008 Authors: + * Ted Gould + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Protrusion filters + * Snow + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + + +/** + \brief Custom predefined Snow filter. + + Snow has fallen on object. +*/ +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) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Snow crest") "\n" + "org.inkscape.effect.filter.snow\n" + "3.5\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Snow has fallen on object") "\n" + "\n" + "\n", new Snow()); + }; + +}; + +gchar const * +Snow::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream drift; + drift << ext->get_param_float("drift"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", drift.str().c_str()); + + return _filter; +}; /* Snow filter */ + + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'PROTRUSIONS' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ */ diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 2339373c1..49f1003cc 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -53,7 +53,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Drop shadow, custom (Shadows and Glows)") "\n" + "" N_("Drop shadow") "\n" "org.inkscape.effect.filter.ColorDropShadow\n" "\n" "\n" @@ -76,7 +76,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Colorizable Drop shadow") "\n" @@ -158,7 +158,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -170,7 +170,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) comp2in1.str().c_str(), comp2in2.str().c_str(), comp2op.str().c_str()); return _filter; -}; +}; /* Drop shadow filter */ }; /* namespace Filter */ }; /* namespace Internal */ diff --git a/src/extension/internal/filter/snow.h b/src/extension/internal/filter/snow.h deleted file mode 100644 index 7a15f9efa..000000000 --- a/src/extension/internal/filter/snow.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ -/* Change the 'SNOW' above to be your file name */ - -/* - * Copyright (C) 2008 Authors: - * Ted Gould - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -namespace Inkscape { -namespace Extension { -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) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Snow crest") "\n" - "org.inkscape.effect.filter.snow\n" - "3.5\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Snow has fallen on object") "\n" - "\n" - "\n", new Snow()); - }; - -}; - -gchar const * -Snow::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream drift; - drift << ext->get_param_float("drift"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", drift.str().c_str()); - - return _filter; -}; - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'SNOW' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ */ diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h new file mode 100644 index 000000000..c47df89df --- /dev/null +++ b/src/extension/internal/filter/transparency.h @@ -0,0 +1,192 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ +/* Change the 'TRANSPARENCY' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Fill and transparency filters + * Channel transparency + * Silhouette + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Channel transparency filter. + + Channel transparency filter. + + Filter's parameters: + * Saturation (0.->1., default 1.) -> colormatrix1 (values) + * Red (-10.->10., default -1.) -> colormatrix2 (values) + * Green (-10.->10., default 0.5) -> colormatrix2 (values) + * Blue (-10.->10., default 0.5) -> colormatrix2 (values) + * Alpha (-10.->10., default 1.) -> colormatrix2 (values) + * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color) + * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out') + + Matrix: + 1 0 0 0 0 + 0 1 0 0 0 + 0 0 1 0 0 + R G B A 0 +*/ +class ChannelTransparency : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ChannelTransparency ( ) : Filter() { }; + virtual ~ChannelTransparency ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Channel transparency") "\n" + "org.inkscape.effect.filter.ChannelTransparency\n" + "-1\n" + "0.5\n" + "0.5\n" + "1\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Replace RGB with transparency") "\n" + "\n" + "\n", new ChannelTransparency()); + }; +}; + +gchar const * +ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + std::ostringstream alpha; + std::ostringstream invert; + + red << ext->get_param_float("red"); + green << ext->get_param_float("green"); + blue << ext->get_param_float("blue"); + alpha << ext->get_param_float("alpha"); + + if (!ext->get_param_bool("invert")) { + invert << "in"; + } else { + invert << "xor"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), + invert.str().c_str()); + + return _filter; +}; /* Channel transparency filter */ + +/** + \brief Custom predefined Silhouette filter. + + Repaint anything visible monochrome + + Filter's parameters: + * Blur (0.01->50., default 0.01) -> blur (stdDeviation) + * Cutout (boolean, default False) -> composite (false=in, true=out) + * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity) +*/ + +class Silhouette : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Silhouette ( ) : Filter() { }; + virtual ~Silhouette ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Silhouette") "\n" + "org.inkscape.effect.filter.Silhouette\n" + "0.01\n" + "false\n" + "255\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Repaint anything visible monochrome") "\n" + "\n" + "\n", new Silhouette()); + }; + +}; + +gchar const * +Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream a; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream cutout; + std::ostringstream blur; + + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + if (ext->get_param_bool("cutout")) + cutout << "out"; + else + cutout << "in"; + blur << ext->get_param_float("blur"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), cutout.str().c_str(), blur.str().c_str()); + + return _filter; +}; /* Silhouette filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'TRANSPARENCY' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ */ -- cgit v1.2.3