From 6ff4ed36cd6ff0aff0b8fff0040794e9a0fdcc96 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 20 Jul 2011 18:06:49 +0200 Subject: Filters. Custom predefined filters update. Translations. inkscape.pot and fr.po update. (bzr r10482) --- src/extension/internal/filter/color.h | 60 +++++++++++++++++----------- src/extension/internal/filter/experimental.h | 24 +++++++---- src/extension/internal/filter/image.h | 6 +-- src/extension/internal/filter/shadows.h | 38 +++++++++++++----- 4 files changed, 84 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 27b1fdda9..53734bee5 100755 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -39,9 +39,10 @@ namespace Filter { Brightness filter. Filter's parameters: - * Strength (-10.->10., default 1) -> colorMatrix (RVB entries) - * Vibration (-10.->10., default 0.) -> colorMatrix (6 other entries) + * Brightness (1.->10., default 2.) -> colorMatrix (RVB entries) + * Over-saturation (0.->10., default 0.5) -> colorMatrix (6 other entries) * Lightness (-10.->10., default 0.) -> colorMatrix (last column) + * Inverted (boolean, default false) -> colorMatrix Matrix: St Vi Vi 0 Li @@ -62,9 +63,10 @@ public: "\n" "" N_("Brightness, custom (Color)") "\n" "org.inkscape.effect.filter.Brightness\n" - "1\n" - "0\n" + "2\n" + "0.5\n" "0\n" + "false\n" "\n" "all\n" "\n" @@ -83,21 +85,29 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); - std::ostringstream strength; - std::ostringstream vibration; + std::ostringstream brightness; + std::ostringstream sat; std::ostringstream lightness; - strength << ext->get_param_float("strength"); - vibration << ext->get_param_float("vibration"); - lightness << ext->get_param_float("lightness"); + if (ext->get_param_bool("invert")) { + brightness << -ext->get_param_float("brightness"); + sat << 1 + ext->get_param_float("sat"); + lightness << -ext->get_param_float("lightness"); + } else { + brightness << ext->get_param_float("brightness"); + sat << -ext->get_param_float("sat"); + lightness << ext->get_param_float("lightness"); + } + + _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()); + "\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()); return _filter; }; /* Brightness filter */ @@ -192,11 +202,12 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) nlight << ext->get_param_float("nlight"); blend1 << ext->get_param_enum("blend1"); blend2 << ext->get_param_enum("blend2"); - if (ext->get_param_bool("duotone")) + if (ext->get_param_bool("duotone")) { duotone << "0"; - else + } else { duotone << "1"; - + } + _filter = g_strdup_printf( "\n" "\n" @@ -297,17 +308,17 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) b2 << ((color2 >> 8) & 0xff); fluo << fluorescence; - if((g_ascii_strcasecmp("full", swaptype) == 0)) { + if ((g_ascii_strcasecmp("full", swaptype) == 0)) { swap1 << "in"; swap2 << "out"; a1 << (color1 & 0xff) / 255.0F; a2 << (color2 & 0xff) / 255.0F; - } else if((g_ascii_strcasecmp("color", swaptype) == 0)) { + } else if ((g_ascii_strcasecmp("color", swaptype) == 0)) { swap1 << "in"; swap2 << "out"; a1 << (color2 & 0xff) / 255.0F; a2 << (color1 & 0xff) / 255.0F; - } else if((g_ascii_strcasecmp("alpha", swaptype) == 0)) { + } else if ((g_ascii_strcasecmp("alpha", swaptype) == 0)) { swap1 << "out"; swap2 << "in"; a1 << (color2 & 0xff) / 255.0F; @@ -395,8 +406,9 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) // TransfertComponent table values are calculated based on the effect level and inverted parameters. int val = 0; int levels = ext->get_param_int("levels") + 1; - if (ext->get_param_bool("invert")) + if (ext->get_param_bool("invert")) { val = 1; + } values << val; for ( int step = 1 ; step <= levels ; step++ ) { if (val == 1) { @@ -721,7 +733,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) rotate << ext->get_param_int("rotate"); const gchar *type = ext->get_param_enum("type"); - if((g_ascii_strcasecmp("solarize", type) == 0)) { + if ((g_ascii_strcasecmp("solarize", type) == 0)) { // Solarize blend1 << "darken"; blend2 << "screen"; @@ -854,21 +866,21 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) glight << ext->get_param_float("glight"); const gchar *type = ext->get_param_enum("type"); - if((g_ascii_strcasecmp("enhue", type) == 0)) { + 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)) { + } else if ((g_ascii_strcasecmp("rad", type) == 0)) { // Radiation c1in << "qminp"; c1in2 << "flood"; c2in << "blend6"; c2in2 << "qminpc"; b6in2 << "SourceGraphic"; - } else if((g_ascii_strcasecmp("htb", type) == 0)) { + } else if ((g_ascii_strcasecmp("htb", type) == 0)) { // Hue to background c1in << "qminp"; c1in2 << "BackgroundImage"; diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 96485ad97..84b0eea3d 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -580,7 +580,7 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) Normal = feComponentTransfer Dented = Normal + intermediate values * Transfer type (enum, default "descrete") -> component (type) - * Levels (1->15, default 5) -> component (tableValues) + * Levels (0->15, default 5) -> component (tableValues) * Blend mode (enum, default "Lighten") -> blend (mode) * Primary simplify (0.01->100., default 4.) -> blur1 (stdDeviation) * Secondary simplify (0.01->100., default 0.5) -> blur2 (stdDeviation) @@ -609,11 +609,13 @@ public: "<_item value=\"discrete\">Poster\n" "<_item value=\"table\">Painting\n" "\n" - "5\n" + "5\n" "\n" "<_item value=\"lighten\">Lighten\n" "<_item value=\"normal\">Normal\n" "<_item value=\"darken\">Darken\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" "\n" "4.0\n" "0.5\n" @@ -659,11 +661,19 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) int levels = ext->get_param_int("levels") + 1; const gchar *effecttype = ext->get_param_enum("type"); float val = 0.0; - for ( int step = 1 ; step <= levels ; step++ ) { - val = (float) step / levels; - transf << " " << val; - if((g_ascii_strcasecmp("dented", effecttype) == 0)) { - transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels))); + if (levels == 1) { + if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { + transf << " 1 0 1"; + } else { + transf << " 1"; + } + } else { + for ( int step = 1 ; step <= levels ; step++ ) { + val = (float) step / levels; + transf << " " << val; + if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { + transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels))); + } } } transf << " 1"; diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index 926c56a4d..f459466d5 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -53,7 +53,7 @@ public: "<_item value=\"vertical\">" N_("Vertical lines") "\n" "<_item value=\"horizontal\">" N_("Horizontal lines") "\n" "\n" - "1.0\n" + "1.0\n" "false\n" "\n" "all\n" @@ -80,14 +80,14 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) const gchar *type = ext->get_param_enum("type"); - level << ext->get_param_float("level"); + level << 1 / ext->get_param_float("level"); if ((g_ascii_strcasecmp("vertical", type) == 0)) { matrix << "0 0 0 1 -2 1 0 0 0"; } else if ((g_ascii_strcasecmp("horizontal", type) == 0)) { matrix << "0 1 0 0 -2 0 0 1 0"; } else { - matrix << "1 1 1 1 -8 1 1 1 1"; + matrix << "0 1 0 1 -4 1 0 1 0"; } if (ext->get_param_bool("inverted")) { diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index bfc6cace6..3c964da34 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -37,7 +37,8 @@ namespace Filter { * Blur type (enum, default outer) -> outer = composite1 (operator="in"), composite2 (operator="over", in1="SourceGraphic", in2="offset") inner = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="SourceGraphic") - cutout = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic") + innercut = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic") + outercut = composite1 (operator="out"), composite2 (operator="in", in1="SourceGraphic", in2="offset") * Color (guint, default 0,0,0,127) -> flood (flood-opacity, flood-color) * Use object's color (boolean, default false) -> composite1 (in1, in2) */ @@ -62,7 +63,8 @@ public: "\n" "<_item value=\"outer\">" N_("Outer") "\n" "<_item value=\"inner\">" N_("Inner") "\n" - "<_item value=\"cutout\">" N_("Cutout") "\n" + "<_item value=\"innercut\">" N_("Inner cutout") "\n" + "<_item value=\"outercut\">" N_("Outer cutout") "\n" "\n" "\n" "\n" @@ -113,14 +115,26 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) g << ((color >> 16) & 0xff); b << ((color >> 8) & 0xff); - if (ext->get_param_bool("objcolor")) { - comp1in1 << "SourceGraphic"; - comp1in2 << "flood"; + // Select object or user-defined color + if ((g_ascii_strcasecmp("outercut", type) == 0)) { + if (ext->get_param_bool("objcolor")) { + comp2in1 << "SourceGraphic"; + comp2in2 << "offset"; + } else { + comp2in1 << "offset"; + comp2in2 << "SourceGraphic"; + } } else { - comp1in1 << "flood"; - comp1in2 << "SourceGraphic"; + if (ext->get_param_bool("objcolor")) { + comp1in1 << "SourceGraphic"; + comp1in2 << "flood"; + } else { + comp1in1 << "flood"; + comp1in2 << "SourceGraphic"; + } } + // Shadow mode if ((g_ascii_strcasecmp("outer", type) == 0)) { comp1op << "in"; comp2op << "over"; @@ -131,14 +145,18 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) comp2op << "atop"; comp2in1 << "offset"; comp2in2 << "SourceGraphic"; - } else { + } else if ((g_ascii_strcasecmp("innercut", type) == 0)) { comp1op << "in"; comp2op << "out"; comp2in1 << "offset"; comp2in2 << "SourceGraphic"; + } else { //outercut + comp1op << "out"; + comp1in1 << "flood"; + comp1in2 << "SourceGraphic"; + comp2op << "in"; } - - + _filter = g_strdup_printf( "\n" "\n" -- cgit v1.2.3