X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fextension%2Finternal%2Ffilter%2Fexperimental.h;h=acd258805a381183bacf1e5869c43420714a7145;hb=c7cf14ac71346f76ae219ce67fb88c1bd34832e2;hp=a8879720bdfc8cfe71012423d6aef07ef6f894b1;hpb=aec3c9ae3da6e2f0e5ff87d431716dfccfc7bd71;p=inkscape.git diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h old mode 100644 new mode 100755 index a8879720b..acd258805 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -3,7 +3,7 @@ /* Change the 'EXPERIMENTAL' above to be your file name */ /* - * Copyright (C) 2010 Authors: + * Copyright (C) 2011 Authors: * Ivan Louette (filters) * Nicolas Dufour (UI) * @@ -11,7 +11,7 @@ * Chromolitho * Drawing * Posterize - * Test filter (should no be used...) + * Posterize basic * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -38,8 +38,7 @@ namespace Filter { * Transparent (boolean, default unchecked) -> Checked = colormatrix5 (in="colormatrix4"), Unchecked = colormatrix5 (in="component1") * Invert (boolean, default false) -> component1 (tableValues) [adds a trailing 0] * Dented (boolean, default false) -> component1 (tableValues) [adds intermediate 0s] - * Expand white (0->5, default 1) -> component1 (tableValues) [0="0 1", 5="0 1 1 1 1 1 1"] - * Lightness (0->10, default 0) -> composite1 (k1) + * Lightness (0.->10., default 0.) -> composite1 (k1) * Saturation (0.->1., default 1.) -> colormatrix3 (values) * Noise reduction (1->1000, default 20) -> convolve (kernelMatrix, central value -1001->-2000, default -1020) * Drawing blend (enum, default Normal) -> blend1 (mode) @@ -65,24 +64,24 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Chromolitho, custom -EXP-") "\n" + "" N_("Chromolitho, custom") "\n" "org.inkscape.effect.filter.Chromolitho\n" "\n" "\n" "true\n" "\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" - "<_item value=\"darken\">Darken\n" "\n" "false\n" "false\n" "false\n" - "0\n" + "0\n" "1\n" - "20\n" + "10\n" "1\n" "\n" "\n" @@ -149,7 +148,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) col3in << "colormatrix4"; else col3in << "component1"; - light << ext->get_param_int("light"); + light << ext->get_param_float("light"); saturation << ext->get_param_float("saturation"); noise << (-1000 - ext->get_param_int("noise")); dblend << ext->get_param_enum("dblend"); @@ -180,8 +179,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) graincol << "0"; _filter = g_strdup_printf( - "\n" - + "\n" "\n" "\n" "\n" @@ -210,21 +208,24 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) Convert images to duochrome drawings. Filter's parameters: - * Simplification (0.01->10, default 0.7) -> blur1 (stdDeviation) - * Lightness (0->50, default 5) -> convolve (kernelMatrix, central value -1000->-1050, default -1005) - * Smoothness (0.01->10, default 0.7) -> blur2 (stdDeviation) - * Dilatation (3->100, default 6) -> colormatrix3 (n-1th value) - - * Blur (0.01->10., default 1.) -> blur3 (stdDeviation) - * Blur spread (3->20, default 6) -> colormatrix5 (n-1th value) - * Blur erosion (-2->0, default -2) -> colormatrix5 (nth value) - - * Stroke color (guint, default 205,0,0) -> flood2 (flood-opacity, flood-color) - * Image on stroke (boolean, default false) -> composite1 (in="flood2" true-> in="SourceGraphic") - * Image on stroke opacity (0.->1., default 1) -> composite3 (k3) - * Fill color (guint, default 255,203,0) -> flood3 (flood-opacity, flood-color) - * Image on fill (boolean, default false) -> composite2 (in="flood3" true-> in="SourceGraphic") - * Image on fill opacity (0.->1., default 1) -> composite3 (k2) + * Simplification (0.01->20, default 0.6) -> blur1 (stdDeviation) + * Lightness (1->500, default 10) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1010) + * Fading (0.->6., default 0) -> composite1 (k4) + * Smoothness (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) + * Transluscent (boolean, default false) -> composite 8 (in, true->merge1, false->composite7) + * Offset (-100->100, default 0) -> offset (val) + + * Blur (0.01->20., default 1.) -> blur3 (stdDeviation) + * Blur spread (1->50, default 6) -> color4 (n-1th value) + * Blur erosion (0->50, default 3) -> 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") + * Fill color (guint, default 200,200,200,255) -> flood3 (flood-opacity), composite5 (k2) + * Image on fill (boolean, default false) -> composite4 (in="flood3" true-> in="SourceGraphic") + */ class Drawing : public Inkscape::Extension::Internal::Filter::Filter { @@ -238,28 +239,30 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Drawing, custom -EXP-") "\n" + "" N_("Drawing, custom") "\n" "org.inkscape.effect.filter.Drawing\n" "\n" "\n" - "0.7\n" - "5\n" - "0.7\n" - "6\n" + "0.6\n" + "10\n" + "0\n" + "0.6\n" + "6\n" + "3\n" + "false\n" "<_param name=\"blurheader\" type=\"groupheader\">Blur\n" - "1\n" - "6\n" - "-2\n" + "1\n" + "6\n" + "3\n" "\n" "\n" - "-3473153\n" + "-1515870721\n" "false\n" - "1\n" "\n" "\n" - "-855637761\n" + "589505535\n" "false\n" - "1\n" + "0\n" "\n" "\n" "\n" @@ -282,32 +285,41 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream simply; std::ostringstream light; + std::ostringstream fade; std::ostringstream smooth; std::ostringstream dilat; - std::ostringstream blur; - std::ostringstream spread; std::ostringstream erosion; + std::ostringstream transluscent; + std::ostringstream offset; + std::ostringstream blur; + std::ostringstream bdilat; + std::ostringstream berosion; std::ostringstream strokea; std::ostringstream stroker; std::ostringstream strokeg; std::ostringstream strokeb; std::ostringstream ios; - std::ostringstream ioso; std::ostringstream filla; std::ostringstream fillr; std::ostringstream fillg; std::ostringstream fillb; std::ostringstream iof; - std::ostringstream iofo; simply << ext->get_param_float("simply"); light << (-1000 - ext->get_param_int("light")); + fade << (ext->get_param_float("fade") / 10); smooth << ext->get_param_float("smooth"); - dilat << ext->get_param_int("dilat"); - + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + if (ext->get_param_bool("transluscent")) + transluscent << "merge1"; + else + transluscent << "composite7"; + offset << ext->get_param_int("offset"); + blur << ext->get_param_float("blur"); - spread << ext->get_param_int("spread"); - erosion << ext->get_param_int("erosion"); + bdilat << ext->get_param_float("bdilat"); + berosion << (- ext->get_param_float("berosion")); guint32 fcolor = ext->get_param_color("fcolor"); fillr << ((fcolor >> 24) & 0xff); @@ -318,7 +330,6 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) iof << "SourceGraphic"; else iof << "flood3"; - iofo << ext->get_param_float("iofo"); guint32 scolor = ext->get_param_color("scolor"); stroker << ((scolor >> 24) & 0xff); @@ -329,34 +340,40 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) ios << "SourceGraphic"; else ios << "flood2"; - ioso << ext->get_param_float("ioso"); - + _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", simply.str().c_str(), light.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), blur.str().c_str(), spread.str().c_str(), erosion.str().c_str(), strokea.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), filla.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), iofo.str().c_str(), ioso.str().c_str()); + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", simply.str().c_str(), light.str().c_str(), fade.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), transluscent.str().c_str()); return _filter; }; /* Drawing filter */ @@ -384,7 +401,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Poster and painting, custom -EXP-") "\n" + "" N_("Poster and painting, custom") "\n" "org.inkscape.effect.filter.Posterize\n" "\n" "<_item value=\"normal\">Normal\n" @@ -400,8 +417,8 @@ public: "<_item value=\"normal\">Normal\n" "<_item value=\"darken\">Darken\n" "\n" - "4.0\n" - "0.5\n" + "4.0\n" + "0.5\n" "1.00\n" "1.00\n" "false\n" @@ -434,8 +451,8 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) table << ext->get_param_enum("table"); blendmode << ext->get_param_enum("blend"); - blur1 << ext->get_param_float("blur1") + 0.01; - blur2 << ext->get_param_float("blur2") + 0.01; + blur1 << ext->get_param_float("blur1"); + blur2 << ext->get_param_float("blur2"); presat << ext->get_param_float("presaturation"); postsat << ext->get_param_float("postsaturation"); @@ -459,7 +476,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) antialias << "0.01"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -478,21 +495,30 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Posterize filter */ +/** + \brief Custom predefined PosterizeBasic filter. + + Simple posterizing effect -class TestFilter : public Inkscape::Extension::Internal::Filter::Filter { + Filter's parameters: + * Levels (1->20, default 5) -> component1 (tableValues) + * Blur (0.01->20., default 4.) -> blur1 (stdDeviation) +*/ +class PosterizeBasic : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); public: - TestFilter ( ) : Filter() { }; - virtual ~TestFilter ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + PosterizeBasic ( ) : Filter() { }; + virtual ~PosterizeBasic ( ) { if (_filter != NULL) g_free((void *)_filter); return; } static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Test Filter -EXP-") "\n" - "org.inkscape.effect.filter.TestFilter\n" - "<_param name=\"header1\" type=\"groupheader\">Test filter\n" + "" N_("Posterize basic, custom") "\n" + "org.inkscape.effect.filter.PosterizeBasic\n" + "5\n" + "4.0\n" "\n" "all\n" "\n" @@ -500,36 +526,44 @@ public: "\n" "\n" "\n" - "" N_("Change colors to a two colors palette") "\n" + "" N_("Simple posterizing effect") "\n" "\n" - "\n", new TestFilter()); + "\n", new PosterizeBasic()); }; }; gchar const * -TestFilter::get_filter_text (Inkscape::Extension::Extension * ext) +PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + std::ostringstream transf; + blur << ext->get_param_float("blur"); + + transf << "0"; + int levels = ext->get_param_int("levels") + 1; + float val = 0.0; + for ( int step = 1 ; step <= levels ; step++ ) { + val = (float) step / levels; + transf << " " << val; + } + transf << " 1"; + _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", blur.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str()); return _filter; -}; /* Test filter */ +}; /* PosterizeBasic filter */ }; /* namespace Filter */ }; /* namespace Internal */