From: JazzyNico Date: Wed, 5 Jan 2011 19:48:47 +0000 (+0100) Subject: Filters. Custom predefined filters update and new ABC filters. X-Git-Url: https://git.tokkee.org/?p=inkscape.git;a=commitdiff_plain;h=c7cf14ac71346f76ae219ce67fb88c1bd34832e2 Filters. Custom predefined filters update and new ABC filters. --- diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h new file mode 100755 index 000000000..c93bbb7f7 --- /dev/null +++ b/src/extension/internal/filter/abc.h @@ -0,0 +1,324 @@ +#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ +#define __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 + * Blur + * Diffuse light + * Roughen + * 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 Blur filter. + + Simple horizontal and vertical blur. + + Filter's parameters: + * Horizontal blur (0.01->100., default 2) -> blur (stdDeviation) + * Vertical blur (0.01->100., default 2) -> blur (stdDeviation) +*/ + +class Blur : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Blur ( ) : Filter() { }; + virtual ~Blur ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Blur, custom (ABCs)") "\n" + "org.inkscape.effect.filter.blur\n" + "2\n" + "2\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Simple vertical and horizontal blur effect") "\n" + "\n" + "\n", new Blur()); + }; + +}; + +gchar const * +Blur::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream hblur; + std::ostringstream vblur; + + hblur << ext->get_param_float("hblur"); + vblur << ext->get_param_float("vblur"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", hblur.str().c_str(), vblur.str().c_str()); + + return _filter; +}; /* Blur 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) + * Lightning color (guint, default -1 [white]) -> diffuse (lighting-color) + + TODO: use the alpha channel to calculate the lightning 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 Roughen filter. + + Small-scale roughening to edges and content + + Filter's parameters: + * Frequency (*100) (0.0->40., default 1.3) -> turbulence (baseFrequency) + * 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" + "1.3\n" + "1.3\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 hfreq; + std::ostringstream vfreq; + std::ostringstream intensity; + + hfreq << (ext->get_param_float("hfreq") / 100); + vfreq << (ext->get_param_float("vfreq") / 100); + intensity << ext->get_param_float("intensity"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str()); + + return _filter; +}; /* Roughen 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 25) -> feDistantLight (elevation) + * Azimuth (0->360, default 235) -> feDistantLight (azimuth) + * Lightning color (guint, default -1 [white]) -> specular (lighting-color) + + TODO: use the alpha channel to calculate the lightning color (but do we really need a lightning color here?) +*/ + +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 'COLOR' below to be your file name */ +#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h old mode 100644 new mode 100755 index 54312685c..05173b684 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -54,7 +54,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Colorize, custom -EXP-") "\n" + "" N_("Colorize, custom (color)") "\n" "org.inkscape.effect.filter.Colorize\n" "0\n" "1\n" @@ -119,7 +119,7 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) duotone << "1"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -156,7 +156,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Duochrome, custom -EXP-") "\n" + "" N_("Duochrome, custom (color)") "\n" "org.inkscape.effect.filter.Duochrome\n" "\n" "\n" @@ -241,7 +241,7 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -282,7 +282,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Quadritone fantasy, custom -EXP-") "\n" + "" N_("Quadritone fantasy, custom (color)") "\n" "org.inkscape.effect.filter.Quadritone\n" "280\n" "100\n" @@ -331,7 +331,7 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) blend2 << ext->get_param_enum("blend2"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -369,7 +369,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Solarize, custom -EXP-") "\n" + "" N_("Solarize, custom (color)") "\n" "org.inkscape.effect.filter.Solarize\n" "0\n" "\n" @@ -412,7 +412,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -456,7 +456,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Tritone, custom -EXP-") "\n" + "" N_("Tritone, custom (color)") "\n" "org.inkscape.effect.filter.Tritone\n" "\n" "\n" @@ -565,7 +565,7 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h index 0cd2a8eeb..22890d39a 100644 --- a/src/extension/internal/filter/drop-shadow.h +++ b/src/extension/internal/filter/drop-shadow.h @@ -152,7 +152,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Drop shadow, color -EXP-") "\n" + "" N_("Drop shadow, color") "\n" "org.inkscape.effect.filter.colorizable-drop-shadow\n" "3.0\n" "6.0\n" @@ -196,7 +196,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) b << ((color >> 8) & 0xff); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h old mode 100644 new mode 100755 index a8879720b..acd258805 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -3,7 +3,7 @@ /* Change the 'EXPERIMENTAL' above to be your file name */ /* - * Copyright (C) 2010 Authors: + * Copyright (C) 2011 Authors: * Ivan Louette (filters) * Nicolas Dufour (UI) * @@ -11,7 +11,7 @@ * Chromolitho * Drawing * Posterize - * Test filter (should no be used...) + * Posterize basic * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -38,8 +38,7 @@ namespace Filter { * 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] - * Expand white (0->5, default 1) -> component1 (tableValues) [0="0 1", 5="0 1 1 1 1 1 1"] - * Lightness (0->10, default 0) -> composite1 (k1) + * 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) @@ -65,24 +64,24 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Chromolitho, custom -EXP-") "\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" - "<_item value=\"darken\">Darken\n" "\n" "false\n" "false\n" "false\n" - "0\n" + "0\n" "1\n" - "20\n" + "10\n" "1\n" "\n" "\n" @@ -149,7 +148,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) col3in << "colormatrix4"; else col3in << "component1"; - light << ext->get_param_int("light"); + 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"); @@ -180,8 +179,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) graincol << "0"; _filter = g_strdup_printf( - "\n" - + "\n" "\n" "\n" "\n" @@ -210,21 +208,24 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) Convert images to duochrome drawings. Filter's parameters: - * Simplification (0.01->10, default 0.7) -> blur1 (stdDeviation) - * Lightness (0->50, default 5) -> convolve (kernelMatrix, central value -1000->-1050, default -1005) - * Smoothness (0.01->10, default 0.7) -> blur2 (stdDeviation) - * Dilatation (3->100, default 6) -> colormatrix3 (n-1th value) - - * Blur (0.01->10., default 1.) -> blur3 (stdDeviation) - * Blur spread (3->20, default 6) -> colormatrix5 (n-1th value) - * Blur erosion (-2->0, default -2) -> colormatrix5 (nth value) - - * Stroke color (guint, default 205,0,0) -> flood2 (flood-opacity, flood-color) - * Image on stroke (boolean, default false) -> composite1 (in="flood2" true-> in="SourceGraphic") - * Image on stroke opacity (0.->1., default 1) -> composite3 (k3) - * Fill color (guint, default 255,203,0) -> flood3 (flood-opacity, flood-color) - * Image on fill (boolean, default false) -> composite2 (in="flood3" true-> in="SourceGraphic") - * Image on fill opacity (0.->1., default 1) -> composite3 (k2) + * Simplification (0.01->20, default 0.6) -> blur1 (stdDeviation) + * Lightness (1->500, default 10) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1010) + * Fading (0.->6., default 0) -> composite1 (k4) + * Smoothness (0.01->20, default 0.6) -> blur2 (stdDeviation) + * Dilatation (1->50, default 6) -> color2 (n-1th value) + * Erosion (0->50, default 3) -> color2 (nth value 0->-50) + * Transluscent (boolean, default false) -> composite 8 (in, true->merge1, false->composite7) + * Offset (-100->100, default 0) -> offset (val) + + * Blur (0.01->20., default 1.) -> blur3 (stdDeviation) + * Blur spread (1->50, default 6) -> color4 (n-1th value) + * Blur erosion (0->50, default 3) -> 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") + * 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 { @@ -238,28 +239,30 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Drawing, custom -EXP-") "\n" + "" N_("Drawing, custom") "\n" "org.inkscape.effect.filter.Drawing\n" "\n" "\n" - "0.7\n" - "5\n" - "0.7\n" - "6\n" + "0.6\n" + "10\n" + "0\n" + "0.6\n" + "6\n" + "3\n" + "false\n" "<_param name=\"blurheader\" type=\"groupheader\">Blur\n" - "1\n" - "6\n" - "-2\n" + "1\n" + "6\n" + "3\n" "\n" "\n" - "-3473153\n" + "-1515870721\n" "false\n" - "1\n" "\n" "\n" - "-855637761\n" + "589505535\n" "false\n" - "1\n" + "0\n" "\n" "\n" "\n" @@ -282,32 +285,41 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream simply; std::ostringstream light; + std::ostringstream fade; std::ostringstream smooth; std::ostringstream dilat; - std::ostringstream blur; - std::ostringstream spread; std::ostringstream erosion; + std::ostringstream transluscent; + 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 ioso; std::ostringstream filla; std::ostringstream fillr; std::ostringstream fillg; std::ostringstream fillb; std::ostringstream iof; - std::ostringstream iofo; simply << ext->get_param_float("simply"); light << (-1000 - ext->get_param_int("light")); + fade << (ext->get_param_float("fade") / 10); smooth << ext->get_param_float("smooth"); - dilat << ext->get_param_int("dilat"); - + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + if (ext->get_param_bool("transluscent")) + transluscent << "merge1"; + else + transluscent << "composite7"; + offset << ext->get_param_int("offset"); + blur << ext->get_param_float("blur"); - spread << ext->get_param_int("spread"); - erosion << ext->get_param_int("erosion"); + bdilat << ext->get_param_float("bdilat"); + berosion << (- ext->get_param_float("berosion")); guint32 fcolor = ext->get_param_color("fcolor"); fillr << ((fcolor >> 24) & 0xff); @@ -318,7 +330,6 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) iof << "SourceGraphic"; else iof << "flood3"; - iofo << ext->get_param_float("iofo"); guint32 scolor = ext->get_param_color("scolor"); stroker << ((scolor >> 24) & 0xff); @@ -329,34 +340,40 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) ios << "SourceGraphic"; else ios << "flood2"; - ioso << ext->get_param_float("ioso"); - + _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" - "\n" - "\n" - "\n" - "\n", simply.str().c_str(), light.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), blur.str().c_str(), spread.str().c_str(), erosion.str().c_str(), strokea.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), filla.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), iofo.str().c_str(), ioso.str().c_str()); + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", simply.str().c_str(), light.str().c_str(), fade.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(), transluscent.str().c_str()); return _filter; }; /* Drawing filter */ @@ -384,7 +401,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Poster and painting, custom -EXP-") "\n" + "" N_("Poster and painting, custom") "\n" "org.inkscape.effect.filter.Posterize\n" "\n" "<_item value=\"normal\">Normal\n" @@ -400,8 +417,8 @@ public: "<_item value=\"normal\">Normal\n" "<_item value=\"darken\">Darken\n" "\n" - "4.0\n" - "0.5\n" + "4.0\n" + "0.5\n" "1.00\n" "1.00\n" "false\n" @@ -434,8 +451,8 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) table << ext->get_param_enum("table"); blendmode << ext->get_param_enum("blend"); - blur1 << ext->get_param_float("blur1") + 0.01; - blur2 << ext->get_param_float("blur2") + 0.01; + blur1 << ext->get_param_float("blur1"); + blur2 << ext->get_param_float("blur2"); presat << ext->get_param_float("presaturation"); postsat << ext->get_param_float("postsaturation"); @@ -459,7 +476,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) antialias << "0.01"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -478,21 +495,30 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Posterize filter */ +/** + \brief Custom predefined PosterizeBasic filter. + + Simple posterizing effect -class TestFilter : public Inkscape::Extension::Internal::Filter::Filter { + Filter's parameters: + * Levels (1->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: - TestFilter ( ) : Filter() { }; - virtual ~TestFilter ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + PosterizeBasic ( ) : Filter() { }; + virtual ~PosterizeBasic ( ) { if (_filter != NULL) g_free((void *)_filter); return; } static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Test Filter -EXP-") "\n" - "org.inkscape.effect.filter.TestFilter\n" - "<_param name=\"header1\" type=\"groupheader\">Test filter\n" + "" N_("Posterize basic, custom") "\n" + "org.inkscape.effect.filter.PosterizeBasic\n" + "5\n" + "4.0\n" "\n" "all\n" "\n" @@ -500,36 +526,44 @@ public: "\n" "\n" "\n" - "" N_("Change colors to a two colors palette") "\n" + "" N_("Simple posterizing effect") "\n" "\n" - "\n", new TestFilter()); + "\n", new PosterizeBasic()); }; }; gchar const * -TestFilter::get_filter_text (Inkscape::Extension::Extension * ext) +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" - "\n" + "\n" + "\n" + "\n" + "\n" + "\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; -}; /* Test filter */ +}; /* PosterizeBasic filter */ }; /* namespace Filter */ }; /* namespace Internal */ diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp old mode 100644 new mode 100755 index 06b942a1f..846725472 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -8,6 +8,7 @@ #include "filter.h" /* Put your filter here */ +#include "abc.h" #include "color.h" #include "drop-shadow.h" #include "morphology.h" @@ -30,7 +31,13 @@ Filter::filters_all (void ) Snow::init(); /* Experimental custom predefined filters */ - + + // ABCs + Blur::init(); + DiffuseLight::init(); + Roughen::init(); + SpecularLight::init(); + // Color Colorize::init(); Duochrome::init(); @@ -40,7 +47,7 @@ Filter::filters_all (void ) // Morphology Crosssmooth::init(); - + // Shadows and glows ColorizableDropShadow::init(); @@ -48,6 +55,7 @@ Filter::filters_all (void ) Chromolitho::init(); Drawing::init(); Posterize::init(); + PosterizeBasic::init(); // Here come the rest of the filters that are read from SVG files in share/filters and // .config/Inkscape/filters diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 93d44d6fa..8e00b47be 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -48,8 +48,8 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Cross-smooth, custom -EXP-") "\n" - "org.inkscape.effect.filter.Crosssmooth\n" + "" N_("Cross-smooth, custom (morphology)") "\n" + "org.inkscape.effect.filter.crosssmooth\n" "\n" "<_item value=\"edges\">Smooth edges\n" "<_item value=\"all\">Smooth all\n" @@ -87,7 +87,7 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n"