// SPDX-License-Identifier: GPL-2.0-or-later #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 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 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: gchar const * get_filter_text (Inkscape::Extension::Extension * ext) override; public: NoiseFill ( ) : Filter() { }; ~NoiseFill ( ) override { if (_filter != nullptr) g_free((void *)_filter); return; } static void init () { // clang-format off Inkscape::Extension::build_from_mem( "\n" "" N_("Noise Fill") "\n" "org.inkscape.effect.filter.NoiseFill\n" "\n" "\n" "\n" "\n" "\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()); // clang-format on }; }; gchar const * NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != nullptr) 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_optiongroup("type"); hfreq << (ext->get_param_float("hfreq")); vfreq << (ext->get_param_float("vfreq")); 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__ */