From a14d33de8c9e17477a13a7e76c9eb1fbe490f011 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 17 Aug 2011 18:19:16 +0200 Subject: Filters. New Opacity CPF, Blur and Tritone improvements. (bzr r10548) --- src/extension/internal/filter/blurs.h | 19 ++++- src/extension/internal/filter/color.h | 100 +++++++++++++++------------ src/extension/internal/filter/filter-all.cpp | 1 + src/extension/internal/filter/paint.h | 32 ++++----- src/extension/internal/filter/transparency.h | 88 +++++++++++++++++++---- 5 files changed, 165 insertions(+), 75 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index b8a6d7c4c..1854572ff 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -37,6 +37,7 @@ namespace Filter { Filter's parameters: * Horizontal blur (0.01->100., default 2) -> blur (stdDeviation) * Vertical blur (0.01->100., default 2) -> blur (stdDeviation) + * Blur content only (boolean, default false) -> */ class Blur : public Inkscape::Extension::Internal::Filter::Filter { @@ -54,6 +55,7 @@ public: "org.inkscape.effect.filter.Blur\n" "2\n" "2\n" + "False\n" "\n" "all\n" "\n" @@ -73,16 +75,29 @@ Blur::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); + std::ostringstream bbox; std::ostringstream hblur; std::ostringstream vblur; + std::ostringstream content; hblur << ext->get_param_float("hblur"); vblur << ext->get_param_float("vblur"); + if (ext->get_param_bool("content")) { + bbox << "height=\"1\" width=\"1\" y=\"0\" x=\"0\""; + content << "\n" + << "\n"; + } else { + bbox << "" ; + content << "" ; + } + + _filter = g_strdup_printf( - "\n" + "\n" "\n" - "\n", hblur.str().c_str(), vblur.str().c_str()); + "%s" + "\n", bbox.str().c_str(), hblur.str().c_str(), vblur.str().c_str(), content.str().c_str() ); return _filter; }; /* Blur filter */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 343a5eb84..9ba03a3d6 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -108,9 +108,9 @@ Brilliance::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n", brightness.str().c_str(), sat.str().c_str(), sat.str().c_str(), - lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), - sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), - sat.str().c_str(), brightness.str().c_str(), lightness.str().c_str()); + lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), + sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), + sat.str().c_str(), brightness.str().c_str(), lightness.str().c_str() ); return _filter; }; /* Brilliance filter */ @@ -222,7 +222,7 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) "\n", saturation.str().c_str(), red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), floodRed.str().c_str(), floodGreen.str().c_str(), floodBlue.str().c_str(), floodAlpha.str().c_str(), - invert.str().c_str()); + invert.str().c_str() ); return _filter; }; /* Channel Painting filter */ @@ -281,7 +281,7 @@ ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", shift.str().c_str(), sat.str().c_str()); + "\n", shift.str().c_str(), sat.str().c_str() ); return _filter; }; /* ColorShift filter */ @@ -391,7 +391,9 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", hlight.str().c_str(), nlight.str().c_str(), duotone.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), blend1.str().c_str(), blend2.str().c_str()); + "\n", hlight.str().c_str(), nlight.str().c_str(), duotone.str().c_str(), + a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + blend1.str().c_str(), blend2.str().c_str() ); return _filter; }; /* Colorize filter */ @@ -597,7 +599,9 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), fluo.str().c_str()); + "\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(), + a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), + fluo.str().c_str() ); return _filter; }; /* Duochrome filter */ @@ -791,7 +795,7 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" "\n" - "\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str()); + "\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str() ); return _filter; }; /* Greyscale filter */ @@ -994,8 +998,8 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n", amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str(), - amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str(), - amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str()); + amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str(), + amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str() ); return _filter; }; /* Lightness filter */ @@ -1137,7 +1141,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) rx.str().c_str(), ry.str().c_str(), source.str().c_str(), blend.str().c_str(), gx.str().c_str(), gy.str().c_str(), blend.str().c_str(), bx.str().c_str(), by.str().c_str(), blend.str().c_str(), - composite.str().c_str()); + composite.str().c_str() ); return _filter; @@ -1224,7 +1228,7 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", dist.str().c_str(), colors.str().c_str(), blend1.str().c_str(), sat.str().c_str(), blend2.str().c_str()); + "\n", dist.str().c_str(), colors.str().c_str(), blend1.str().c_str(), sat.str().c_str(), blend2.str().c_str() ); return _filter; }; /* Quadritone filter */ @@ -1303,7 +1307,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", rotate.str().c_str(), blend1.str().c_str(), blend2.str().c_str()); + "\n", rotate.str().c_str(), blend1.str().c_str(), blend2.str().c_str() ); return _filter; }; /* Solarize filter */ @@ -1315,14 +1319,15 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) Filter's parameters: * Option (enum, default Normal) -> - Normal = composite1 (in="qminp", in2="flood"), composite2 (in="p", in2="blend6"), blend6 (in2="qminpc") + Normal = composite1 (in2="flood"), composite2 (in="p", in2="blend6"), blend6 (in2="composite1") Enhance hue = Normal + composite2 (in="SourceGraphic") - Phosphorescence = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="qminpc") + Phosphorescence = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="composite1") + PhosphorescenceB = Normal + blend6 (in2="flood") composite1 (in2="SourceGraphic") 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) * 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) -> blur (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]. @@ -1346,7 +1351,8 @@ public: "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"enhue\">" N_("Enhance hue") "\n" - "<_item value=\"rad\">" N_("Phosphorescence") "\n" + "<_item value=\"phospho\">" N_("Phosphorescence") "\n" + "<_item value=\"phosphoB\">" N_("Phosphorescence B") "\n" "<_item value=\"htb\">" N_("Hue to background") "\n" "\n" "\n" @@ -1398,7 +1404,6 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream glowblend; std::ostringstream llight; std::ostringstream glight; - std::ostringstream c1in; std::ostringstream c1in2; std::ostringstream c2in; std::ostringstream c2in2; @@ -1419,56 +1424,61 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) const gchar *type = ext->get_param_enum("type"); if ((g_ascii_strcasecmp("enhue", type) == 0)) { // Enhance hue - c1in << "qminp"; c1in2 << "flood"; c2in << "SourceGraphic"; c2in2 << "blend6"; - b6in2 << "qminpc"; - } else if ((g_ascii_strcasecmp("rad", type) == 0)) { + b6in2 << "composite1"; + } else if ((g_ascii_strcasecmp("phospho", type) == 0)) { // Phosphorescence - c1in << "qminp"; c1in2 << "flood"; c2in << "blend6"; - c2in2 << "qminpc"; + c2in2 << "composite1"; b6in2 << "SourceGraphic"; + } else if ((g_ascii_strcasecmp("phosphoB", type) == 0)) { + // Phosphorescence B + c1in2 << "SourceGraphic"; + c2in << "blend6"; + c2in2 << "composite1"; + b6in2 << "flood"; } else if ((g_ascii_strcasecmp("htb", type) == 0)) { // Hue to background - c1in << "qminp"; c1in2 << "BackgroundImage"; - c2in << "p"; + c2in << "blend2"; c2in2 << "blend6"; - b6in2 << "qminpc"; + b6in2 << "composite1"; } else { // Normal - c1in << "qminp"; c1in2 << "flood"; - c2in << "p"; + c2in << "blend2"; c2in2 << "blend6"; - b6in2 << "qminpc"; + b6in2 << "composite"; } _filter = g_strdup_printf( "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" "\n" "\n" - "\n" - "\n" + "\n" + "\n" "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" "\n" - "\n" - "\n", dist.str().c_str(), globalblend.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), c1in.str().c_str(), c1in2.str().c_str(), glow.str().c_str(), b6in2.str().c_str(), glowblend.str().c_str(), c2in.str().c_str(), c2in2.str().c_str(), llight.str().c_str(), glight.str().c_str()); + "\n" + "\n", dist.str().c_str(), globalblend.str().c_str(), + a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + c1in2.str().c_str(), glow.str().c_str(), b6in2.str().c_str(), glowblend.str().c_str(), + c2in.str().c_str(), c2in2.str().c_str(), llight.str().c_str(), glight.str().c_str() ); return _filter; }; /* Tritone filter */ diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 092edff18..c145dd717 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -101,6 +101,7 @@ Filter::filters_all (void ) Blend::init(); ChannelTransparency::init(); LightEraser::init(); + Opacity::init(); Silhouette::init(); // Here come the rest of the filters that are read from SVG files in share/filters and diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index 0546b672f..b22eeb889 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -678,9 +678,9 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) * Erase (0.00->1., default 0) -> composite1 (k4) * Blur (0.01->2., default 0.5) -> blur (stdDeviation) - * Drawing color (guint32, default rgb(73,69,40)) -> flood1 (flood-color, flood-opacity) + * Drawing color (guint32, default rgb(255,255,255)) -> flood1 (flood-color, flood-opacity) - * Background color (guint32, default rgb(255,255,255)) -> flood2 (flood-color, flood-opacity) + * Background color (guint32, default rgb(99,89,46)) -> flood2 (flood-color, flood-opacity) */ class PointEngraving : public Inkscape::Extension::Internal::Filter::Filter { @@ -719,12 +719,12 @@ public: "0\n" "0.5\n" "\n" - "\n" - "1229269247\n" + "\n" + "-1\n" "false\n" "\n" - "\n" - "-16843009\n" + "\n" + "1666789119\n" "false\n" "\n" "\n" @@ -781,17 +781,17 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) erase << ext->get_param_float("erase"); blur << ext->get_param_float("blur"); - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; + guint32 fcolor = ext->get_param_color("fcolor"); + r << ((fcolor >> 24) & 0xff); + g << ((fcolor >> 16) & 0xff); + b << ((fcolor >> 8) & 0xff); + a << (fcolor & 0xff) / 255.0F; - guint32 bgcolor = ext->get_param_color("bgcolor"); - br << ((bgcolor >> 24) & 0xff); - bg << ((bgcolor >> 16) & 0xff); - bb << ((bgcolor >> 8) & 0xff); - ba << (bgcolor & 0xff) / 255.0F; + guint32 pcolor = ext->get_param_color("pcolor"); + br << ((pcolor >> 24) & 0xff); + bg << ((pcolor >> 16) & 0xff); + bb << ((pcolor >> 8) & 0xff); + ba << (pcolor & 0xff) / 255.0F; if (ext->get_param_bool("iof")) iof << "SourceGraphic"; diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 48322ae43..696c65b48 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -11,6 +11,7 @@ * Blend * Channel transparency * Light eraser + * Opacity * Silhouette * * Released under GNU GPL, read the file 'COPYING' for more information @@ -184,8 +185,8 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) Make the lightest parts of the object progressively transparent. Filter's parameters: - * Expand (1->1000, default 250) -> colormatrix (first 3 values, multiplicator) - * Erode (0->1000, default 75) -> colormatrix (4th value, multiplicator) + * Expansion (1.->1000., default 100) -> colormatrix (first 3 values, multiplicator) + * Erosion (0.->1000., default 50) -> colormatrix (4th value, multiplicator) * Global opacity (0.->1., default 1.) -> composite (k2) * Inverted (boolean, default false) -> colormatrix (values, true: first 3 values positive, 4th negative) @@ -203,8 +204,8 @@ public: "\n" "" N_("Light Eraser") "\n" "org.inkscape.effect.filter.LightEraser\n" - "100\n" - "50\n" + "100\n" + "50\n" "1\n" "false\n" "\n" @@ -232,15 +233,15 @@ LightEraser::get_filter_text (Inkscape::Extension::Extension * ext) opacity << ext->get_param_float("opacity"); if (ext->get_param_bool("invert")) { - expand << (ext->get_param_int("expand") * 0.2125) << " " - << (ext->get_param_int("expand") * 0.7154) << " " - << (ext->get_param_int("expand") * 0.0721); - erode << (-ext->get_param_int("erode") * 720 / 1000); + expand << (ext->get_param_float("expand") * 0.2125) << " " + << (ext->get_param_float("expand") * 0.7154) << " " + << (ext->get_param_float("expand") * 0.0721); + erode << (-ext->get_param_float("erode") * 720 / 1000); } else { - expand << (-ext->get_param_int("expand") * 0.2125) << " " - << (-ext->get_param_int("expand") * 0.7154) << " " - << (-ext->get_param_int("expand") * 0.0721); - erode << (ext->get_param_int("erode") * 720 / 1000); + expand << (-ext->get_param_float("expand") * 0.2125) << " " + << (-ext->get_param_float("expand") * 0.7154) << " " + << (-ext->get_param_float("expand") * 0.0721); + erode << (ext->get_param_float("erode") * 720 / 1000); } _filter = g_strdup_printf( @@ -252,6 +253,69 @@ LightEraser::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Light Eraser filter */ + +/** + \brief Custom predefined Opacity filter. + + Set opacity and strength of opacity boundaries. + + Filter's parameters: + * Expansion (0.->1000., default 5) -> colormatrix (last-1th value) + * Erosion (0.->1000., default 1) -> colormatrix (last value) + * Global opacity (0.->1., default 1.) -> composite (k2) + +*/ +class Opacity : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Opacity ( ) : Filter() { }; + virtual ~Opacity ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Opacity") "\n" + "org.inkscape.effect.filter.Opacity\n" + "5\n" + "1\n" + "1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Set opacity and strength of opacity boundaries") "\n" + "\n" + "\n", new Opacity()); + }; +}; + +gchar const * +Opacity::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream matrix; + std::ostringstream opacity; + + opacity << ext->get_param_float("opacity"); + + matrix << (ext->get_param_float("expand")) << " " + << (-ext->get_param_float("erode")); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", matrix.str().c_str(), opacity.str().c_str()); + + return _filter; +}; /* Opacity filter */ + /** \brief Custom predefined Silhouette filter. -- cgit v1.2.3