From 429a74fe79316cf29eafbe9842dfd4812eaf18a5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 19 Aug 2011 14:38:26 +0200 Subject: Filters. Some extra clean-up (moving color-interpolation-filters attribute to style). Filters. New Lightness-Contrast and Fade to Black or White CPFs. Translations. POT file and French translation update. (bzr r10556) --- src/extension/internal/filter/blurs.h | 10 +- src/extension/internal/filter/bumps.h | 10 +- src/extension/internal/filter/color.h | 180 ++++++++++++++++++++++++--- src/extension/internal/filter/distort.h | 4 +- src/extension/internal/filter/filter-all.cpp | 2 + src/extension/internal/filter/image.h | 2 +- src/extension/internal/filter/morphology.h | 4 +- src/extension/internal/filter/overlays.h | 2 +- src/extension/internal/filter/paint.h | 16 +-- src/extension/internal/filter/protrusions.h | 2 +- src/extension/internal/filter/shadows.h | 2 +- src/extension/internal/filter/textures.h | 2 +- src/extension/internal/filter/transparency.h | 10 +- 13 files changed, 200 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 39d40ee33..59790b1be 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -94,7 +94,7 @@ Blur::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( - "\n" + "\n" "\n" "%s" "\n", bbox.str().c_str(), hblur.str().c_str(), vblur.str().c_str(), content.str().c_str() ); @@ -149,7 +149,7 @@ CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) blur << ext->get_param_float("blur"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -226,7 +226,7 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) blend << ext->get_param_enum("blend"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -284,7 +284,7 @@ Feather::get_filter_text (Inkscape::Extension::Extension * ext) blur << ext->get_param_float("blur"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -395,7 +395,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index ef7f1dc8b..bb2bfd8a8 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -245,7 +245,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -335,7 +335,7 @@ DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -418,7 +418,7 @@ MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -502,7 +502,7 @@ SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -696,7 +696,7 @@ WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) transparency << ext->get_param_enum("transparency"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 77fa06a25..a026e686a 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -15,9 +15,11 @@ * Component transfer * Duochrome * Extract channel + * Fade to black or white * Greyscale * Invert * Lightness + * Lightness-contrast * Nudge * Quadritone * Solarize @@ -105,7 +107,7 @@ Brilliance::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\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(), @@ -209,7 +211,7 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -278,7 +280,7 @@ ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) sat << ext->get_param_float("sat"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", shift.str().c_str(), sat.str().c_str() ); @@ -383,7 +385,7 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -471,7 +473,7 @@ ComponentTransfer::get_filter_text (Inkscape::Extension::Extension * ext) << "\n"; } _filter = g_strdup_printf( - "\n" + "\n" "\n" "%s\n" "\n" @@ -588,7 +590,7 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -700,7 +702,7 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() ); @@ -708,6 +710,82 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* ExtractChannel filter */ +/** + \brief Custom predefined Fade to Black or White filter. + + Fade to black or white. + + Filter's parameters: + * Level (0.->1., default 1.) -> colorMatrix (RVB entries) + * Fade to (enum [black|white], default black) -> colorMatrix (RVB entries) + + Matrix + black white + Lv 0 0 0 0 Lv 0 0 1-lv 0 + 0 Lv 0 0 0 0 Lv 0 1-lv 0 + 0 0 Lv 0 0 0 0 Lv 1-lv 0 + 0 0 0 1 0 0 0 0 1 0 +*/ +class FadeToBW : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + FadeToBW ( ) : Filter() { }; + virtual ~FadeToBW ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Fade to Black or White") "\n" + "org.inkscape.effect.filter.FadeToBW\n" + "1\n" + "\n" + "<_item value=\"black\">" N_("Black") "\n" + "<_item value=\"white\">" N_("White") "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Fade to black or white") "\n" + "\n" + "\n", new FadeToBW()); + }; +}; + +gchar const * +FadeToBW::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream level; + std::ostringstream wlevel; + + level << ext->get_param_float("level"); + + const gchar *fadeto = ext->get_param_enum("fadeto"); + if ((g_ascii_strcasecmp("white", fadeto) == 0)) { + // White + wlevel << (1 - ext->get_param_float("level")); + } else { + // Black + wlevel << "0"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", level.str().c_str(), wlevel.str().c_str(), + level.str().c_str(), wlevel.str().c_str(), + level.str().c_str(), wlevel.str().c_str() ); + + return _filter; +}; /* Fade to black or white filter */ + /** \brief Custom predefined Greyscale filter. @@ -793,7 +871,7 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str() ); return _filter; @@ -926,7 +1004,7 @@ Invert::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "%s" "\n" "\n", hue.str().c_str(), @@ -991,7 +1069,7 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) offset << ext->get_param_float("offset"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1004,6 +1082,80 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Lightness filter */ +/** + \brief Custom predefined Lightness-Contrast filter. + + Modify lightness and contrast separately. + + Filter's parameters: + * Lightness (0.->100., default 0.) -> colorMatrix + * Contrast (0.->100., default 0.) -> colorMatrix + + Matrix: + Co/10 0 0 1+(Co-1)*Li/2000 -(Co-1)/20 + 0 Co/10 0 1+(Co-1)*Li/2000 -(Co-1)/20 + 0 0 Co/10 1+(Co-1)*Li/2000 -(Co-1)/20 + 0 0 0 1 0 +*/ +class LightnessContrast : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + LightnessContrast ( ) : Filter() { }; + virtual ~LightnessContrast ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Lightness-Contrast") "\n" + "org.inkscape.effect.filter.LightnessContrast\n" + "0\n" + "0\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Modify lightness and contrast separately") "\n" + "\n" + "\n", new LightnessContrast()); + }; +}; + +gchar const * +LightnessContrast::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream lightness; + std::ostringstream contrast; + std::ostringstream contrast5; + + gfloat c5; + if (ext->get_param_float("contrast") > 0) { + contrast << (1 + ext->get_param_float("contrast") / 10); + c5 = (- ext->get_param_float("contrast") / 20); + } else { + contrast << (1 + ext->get_param_float("contrast") / 100); + c5 =(- ext->get_param_float("contrast") / 200); + } + + contrast5 << c5; + lightness << ((1 - c5) * ext->get_param_float("lightness") / 100); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", contrast.str().c_str(), lightness.str().c_str(), contrast5.str().c_str(), + contrast.str().c_str(), lightness.str().c_str(), contrast5.str().c_str(), + contrast.str().c_str(), lightness.str().c_str(), contrast5.str().c_str() ); + + return _filter; +}; /* Lightness-Contrast filter */ + /** \brief Custom predefined Nudge filter. @@ -1125,7 +1277,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1220,7 +1372,7 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) blend2 << ext->get_param_enum("blend2"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1300,7 +1452,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1455,7 +1607,7 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h index 56855abea..f4caf3d11 100644 --- a/src/extension/internal/filter/distort.h +++ b/src/extension/internal/filter/distort.h @@ -146,7 +146,7 @@ FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -232,7 +232,7 @@ Roughen::get_filter_text (Inkscape::Extension::Extension * ext) intensity << ext->get_param_float("intensity"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str()); diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index c145dd717..7dd35b055 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -56,9 +56,11 @@ Filter::filters_all (void ) ComponentTransfer::init(); Duochrome::init(); ExtractChannel::init(); + FadeToBW::init(); Greyscale::init(); Invert::init(); Lightness::init(); + LightnessContrast::init(); Nudge::init(); Quadritone::init(); Solarize::init(); diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index 47744a2f6..b0a6367e1 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -97,7 +97,7 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str()); diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 2f5c3ecc8..e51eb5a0b 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -88,7 +88,7 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -177,7 +177,7 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h index 12e7b5985..b98577ce1 100644 --- a/src/extension/internal/filter/overlays.h +++ b/src/extension/internal/filter/overlays.h @@ -123,7 +123,7 @@ NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) inverted << "in"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index fec2f8356..678c0c08f 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -183,7 +183,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) graincol << "0"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -274,7 +274,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) trans << "blend"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -434,7 +434,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) ios << "flood2"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -544,7 +544,7 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -638,7 +638,7 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -804,7 +804,7 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) iop << "flood1"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -942,7 +942,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) antialias << "0.01"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1018,7 +1018,7 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) transf << " 1"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/protrusions.h b/src/extension/internal/filter/protrusions.h index 9103bdc11..8ba35db62 100644 --- a/src/extension/internal/filter/protrusions.h +++ b/src/extension/internal/filter/protrusions.h @@ -71,7 +71,7 @@ Snow::get_filter_text (Inkscape::Extension::Extension * ext) drift << ext->get_param_float("drift"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 2d63ac00f..a1a82111d 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -158,7 +158,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/textures.h b/src/extension/internal/filter/textures.h index f0086eccf..513483e26 100644 --- a/src/extension/internal/filter/textures.h +++ b/src/extension/internal/filter/textures.h @@ -133,7 +133,7 @@ InkBlot::get_filter_text (Inkscape::Extension::Extension * ext) stroke << ext->get_param_enum("stroke"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 989df0131..1397b726d 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -89,7 +89,7 @@ Blend::get_filter_text (Inkscape::Extension::Extension * ext) mode << ext->get_param_enum("mode"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", source.str().c_str(), mode.str().c_str() ); @@ -170,7 +170,7 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), @@ -245,7 +245,7 @@ LightEraser::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", expand.str().c_str(), erode.str().c_str(), opacity.str().c_str()); @@ -308,7 +308,7 @@ Opacity::get_filter_text (Inkscape::Extension::Extension * ext) << (-ext->get_param_float("erode")); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", matrix.str().c_str(), opacity.str().c_str()); @@ -381,7 +381,7 @@ Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) blur << ext->get_param_float("blur"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" -- cgit v1.2.3