From: JazzyNico Date: Fri, 26 Nov 2010 14:09:40 +0000 (+0100) Subject: Filters. New custom predefined cross-smooth filter (very experimental...). X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a13531703adeeb1b8b4b9beca2499a51e37b36ad;p=inkscape.git Filters. New custom predefined cross-smooth filter (very experimental...). --- diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index be055463c..d9720b05c 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -22,11 +22,14 @@ namespace Extension { namespace Internal { namespace Filter { -/* Custom predefined Colorize filter +/** + \brief Custom predefined Colorize filter. + + Blend image or object with a flood color. -Filter's parameters: - * Harsh light (0.-10., default 0) -> composite1 (k1) - * Normal light (0.-10., default 1) -> composite2 (k2) + Filter's parameters: + * Harsh light (0.->10., default 0) -> composite1 (k1) + * Normal light (0.->10., default 1) -> composite2 (k2) * Duotone (boolean, default false) -> colormatrix1 (values="0") * Filtered greys (boolean, default false) -> colormatrix2 (values="0") * Blend mode 1 (enum, default Multiply) -> blend1 (mode) @@ -129,10 +132,13 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Colorize filter */ -/* Custom predefined Duochrome filter +/** + \brief Custom predefined Duochrome filter. + + Convert luminance values to a duochrome palette. -Filter's parameters: - * Fluorescence level (0.-2., default 0) -> composite4 (k2) + Filter's parameters: + * Fluorescence level (0.->2., default 0) -> composite4 (k2) * Swap (enum, default "No swap") -> composite1, composite2 (operator) * Color 1 (guint, default 1364325887) -> flood1 (flood-opacity, flood-color) * Color 2 (guint, default -65281) -> flood2 (flood-opacity, flood-color) @@ -245,13 +251,16 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Duochrome filter */ -/* Custom predefined Quadritone filter +/** + \brief Custom predefined Quadritone filter. + + Replace hue by two colors. -Filter's parameters: - * Hue distribution (0-360, default 280) -> colormatrix1 (values) - * Colors (0-360, default 100) -> colormatrix3 (values) + Filter's parameters: + * Hue distribution (0->360, default 280) -> colormatrix1 (values) + * Colors (0->360, default 100) -> colormatrix3 (values) * Blend mode 1 (enum, default Normal) -> blend1 (mode) - * Over-saturation (0.-1., default 0) -> composite1 (k2) + * Over-saturation (0.->1., default 0) -> composite1 (k2) * Blend mode 2 (enum, default Normal) -> blend2 (mode) */ @@ -329,15 +338,19 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Quadritone filter */ -/* Custom predefined Solarize filter +/** + \brief Custom predefined Solarize filter. + + Classic photographic solarization effect. -Filter's parameters: + Filter's parameters: * Type (enum, default "Solarize") -> Solarize = blend1 (mode="darken"), blend2 (mode="screen") Moonarize = blend1 (mode="lighten"), blend2 (mode="multiply") [No other access to the blend modes] - * Hue rotation (0-360, default 0) -> colormatrix1 (values) + * Hue rotation (0->360, default 0) -> colormatrix1 (values) */ + class Solarize : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); @@ -405,21 +418,24 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Solarize filter */ -/* Custom predefined Tritone filter +/** + \brief Custom predefined Tritone filter. + + Create a custom tritone palette with additional glow, blend modes and hue moving. -Filter's parameters: + Filter's parameters: * Option (enum, default Normal) -> Normal = composite1 (in="qminp", in2="flood"), composite2 (in="p", in2="blend6"), blend6 (in2="qminpc") Enhance hue = Normal + composite2 (in="SourceGraphic") Radiation = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="qminpc") Hue to background = Normal + composite1 (in2="BackgroundImage") [a template with an activated background is needed, or colors become black] - * Hue distribution (0-360, default 0) -> colormatrix1 (values) + * Hue distribution (0->360, default 0) -> colormatrix1 (values) * Colors (guint, default -73203457) -> flood (flood-opacity, flood-color) * Global blend (enum, default Lighten) -> blend5 (mode) [Multiply, Screen, Darken, Lighten only!] - * Glow (0.01-10., default 0.01) -> feGaussianBlur (stdDeviation) + * Glow (0.01->10., default 0.01) -> feGaussianBlur (stdDeviation) * Glow & blend (enum, default Normal) -> blend6 (mode) [Normal, Multiply and Darken only!] - * Local light (0.-10., default 0) -> composite2 (k1) - * Global light (0.-10., default 1) -> composite2 (k3) [k2 must be fixed to 1]. + * Local light (0.->10., default 0) -> composite2 (k1) + * Global light (0.->10., default 1) -> composite2 (k3) [k2 must be fixed to 1]. */ class Tritone : public Inkscape::Extension::Internal::Filter::Filter { diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 38f54e7df..80fa7c69e 100644 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -10,7 +10,9 @@ /* Put your filter here */ #include "color.h" #include "drop-shadow.h" +#include "morphology.h" #include "snow.h" + #include "experimental.h" namespace Inkscape { @@ -26,17 +28,22 @@ Filter::filters_all (void ) DropShadow::init(); DropGlow::init(); Snow::init(); + + /* Experimental custom predefined filters */ - // Experimental // Color Colorize::init(); Duochrome::init(); Quadritone::init(); Solarize::init(); Tritone::init(); + + // Morphology + Crosssmooth::init(); // Shadows and glows ColorizableDropShadow::init(); + // TDB Posterize::init(); diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h new file mode 100644 index 000000000..61fb8d42b --- /dev/null +++ b/src/extension/internal/filter/morphology.h @@ -0,0 +1,110 @@ +#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ +#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ +/* Change the 'MORPHOLOGY' above to be your file name */ + +/* + * Copyright (C) 2010 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * 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 Crosssmooth filter. + + Smooth the outside of shapes and pictures. + + Filter's parameters: + * Type (enum, default "Smooth all") -> + Smooth all = composite (in="colormatrix", in2="colormatrix") + Smooth edges = composite (in="SourceGraphic", in2="colormatrix") + * Blur (0.01->10., default 5.) -> blur (stdDeviation) + * Spreading (1->100, default 20) -> colormatrix (value n-1) + * Erosion (0->-100, default -15) -> colormatrix (value n) +*/ + +class Crosssmooth : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Crosssmooth ( ) : Filter() { }; + virtual ~Crosssmooth ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Cross-smooth, custom -EXP-") "\n" + "org.inkscape.effect.filter.Crosssmooth\n" + "\n" + "<_item value=\"all\">Smooth all\n" + "<_item value=\"edges\">Smooth edges\n" + "\n" + "5\n" + "20\n" + "-15\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Smooth the outside of shapes and pictures without altering their contents") "\n" + "\n" + "\n", new Crosssmooth()); + }; + +}; + +gchar const * +Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + std::ostringstream spreading; + std::ostringstream erosion; + std::ostringstream cin; + + blur << ext->get_param_float("blur"); + spreading << ext->get_param_int("spreading"); + erosion << ext->get_param_int("erosion"); + + const gchar *type = ext->get_param_enum("type"); + if((g_ascii_strcasecmp("all", type) == 0)) { + cin << "colormatrix"; + } else { + cin << "SourceGraphic"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n", blur.str().c_str(), spreading.str().c_str(), erosion.str().c_str(), cin.str().c_str()); + + return _filter; +}; /* Crosssmooth filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'COLOR' below to be your file name */ +#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ */