From 74989927846c114eda06120fcc13ff3bd55fde6e Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 10 Aug 2011 21:45:15 +0200 Subject: Filters. Forgotten textures file... (bzr r10535) --- src/extension/internal/filter/textures.h | 158 +++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 src/extension/internal/filter/textures.h (limited to 'src') diff --git a/src/extension/internal/filter/textures.h b/src/extension/internal/filter/textures.h new file mode 100644 index 000000000..17fccfcbc --- /dev/null +++ b/src/extension/internal/filter/textures.h @@ -0,0 +1,158 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TEXTURES_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TEXTURES_H__ +/* Change the 'TEXTURES' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Protrusion filters + * Ink blot + * + * 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 Ink Blot filter. + + Inkblot on tissue or rough paper. + + Filter's parameters: + + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Frequency (0.001->1., default 0.04) -> turbulence (baseFrequency) + * Complexity (1->5, default 3) -> turbulence (numOctaves) + * Variation (0->100, default 0) -> turbulence (seed) + * Horizontal inlay (0.01->30., default 10) -> blur1 (stdDeviation x) + * Vertical inlay (0.01->30., default 10) -> blur1 (stdDeviation y) + * Displacement (0.->100., default 50) -> map (scale) + * Blend (0.01->30., default 5) -> blur2 (stdDeviation) + * Stroke (enum, default over) -> composite (operator) + * Arithmetic stroke options + * k1 (-10.->10., default 1.5) + * k2 (-10.->10., default -0.25) + * k3 (-10.->10., default 0.5) +*/ +class InkBlot : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + InkBlot ( ) : Filter() { }; + virtual ~InkBlot ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + +public: + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Ink Blot") "\n" + "org.inkscape.effect.filter.InkBlot\n" + "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" + "\n" + "0.04\n" + "3\n" + "0\n" + "10\n" + "10\n" + "50\n" + "5\n" + "\n" + "<_item value=\"over\">Wide\n" + "<_item value=\"atop\">Normal\n" + "<_item value=\"in\">Narrow\n" + "<_item value=\"xor\">Overlapping\n" + "<_item value=\"out\">External\n" + "<_item value=\"arithmetic\">Custom\n" + "\n" + "<_param name=\"customHeader\" type=\"description\" appearance=\"header\">" N_("Custom stroke options") "\n" + "1.5\n" + "-0.25\n" + "0.5\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Inkblot on tissue or rough paper") "\n" + "\n" + "\n", new InkBlot()); + }; + +}; + +gchar const * +InkBlot::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + std::ostringstream freq; + std::ostringstream complexity; + std::ostringstream variation; + std::ostringstream hblur; + std::ostringstream vblur; + std::ostringstream displacement; + std::ostringstream blend; + std::ostringstream stroke; + std::ostringstream custom; + + type << ext->get_param_enum("type"); + freq << ext->get_param_float("freq"); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + hblur << ext->get_param_float("hblur"); + vblur << ext->get_param_float("vblur"); + displacement << ext->get_param_float("displacement"); + blend << ext->get_param_float("blend"); + + const gchar *ope = ext->get_param_enum("stroke"); + if (g_ascii_strcasecmp("arithmetic", ope) == 0) { + custom << "k1=\"" << ext->get_param_float("k1") << "\" k2=\"" << ext->get_param_float("k2") << "\" k3=\"" << ext->get_param_float("k3") << "\""; + } else { + custom << ""; + } + + stroke << ext->get_param_enum("stroke"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", hblur.str().c_str(), vblur.str().c_str(), type.str().c_str(), + freq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), + displacement.str().c_str(), blend.str().c_str(), + custom.str().c_str(), stroke.str().c_str() ); + + return _filter; + +}; /* Ink Blot filter */ + + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'TEXTURES' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TEXTURES_H__ */ -- cgit v1.2.3