diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2011-08-17 16:19:16 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2011-08-17 16:19:16 +0000 |
| commit | a14d33de8c9e17477a13a7e76c9eb1fbe490f011 (patch) | |
| tree | f99e364c982f6b18981477cebc2b6c2545feb711 /src | |
| parent | Filters. Fixes for SVG validation (now 100% pass). (diff) | |
| download | inkscape-a14d33de8c9e17477a13a7e76c9eb1fbe490f011.tar.gz inkscape-a14d33de8c9e17477a13a7e76c9eb1fbe490f011.zip | |
Filters. New Opacity CPF, Blur and Tritone improvements.
(bzr r10548)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/internal/filter/blurs.h | 19 | ||||
| -rw-r--r-- | src/extension/internal/filter/color.h | 100 | ||||
| -rwxr-xr-x | src/extension/internal/filter/filter-all.cpp | 1 | ||||
| -rw-r--r-- | src/extension/internal/filter/paint.h | 32 | ||||
| -rw-r--r-- | src/extension/internal/filter/transparency.h | 88 |
5 files changed, 165 insertions, 75 deletions
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: "<id>org.inkscape.effect.filter.Blur</id>\n" "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" + "<param name=\"content\" gui-text=\"" N_("Blur content only") "\" type=\"boolean\">False</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\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 << "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 0 \" result=\"colormatrix\" />\n" + << "<feComposite in=\"colormatrix\" in2=\"SourceGraphic\" operator=\"in\" />\n"; + } else { + bbox << "" ; + content << "" ; + } + + _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Blur\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" %s color-interpolation-filters=\"sRGB\" inkscape:label=\"Blur\">\n" "<feGaussianBlur stdDeviation=\"%s %s\" result=\"blur\" />\n" - "</filter>\n", hblur.str().c_str(), vblur.str().c_str()); + "%s" + "</filter>\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) "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Brilliance\">\n" "<feColorMatrix values=\"%s %s %s 0 %s %s %s %s 0 %s %s %s %s 0 %s 0 0 0 1 0 \" />\n" "</filter>\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) "</filter>\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) "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Color Shift\">\n" "<feColorMatrix type=\"hueRotate\" values=\"%s\" result=\"color1\" />\n" "<feColorMatrix type=\"saturate\" values=\"%s\" result=\"color2\" />\n" - "</filter>\n", shift.str().c_str(), sat.str().c_str()); + "</filter>\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) "<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n" "<feColorMatrix in=\"blend2\" values=\"1\" type=\"saturate\" result=\"colormatrix2\" />\n" "<feComposite in=\"colormatrix2\" in2=\"SourceGraphic\" operator=\"in\" k2=\"1\" result=\"composite2\" />\n" - "</filter>\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()); + "</filter>\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) "<feComposite in=\"colormatrix2\" in2=\"composite3\" operator=\"arithmetic\" k2=\"%s\" result=\"composite4\" />\n" "<feBlend in=\"composite4\" in2=\"composite3\" blend=\"normal\" mode=\"normal\" result=\"blend\" />\n" "<feComposite in2=\"SourceGraphic\" operator=\"in\" />\n" - "</filter>\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()); + "</filter>\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( "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Greyscale\">\n" "<feColorMatrix values=\"%s 0 %s 0 %s 0 %s 0 \" />\n" - "</filter>\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str()); + "</filter>\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) "<feFuncB type=\"gamma\" amplitude=\"%s\" exponent=\"%s\" offset=\"%s\" />\n" "</feComponentTransfer>\n" "</filter>\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) "<feColorMatrix type=\"matrix\" values=\"2.5 -0.75 -0.75 0 0 -0.75 2.5 -0.75 0 0 -0.75 -0.75 2.5 0 0 0 0 0 1 0 \" result=\"colormatrix4\" />\n" "<feComposite in=\"colormatrix4\" in2=\"blend1\" operator=\"arithmetic\" k2=\"%s\" result=\"composite1\" />\n" "<feBlend in2=\"blend1\" blend=\"normal\" mode=\"%s\" result=\"blend2\" />\n" - "</filter>\n", dist.str().c_str(), colors.str().c_str(), blend1.str().c_str(), sat.str().c_str(), blend2.str().c_str()); + "</filter>\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) "<feBlend in=\"colormatrix3\" in2=\"colormatrix2\" mode=\"%s\" result=\"blend1\" />\n" "<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n" "<feComposite in2=\"SourceGraphic\" operator=\"in\" />\n" - "</filter>\n", rotate.str().c_str(), blend1.str().c_str(), blend2.str().c_str()); + "</filter>\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: "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n" "<_item value=\"normal\">" N_("Normal") "</_item>\n" "<_item value=\"enhue\">" N_("Enhance hue") "</_item>\n" - "<_item value=\"rad\">" N_("Phosphorescence") "</_item>\n" + "<_item value=\"phospho\">" N_("Phosphorescence") "</_item>\n" + "<_item value=\"phosphoB\">" N_("Phosphorescence B") "</_item>\n" "<_item value=\"htb\">" N_("Hue to background") "</_item>\n" "</param>\n" "<param name=\"globalblend\" gui-text=\"" N_("Global blend:") "\" type=\"enum\">\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( "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Tritone\">\n" - "<feColorMatrix type=\"hueRotate\" result=\"colormatrix1\" values=\"%s\" />\n" - "<feColorMatrix in=\"colormatrix1\" result=\"r\" type=\"matrix\" values=\"1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 \" />\n" - "<feColorMatrix in=\"colormatrix1\" result=\"g\" type=\"matrix\" values=\"0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 \" />\n" - "<feColorMatrix in=\"colormatrix1\" result=\"b\" type=\"matrix\" values=\"0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 \" />\n" - "<feBlend in2=\"g\" mode=\"darken\" in=\"r\" result=\"minrg\" />\n" - "<feBlend in2=\"b\" mode=\"darken\" in=\"minrg\" result=\"p\" />\n" - "<feBlend in2=\"g\" mode=\"lighten\" in=\"r\" result=\"maxrg\" />\n" - "<feBlend in2=\"b\" mode=\"lighten\" in=\"maxrg\" result=\"q\" />\n" - "<feComponentTransfer in=\"q\" result=\"q2\">\n" + "<feColorMatrix type=\"hueRotate\" values=\"%s\" result=\"colormatrix1\" />\n" + "<feColorMatrix in=\"colormatrix1\" type=\"matrix\" values=\"1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 \" result=\"colormatrix2\" />\n" + "<feColorMatrix in=\"colormatrix1\" type=\"matrix\" values=\"0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 \" result=\"colormatrix3\" />\n" + "<feColorMatrix in=\"colormatrix1\" type=\"matrix\" values=\"0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 \" result=\"colormatrix4\" />\n" + "<feBlend in=\"colormatrix2\" in2=\"colormatrix3\" mode=\"darken\" result=\"blend1\" />\n" + "<feBlend in=\"blend1\" in2=\"colormatrix4\" mode=\"darken\" result=\"blend2\" />\n" + "<feBlend in=\"colormatrix2\" in2=\"colormatrix3\" mode=\"lighten\" result=\"blend3\" />\n" + "<feBlend in=\"blend3\" in2=\"colormatrix4\" mode=\"lighten\" result=\"blend4\" />\n" + "<feComponentTransfer in=\"blend4\" result=\"componentTransfer\">\n" "<feFuncR type=\"linear\" slope=\"0\" />\n" "</feComponentTransfer>\n" - "<feBlend in2=\"q2\" mode=\"%s\" in=\"p\" result=\"pq\" />\n" - "<feColorMatrix in=\"pq\" result=\"qminp\" type=\"matrix\" values=\"-1 1 0 0 0 -1 1 0 0 0 -1 1 0 0 0 0 0 0 0 1 \" />\n" + "<feBlend in=\"blend2\" in2=\"componentTransfer\" mode=\"%s\" result=\"blend5\" />\n" + "<feColorMatrix in=\"blend5\" type=\"matrix\" values=\"-1 1 0 0 0 -1 1 0 0 0 -1 1 0 0 0 0 0 0 0 1 \" result=\"colormatrix5\" />\n" "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" - "<feComposite in=\"%s\" in2=\"%s\" result=\"qminpc\" operator=\"arithmetic\" k1=\"1\" />\n" - "<feGaussianBlur stdDeviation=\"%s\" />\n" - "<feBlend in2=\"%s\" blend=\"normal\" result=\"blend6\" mode=\"%s\" />\n" + "<feComposite in=\"colormatrix5\" in2=\"%s\" operator=\"arithmetic\" k1=\"1\" result=\"composite1\" />\n" + "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n" + "<feBlend in2=\"%s\" blend=\"normal\" mode=\"%s\" result=\"blend6\" />\n" "<feComposite in=\"%s\" in2=\"%s\" operator=\"arithmetic\" k1=\"%s\" k2=\"1\" k3=\"%s\" k4=\"0\" result=\"composite2\" />\n" - "<feComposite in2=\"SourceGraphic\" in=\"composite2\" operator=\"in\" />\n" - "</filter>\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()); + "<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite3\" />\n" + "</filter>\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: "<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">0</param>\n" "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2\">0.5</param>\n" "</page>\n" - "<page name=\"drawingcolortab\" _gui-text=\"Fill color\">\n" - "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">1229269247</param>\n" + "<page name=\"fcolortab\" _gui-text=\"Fill color\">\n" + "<param name=\"fcolor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" "<param name=\"iof\" gui-text=\"" N_("Image on fill") "\" type=\"boolean\" >false</param>\n" "</page>\n" - "<page name=\"bgcolortab\" _gui-text=\"Points color\">\n" - "<param name=\"bgcolor\" gui-text=\"" N_("Color") "\" type=\"color\">-16843009</param>\n" + "<page name=\"pcolortab\" _gui-text=\"Points color\">\n" + "<param name=\"pcolor\" gui-text=\"" N_("Color") "\" type=\"color\">1666789119</param>\n" "<param name=\"iop\" gui-text=\"" N_("Image on points") "\" type=\"boolean\" >false</param>\n" "</page>\n" "</param>\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: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Light Eraser") "</name>\n" "<id>org.inkscape.effect.filter.LightEraser</id>\n" - "<param name=\"expand\" gui-text=\"" N_("Expansion:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"1000\">100</param>\n" - "<param name=\"erode\" gui-text=\"" N_("Erosion:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"1000\">50</param>\n" + "<param name=\"expand\" gui-text=\"" N_("Expansion:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">100</param>\n" + "<param name=\"erode\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">50</param>\n" "<param name=\"opacity\" gui-text=\"" N_("Global opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" "<effect>\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( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Opacity") "</name>\n" + "<id>org.inkscape.effect.filter.Opacity</id>\n" + "<param name=\"expand\" gui-text=\"" N_("Expansion:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">5</param>\n" + "<param name=\"erode\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">1</param>\n" + "<param name=\"opacity\" gui-text=\"" N_("Global opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" + "<effect>\n" + "<object-type>all</object-type>\n" + "<effects-menu>\n" + "<submenu name=\"" N_("Filters") "\">\n" + "<submenu name=\"" N_("Fill and Transparency") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Set opacity and strength of opacity boundaries") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\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( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Opacity\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" color-interpolation-filters=\"sRGB\" >\n" + "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s \" result=\"colormatrix\" />\n" + "<feComposite in2=\"colormatrix\" operator=\"arithmetic\" k2=\"%s\" result=\"composite\" />\n" + "</filter>\n", matrix.str().c_str(), opacity.str().c_str()); + + return _filter; +}; /* Opacity filter */ + /** \brief Custom predefined Silhouette filter. |
