// SPDX-License-Identifier: GPL-2.0-or-later #ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ #define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ /* Change the 'BEVELS' above to be your file name */ /* * Copyright (C) 2011 Authors: * Ivan Louette (filters) * Nicolas Dufour (UI) * * Bevel filters * Diffuse light * Matte jelly * Specular light * * 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 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: gchar const * get_filter_text (Inkscape::Extension::Extension * ext) override; public: DiffuseLight ( ) : Filter() { }; ~DiffuseLight ( ) override { if (_filter != nullptr) g_free((void *)_filter); return; } static void init () { // clang-format off 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()); // clang-format on }; }; gchar const * DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != nullptr) 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: gchar const * get_filter_text (Inkscape::Extension::Extension * ext) override; public: MatteJelly ( ) : Filter() { }; ~MatteJelly ( ) override { if (_filter != nullptr) g_free((void *)_filter); return; } static void init () { // clang-format off 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()); // clang-format on }; }; gchar const * MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != nullptr) 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: gchar const * get_filter_text (Inkscape::Extension::Extension * ext) override; public: SpecularLight ( ) : Filter() { }; ~SpecularLight ( ) override { if (_filter != nullptr) g_free((void *)_filter); return; } static void init () { // clang-format off 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()); // clang-format on }; }; gchar const * SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != nullptr) 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 'BEVELS' below to be your file name */ #endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ */