// SPDX-License-Identifier: GPL-2.0-or-later #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 v2+, 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 [/100]) * 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: gchar const * get_filter_text (Inkscape::Extension::Extension * ext) override; public: InkBlot ( ) : Filter() { }; ~InkBlot ( ) override { if (_filter != nullptr) g_free((void *)_filter); return; } public: static void init () { // clang-format off Inkscape::Extension::build_from_mem( "\n" "" N_("Ink Blot") "\n" "org.inkscape.effect.filter.InkBlot\n" "\n" "\n" "\n" "\n" "4\n" "3\n" "0\n" "10\n" "10\n" "50\n" "5\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\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()); // clang-format on }; }; gchar const * InkBlot::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != nullptr) 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_optiongroup("type"); freq << ext->get_param_float("freq") / 100; 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_optiongroup("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_optiongroup("stroke"); // clang-format off _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() ); // clang-format on 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__ */