From b6e4da66f2c664ac3b3fdf80284b63070f6f143a Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 11 Mar 2011 13:11:19 +0100 Subject: Filters. New Grayscale, Lightness and Brightness CPF. Some default values adjustment. Inkscape.pot update. (bzr r10090) --- src/extension/internal/filter/color.h | 229 +++++++++++++++++++++++++++ src/extension/internal/filter/experimental.h | 62 ++++---- src/extension/internal/filter/filter-all.cpp | 3 + 3 files changed, 263 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index fcae5f8c3..cdf8ffe90 100755 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -8,9 +8,12 @@ * Nicolas Dufour (UI) * * Color filters + * Brightness * Colorize * Duochrome * Electrize + * Greyscale + * Lightness * Quadritone * Solarize * Tritone @@ -30,6 +33,75 @@ namespace Extension { namespace Internal { namespace Filter { +/** + \brief Custom predefined Brightness filter. + + Brightness filter. + + Filter's parameters: + * Strength (-10.->10., default 10) -> colorMatrix (RVB entries [/10]) + * Vibration (-10.->10., default 0.) -> colorMatrix (6 other entries [/10]) + * Lightness (-10.->10., default 0.) -> colorMatrix (last column [/10]) + + Matrix: + St Vi Vi 0 Li + Vi St Vi 0 Li + Vi Vi St 0 Li + 0 0 0 1 0 +*/ +class Brightness : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Brightness ( ) : Filter() { }; + virtual ~Brightness ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Brightness, custom (Color)") "\n" + "org.inkscape.effect.filter.Brightness\n" + "10\n" + "0\n" + "0\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Brightness filter") "\n" + "\n" + "\n", new Brightness()); + }; +}; + +gchar const * +Brightness::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream strength; + std::ostringstream vibration; + std::ostringstream lightness; + + strength << (ext->get_param_float("strength") / 10); + vibration << (ext->get_param_float("vibration") / 10); + lightness << (ext->get_param_float("lightness") / 10); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", strength.str().c_str(), vibration.str().c_str(), vibration.str().c_str(), + lightness.str().c_str(), vibration.str().c_str(), strength.str().c_str(), + vibration.str().c_str(), lightness.str().c_str(), vibration.str().c_str(), + vibration.str().c_str(), strength.str().c_str(), lightness.str().c_str()); + + return _filter; +}; /* Brightness filter */ + /** \brief Custom predefined Colorize filter. @@ -349,6 +421,163 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Electrize filter */ +/** + \brief Custom predefined Greyscale filter. + + Customize greyscale components. + + Filter's parameters: + * Red (-100.->100., default 2.1) -> colorMatrix (values [/10]) + * Green (-100.->100., default 7.2) -> colorMatrix (values [/10]) + * Blue (-100.->100., default 0.72) -> colorMatrix (values [/10]) + * Lightness (-100.->100., default 0.) -> colorMatrix (values [/10]) + * Transparent (boolean, default false) -> matrix structure + + Matrix: + normal transparency + R G B St 0 0 0 0 0 0 + R G B St 0 0 0 0 0 0 + R G B St 0 0 0 0 0 0 + 0 0 0 1 0 R G B 1-St 0 +*/ +class Greyscale : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Greyscale ( ) : Filter() { }; + virtual ~Greyscale ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Greyscale, custom (Color)") "\n" + "org.inkscape.effect.filter.Greyscale\n" + "2.1\n" + "7.2\n" + "0.72\n" + "0\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Customize greyscale components") "\n" + "\n" + "\n", new Greyscale()); + }; +}; + +gchar const * +Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + std::ostringstream strength; + std::ostringstream redt; + std::ostringstream greent; + std::ostringstream bluet; + std::ostringstream strengtht; + std::ostringstream transparency; + std::ostringstream line; + + red << (ext->get_param_float("red") / 10); + green << (ext->get_param_float("green") / 10); + blue << (ext->get_param_float("blue") / 10); + strength << (ext->get_param_float("strength") / 10); + + redt << - (ext->get_param_float("red") / 10); + greent << - (ext->get_param_float("green") / 10); + bluet << - (ext->get_param_float("blue") / 10); + strengtht << 1 - (ext->get_param_float("strength") / 10); + + if (ext->get_param_bool("transparent")) { + line << "0 0 0 0"; + transparency << redt.str().c_str() << " " << greent.str().c_str() << " " << bluet.str().c_str() << " " << strengtht.str().c_str(); + } else { + line << red.str().c_str() << " " << green.str().c_str() << " " << blue.str().c_str() << " " << strength.str().c_str(); + transparency << "0 0 0 1"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str()); + return _filter; +}; /* Greyscale filter */ + +/** + \brief Custom predefined Lightness filter. + + Modify lights and shadows separately. + + Filter's parameters: + * Lightness (0.->200., default 10.) -> component (amplitude [/10]) + * Shadow (0.->200., default 10.) -> component (exponent [/10]) + * Offset (-10.->10., default 0.) -> component (offset [/10]) +*/ +class Lightness : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Lightness ( ) : Filter() { }; + virtual ~Lightness ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Lightness, custom (Color)") "\n" + "org.inkscape.effect.filter.Lightness\n" + "10.0\n" + "10.0\n" + "0.0\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Modify lights and shadows separately") "\n" + "\n" + "\n", new Lightness()); + }; +}; + +gchar const * +Lightness::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream amplitude; + std::ostringstream exponent; + std::ostringstream offset; + + amplitude << (ext->get_param_float("amplitude") / 10); + exponent << (ext->get_param_float("exponent") / 10); + offset << (ext->get_param_float("offset") / 10); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\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()); + + return _filter; +}; /* Lightness filter */ + /** \brief Custom predefined Quadritone filter. diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 1646771f4..9dd188bd3 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -72,11 +72,11 @@ public: "\n" "true\n" "\n" - "<_item value=\"darken\">" N_("Darken") "\n" - "<_item value=\"normal\">" N_("Normal") "\n" - "<_item value=\"multiply\">" N_("Multiply") "\n" - "<_item value=\"screen\">" N_("Screen") "\n" - "<_item value=\"lighten\">" N_("Lighten") "\n" + "<_item value=\"darken\">Darken\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "<_item value=\"lighten\">Lighten\n" "\n" "false\n" "false\n" @@ -96,11 +96,11 @@ public: "0\n" "true\n" "\n" - "<_item value=\"normal\">" N_("Normal") "\n" - "<_item value=\"multiply\">" N_("Multiply") "\n" - "<_item value=\"screen\">" N_("Screen") "\n" - "<_item value=\"lighten\">" N_("Lighten") "\n" - "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "<_item value=\"lighten\">Lighten\n" + "<_item value=\"darken\">Darken\n" "\n" "\n" "\n" @@ -300,12 +300,12 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) * Erase (0.->6., default 0) -> composite1 (k4) * Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation) * Dilatation (1.->50., default 6) -> color2 (n-1th value) - * Erosion (0.->50., default 3) -> color2 (nth value 0->-50) + * Erosion (0.->50., default 2) -> color2 (nth value 0->-50) * Transluscent (boolean, default false) -> composite 8 (in, true->merge1, false->composite7) * Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation) * Blur dilatation (1.->50., default 6) -> color4 (n-1th value) - * Blur erosion (0.->50., default 3) -> color4 (nth value 0->-50) + * Blur erosion (0.->50., default 2) -> color4 (nth value 0->-50) * Stroke color (guint, default 64,64,64,255) -> flood2 (flood-color), composite3 (k2) * Image on stroke (boolean, default false) -> composite2 (in="flood2" true-> in="SourceGraphic") @@ -331,19 +331,19 @@ public: "org.inkscape.effect.filter.Drawing\n" "\n" "\n" - "" N_("Simplify") "\n" + "<_param name=\"simplifyheader\" type=\"groupheader\">Simplify\n" "0.6\n" "10\n" "0\n" "false\n" - "" N_("Smoothness") "\n" + "<_param name=\"smoothheader\" type=\"groupheader\">Smoothness\n" "0.6\n" "6\n" - "3\n" - "" N_("Melt") "\n" + "2\n" + "<_param name=\"meltheader\" type=\"groupheader\">Melt\n" "1\n" "6\n" - "3\n" + "2\n" "\n" "\n" "-1515870721\n" @@ -480,7 +480,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1") * Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation) * Line width (0.01->20., default 1.5) -> blur2 (stdDeviation) - * Lightness (0.->10., default 5) -> composite1 (k3) + * Lightness (0.->10., default 0.5) -> composite1 (k3) * Blend (enum [normal, multiply, screen], default normal) -> blend (mode) * Dark mode (boolean, default false) -> composite1 (true: in2="component2") */ @@ -498,16 +498,16 @@ public: "" N_("Neon draw, custom") "\n" "org.inkscape.effect.filter.NeonDraw\n" "\n" - "<_item value=\"table\">" N_("Smoothed") "\n" - "<_item value=\"discrete\">" N_("Contrasted") "\n" + "<_item value=\"table\">Smoothed\n" + "<_item value=\"discrete\">Contrasted\n" "\n" "1.5\n" "1.5\n" - "5\n" + "0.5\n" "\n" - "<_item value=\"normal\">" N_("Normal") "\n" - "<_item value=\"multiply\">" N_("Multiply") "\n" - "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" "\n" "false\n" "\n" @@ -603,18 +603,18 @@ public: "" N_("Poster paint, custom") "\n" "org.inkscape.effect.filter.Posterize\n" "\n" - "<_item value=\"normal\">" N_("Normal") "\n" - "<_item value=\"dented\">" N_("Dented") "\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"dented\">Dented\n" "\n" "\n" - "<_item value=\"discrete\">" N_("Poster") "\n" - "<_item value=\"table\">" N_("Painting") "\n" + "<_item value=\"discrete\">Poster\n" + "<_item value=\"table\">Painting\n" "\n" "5\n" "\n" - "<_item value=\"lighten\">" N_("Lighten") "\n" - "<_item value=\"normal\">" N_("Normal") "\n" - "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"lighten\">Lighten\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"darken\">Darken\n" "\n" "4.0\n" "0.5\n" diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 7383b793a..280dc9563 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -47,9 +47,12 @@ Filter::filters_all (void ) SpecularLight::init(); // Color + Brightness::init(); Colorize::init(); Duochrome::init(); Electrize::init(); + Greyscale::init(); + Lightness::init(); Quadritone::init(); Solarize::init(); Tritone::init(); -- cgit v1.2.3